-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add linter check support #679
Conversation
Codecov Report
@@ Coverage Diff @@
## master #679 +/- ##
==========================================
+ Coverage 55.69% 63.64% +7.94%
==========================================
Files 48 48
Lines 2027 2027
==========================================
+ Hits 1129 1290 +161
+ Misses 766 605 -161
Partials 132 132
Continue to review full report at Codecov.
|
.golangci.yaml
Outdated
misspell: | ||
locale: US | ||
goimports: | ||
local-prefixes: github.com/rahul23/trivy |
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.
local-prefixes: github.com/rahul23/trivy | |
local-prefixes: github.com/aquasecurity/trivy |
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.
It was for running the linter check in workflow here, reverted
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.
Reverted to rahul2393?
pkg/detector/ospkg/detect.go
Outdated
} | ||
return d | ||
log.Logger.Warnf("unsupported os : %s", osFamily) |
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.
Hmm... I prefer the previous one. If we follow the linter, return xxx.NewScanner()
looks better.
.golangci.yaml
Outdated
@@ -65,6 +65,9 @@ issues: | |||
- linters: | |||
- golint | |||
text: "a blank import should be only in a main or test package" | |||
- linters: | |||
- govet | |||
text: "shadow: declaration of" |
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.
Ok, done,
.golangci.yaml
Outdated
misspell: | ||
locale: US | ||
goimports: | ||
local-prefixes: github.com/rahul23/trivy |
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.
Reverted to rahul2393?
@knqyf263 Done |
@rahul2393 The linter test seems to be failing. |
As I said it will fail, but once merged it will succeed |
Let me know what are next action items now |
Could you clarify it? I don't get your point yet. |
No, I meant why it needs to be rahul2393. |
Maybe because the workflow run my forked repo |
I also thought so, but I didn't find the clue. And if so, it means PR always fails the linter test. |
@knqyf263 removed that config now I think its good. |
We should find out what effect the option has and make sure it's okay to remove it. We have to avoid "we don't know why it fails, but it looks good after removing it" as much as possible. |
@knqyf263 this is to grouping the import in separate lines and disabling local prefixes will not cause issue. |
@knqyf263 Check now, added back the local-prefixes goimport and linter issues fixed |
Hmm. Please allow me to check that my understanding is correct or not. What you said as follows is not correct, right? Even after it is merged, the grouping still violates the policy, so the test will fail. Also, can we specify |
@knqyf263 Done, make sense to add "github.com/aquasecurity" as local prefix. |
@rahul2393 What about the first question? Is my understanding correct? I'd like to figure out what was wrong. |
Yes, I was wrong before, if its merged now it will work fine because in all the files the grouping is fine, e.g
|
It makes sense. Thanks! I'll take a look at last. |
"golang.org/x/xerrors" | ||
|
||
"github.com/Masterminds/semver/v3" |
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.
Could you group them?
pkg/detector/library/driver.go
Outdated
"golang.org/x/xerrors" | ||
|
||
"github.com/Masterminds/semver/v3" |
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.
ditto
pkg/detector/library/detect.go
Outdated
"golang.org/x/xerrors" | ||
|
||
"github.com/google/wire" | ||
|
||
"github.com/Masterminds/semver/v3" |
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.
ditto
"golang.org/x/xerrors" | ||
|
||
"github.com/Masterminds/semver/v3" |
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.
ditto
"github.com/urfave/cli/v2" | ||
|
||
"github.com/aquasecurity/trivy/internal/config" |
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.
same here
@@ -56,31 +62,31 @@ func (d Detector) Detect(_, osFamily, osName string, _ time.Time, pkgs []ftypes. | |||
return vulns, eosl, nil | |||
} | |||
|
|||
// nolint: gocyclo | |||
// TODO: fix cyclometic complexity by removing default |
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.
I'd like to know why gocyclo
complains default
. Is it only about default
? Or, even if we remove default
and add a new family, will gocyclo
complain again?
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.
even if you replace the default with a different case, it will complain because by default cyclomatic complexity of 10, and for this function, default branch is adding up to 11
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.
So, removing default
doesn't address the root issue. Let's consider it carefully later.
pkg/detector/ospkg/photon/photon.go
Outdated
version "github.com/knqyf263/go-rpm-version" | ||
|
||
"golang.org/x/xerrors" | ||
|
||
"k8s.io/utils/clock" |
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.
grouping
pkg/github/github.go
Outdated
"golang.org/x/oauth2" | ||
"golang.org/x/xerrors" | ||
|
||
"github.com/google/go-github/v28/github" |
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.
grouping
pkg/report/writer.go
Outdated
"golang.org/x/xerrors" | ||
|
||
"github.com/olekukonko/tablewriter" |
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.
ditto
pkg/rpc/retry.go
Outdated
"github.com/cenkalti/backoff" | ||
|
||
"github.com/twitchtv/twirp" |
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.
same
@knqyf263 I tried fixing all these issues |
@@ -56,31 +62,31 @@ func (d Detector) Detect(_, osFamily, osName string, _ time.Time, pkgs []ftypes. | |||
return vulns, eosl, nil | |||
} | |||
|
|||
// nolint: gocyclo | |||
// TODO: fix cyclometic complexity by removing default |
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.
So, removing default
doesn't address the root issue. Let's consider it carefully later.
@rahul2393 Thanks. |
* add linter supports * add only minor version * use latest version * Fix println with format issue * Fix test * Fix tests * For slice with unknown length, preallocating the array * fix code-coverage * Removed linter rules * Reverting linter fixes, adding TODO for later * Ignore linter error for import * Remove another err var. * Ignore shadow error * Fixes * Fix issue * Add back goimports local-prefixes * Update local prefixes * Removed extra spaces and merge the imports * more refactoring * Update photon.go Co-authored-by: Teppei Fukuda <[email protected]>
Issue