Skip to content

Commit

Permalink
Don't lint the generated deepcopy file
Browse files Browse the repository at this point in the history
I found it a bit hard to understand how to configure this but looking at
the example config
(https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml)
this seems right.

Since we don't control these files, it makes sense to skip linting them.

Recently we bumped the linter, which pulled in a new version of gosec,
which started flagging "Implicit memory aliasing in for loop" in the
generated files. This is a bit weird but at least we know that the
values are being used immediately and not stored, so it seems (famous
last words) unlikely to hit the bug these are trying to catch
(this issue has an example of the kind of bug this catches:
https://github.com/trailofbits/gosec/issues/1)

e.g. the code getting flagged:
```
		for key, val := range *in {
			var outVal *PipelineRunTaskRunStatus
			if val == nil {
				(*out)[key] = nil
			} else {
				in, out := &val, &outVal
				*out = new(PipelineRunTaskRunStatus)
				(*in).DeepCopyInto(*out)
			}
			(*out)[key] = outVal
		}
```
  • Loading branch information
bobcatfish committed Jun 18, 2020
1 parent 67f5476 commit 0779a46
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ run:
issues-exit-code: 1
build-tags:
- e2e
skip-files:
- path: .*/zz_generated.deepcopy.go
skip-dirs:
- vendor
- pkg/client
Expand Down

0 comments on commit 0779a46

Please sign in to comment.