-
Notifications
You must be signed in to change notification settings - Fork 224
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
chore(lint): Add support for linter in mage #2392
Conversation
list-mode: lax | ||
deny: | ||
# Cannot use gomodguard, which examines go.mod, as "golang.org/x/exp/slices" is not a module and doesn't appear in go.mod. | ||
- pkg: "golang.org/x/exp/slices" |
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'm not sure it's relevant for trivy-operator
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.
thanks, removed!
@@ -46,8 +47,8 @@ func evaluate(ctx context.Context, policies *policy.Policies, resource client.Ob | |||
if err != nil { | |||
return Misconfiguration{}, err | |||
} | |||
infraChecks := make([]v1alpha1.Check, 0) | |||
checks := make([]v1alpha1.Check, 0) | |||
var infraChecks []v1alpha1.Check |
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 looks like it's not equal update.
misc/lint/rules.go
Outdated
`$name := []$t{}`, | ||
`$name := make([]$t, 0)`, | ||
). | ||
Suggest(`var $name []$t`). | ||
Report(`replace '$$' with 'var $name []$t'`) | ||
} |
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.
as for me, var $name []$t
isn't equal $name := make([]$t, 0)
,
because $name := make([]$t, 0)
contains two operations:
- create a new variable
- init this one with an empty array,
but var $name []$t
does only creating
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 after var $name []$t
, $name
is nil, but after $name := make([]$t, 0)
$name
is []$t
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.
You're right, in this case as per the golang spec it makes sense to use make
due to JSON being involved. I've updated it.
pkg/kube/secrets.go
Outdated
@@ -142,7 +143,7 @@ type secretsReader struct { | |||
} | |||
|
|||
func (r *secretsReader) ListByLocalObjectReferences(ctx context.Context, refs []corev1.LocalObjectReference, ns string) ([]corev1.Secret, error) { | |||
secrets := make([]corev1.Secret, 0) | |||
var secrets []corev1.Secret |
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.
imho it's not equal too, and it's important for tests
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.
updated.
8aa63b3
to
ded4707
Compare
@afdesk thanks for the review, could you take another look? The tests are green now. |
"github.com/aquasecurity/go-version/pkg/semver" | ||
) | ||
|
||
func compareTagVersion(currentTag string, contraint string) bool { | ||
c, err := semver.NewConstraint(contraint) | ||
func compareTagVersion(currentTag, constraint string) bool { | ||
c, err := semver.NewConstraints(constraint) |
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.
Was this change made by linter?
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.
partially yes. The change to eliminate the redundant type was suggested by the linter and the typo was fixed by me.
As for the semver package, We have had issues in the past with upstream semver, for aqua projects we use the aqua go-version pkg.
TrueString = "true" | ||
FalseString = "false" |
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.
just note. For me it's an interesting action for linter
@simar7 LGTM I left two comments just to make sure you saw and approved these changes. |
Description
.golanci.yaml
is taken from Trivy.