-
Notifications
You must be signed in to change notification settings - Fork 803
refactor: add missing error checks #7079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @ankitm123. Thanks for your PR. I'm waiting for a jenkins-x member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
/test lint |
So after rebasing, the lint failed again. So, I decided to split the linting into two files - linter.sh and linter-extra.sh, keeping the increased limits for both of those linting jobs. |
/test lint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Not so sure between the separation between lint
and lint-extra
. Where is the differentiation and how would we evolve things? Were would one add a new check and why? Can you explain your motivation?
Makefile
Outdated
@@ -213,6 +213,7 @@ importfmt: get-fmt-deps | |||
lint: ## Lint the code | |||
./hack/gofmt.sh | |||
./hack/linter.sh | |||
./hack/linter-extra.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the separation? What do you try to achieve?
hack/linter-extra.sh
Outdated
${DIR}/install_golint.sh -b $GOPATH/bin v1.20.0 | ||
fi | ||
|
||
export GO111MODULE=on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I find it hard to see what the difference between lint and lint-extra is. I fear this might confuse others as well. What do we gain?
AFAICT, the bulk of the scripts are identical. So if we really want to split into multiple lint steps in Makefile
and jenkins-x-lint.yaml
, then I think it should be a single linter script and you pass in by argument which checks to run.
If this is just about splitting into more tasks and contexts, one thing I want to do for a long time it to break out a codegen
context (`jenkins-x-codegen.yaml) and so the code generation checks separately. That's technically really not linting and it has confused people before. I'd rather do that than splitting lint and lint-extra (unless there is something I am missing here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint -> all the old linters, lint-extra -> new linters (ununsed and errcheck). It's a bit difficult for me to know where the script really fails. I tried various combinations, and this is the one which succeeded. I think it might make sense to coordinate over slack, if that's an option. I can try making the changes, and if you can get me the logs, that would help us debug it 🥇 wdyt? Let me try to separate the code gen from linting, and see what happens.
if err != nil { | ||
return errors.Wrapf(err, "checking if file %s exists", path) | ||
} | ||
if exists { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 sweet
@@ -123,7 +123,10 @@ func (o *GetPipelineOptions) Run() error { | |||
if err != nil { | |||
return err | |||
} | |||
o.dump(jenkins, job.Name, &table) | |||
err = o.dump(jenkins, job.Name, &table) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -90,7 +92,10 @@ func (e ElasticsearchProvider) SendRelease(r *v1.Release) error { | |||
r.Namespace: r.CreationTimestamp.String(), | |||
}, | |||
} | |||
e.SendIssue(&esissue) | |||
err = e.SendIssue(&esissue) | |||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@hferentschik combining all the linters into one lint file, made it fail again. Can we increase the memory further. There is also the option to use a lower value of GOGC, this will reduce the memory usage, but at the expense of making the tests run longer. https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint |
So the lint passed after I set GOGC=10 💯 . Not sure, how to add the new code-gen to the list of existing checks ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, let me enable jenkins-x-codegen
context so that we can see this context run. Once it is configured we can see it works and merge. Then we will make it a required context.
@@ -0,0 +1,32 @@ | |||
buildPack: none |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will need to enable the new context in the configuration for the repo.
jenkins-x-codegen.yml
Outdated
- name: generate | ||
image: golang:1.12.10 | ||
command: ./hack/generate.sh | ||
dir: /workspace/go/src/github.com/jenkins-x/jx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick, missing newline
@ankitm123 - fyi https://github.com/jenkins-x/environment-tekton-weasel-dev/pull/581. Once that's merging the new context should appear and we can rebuild the whole PR. If all looks good we can merge and then we can make it a required context. |
/test codegen |
I think we need the copy parts from the lint status check as well to move the sources to the "right" location. At least while we are still on Go 1.12. |
Signed-off-by: ankitm123 <[email protected]>
@hferentschik great, the codegen bit works now, gonna remove that copy part from the lint (it's not needed any more imo). |
/retest |
cpu: 3 | ||
memory: 6Gi | ||
steps: | ||
- name: mk-jx-project-dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:+1
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hferentschik The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This is a great change, but I think it would be useful to log an error for missing error checks in one PR before returning the error, because it alters behaviour of the codebase (albeit incorrect). Then a subsequent PR which returns the error would be required (when the impact is understood), and arguably could be a case for a minor version increment. |
You are right. Honestly, I thought that this PR might lead to some cases, where the downstream code relies on no errors being returned. There are about 90 places in the codebase where I have skipped errchecks (using nolint). Not catching the error can lead to unintended results though, for instance we still dont handle errors for any of the defer functions and I am not sure what kind of bugs they have introduced (for instance we dont know if those files are being closed properly). Are you seeing any places where handling the errors have led to some issues? Would be nice to re-evaluate the logic there. |
Signed-off-by: ankitm123 [email protected]
Submitter checklist
Which issue this PR fixex
fixes #6851