-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix linter golint #2240
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
Fix linter golint #2240
Conversation
@@ -42,14 +42,14 @@ type CSVUpdater interface { | |||
Apply(*olmapiv1alpha1.ClusterServiceVersion) error | |||
} | |||
|
|||
type updaterStore struct { | |||
type UpdaterStore struct { |
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 are we exporting this type?
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.
The error occurs because of NewUpdaterStore which will return this structure and is used in another place. See
store := NewUpdaterStore() |
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.
After looking at it, exporting it does make sense now. I'm okay with this.
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.
@joelanford I understand that your only concern with this PR still this point. However, it is used outside then shows that could not be in lower case at all.
So, if you agree and it is ok for you too, I think we could move forward this one and get it merged. WDYT?
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.
This is being removed in #2250.
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.
Good point so, I will ignore this check for we merge this one.
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.
H @estroz and @joelanford,
It was ignored as well. So, I think we could safely move forward here.
/hold |
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.
/lgtm
@@ -36,7 +36,7 @@ var ( | |||
skipGeneration bool | |||
) | |||
|
|||
func newAddApiCmd() *cobra.Command { | |||
func newAddAPICmd() *cobra.Command { |
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.
👍
cmd/operator-sdk/new/cmd.go
Outdated
// The nolint here is used to hide the warning "func name will be used as new.NewCmd by other packages, and that stutters; consider calling this Cmd" | ||
// which is a false positive. |
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.
can we wrap the comment so it's 80 columns per line? At least break up the first one into 2 lines.
@@ -31,7 +31,7 @@ func NewCmd() *cobra.Command { | |||
Short: "Run scorecard tests", | |||
Long: `Runs blackbox scorecard tests on an operator | |||
`, | |||
RunE: scorecard.ScorecardTests, | |||
RunE: scorecard.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.
I'm fine with this.
internal/flags/watch/flags.go
Outdated
// The nolint is regards to: type name will be used as watch.WatchFlags by other packages, and that stutters; consider calling this Flags (golint) | ||
// todo(camilamacedo86): Note that we decided to not introduce breakchanges to add the linters and it should be done after. | ||
// From @joe: Even though watch.WatchFlags is an internal type, being embedded here means that changing it to watch.Flags is a breaking change | ||
// to AnsibleOperatorFlags, which is exported. So this is a breaking change. |
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.
wrap the comments to 80 or so so I don't have to scroll to the right to read.
var AnsibleDelims = [2]string{"[[", "]]"} | ||
var ( | ||
AnsibleDelims = [2]string{"[[", "]]"} | ||
) |
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.
This isn't the correct fix for the lint error, which was
internal/scaffold/ansible/constants.go:30:1: comment on exported var `AnsibleDelims` should be of the form `AnsibleDelims ...` (golint)
The correct fix is:
// AnsibleDelims is a slice of two strings representing the left and right delimiters for ansible templates. Arrays can't be constants but this should be a constant.
var AnsibleDelims = [2]string{"[[", "]]"}
@@ -42,14 +42,14 @@ type CSVUpdater interface { | |||
Apply(*olmapiv1alpha1.ClusterServiceVersion) error | |||
} | |||
|
|||
type updaterStore struct { | |||
type UpdaterStore struct { |
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.
After looking at it, exporting it does make sense now. I'm okay with this.
func (store *UpdaterStore) Apply(csv *olmapiv1alpha1.ClusterServiceVersion) error { | ||
updaters := []CSVUpdater{store.installStrategy, store.crds, store.almExamples} |
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.
What is the linter complaining about here? -1 I think s
is just fine. I use single letters for all of my struct receivers. I agree store
is easier to read, but I knew it was the store because of the receiver. It's a very common paradigm. In our broker repo there are 12260 instances of func (a *
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.
Nevermind, I see it now. You are simply making it consistent.
@@ -83,10 +83,10 @@ func ToSnake(s string) string { | |||
} | |||
bits := []string{} | |||
n := "" | |||
real_i := -1 | |||
iReal := -1 |
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.
yep I'm surprised underscore variable compiled.
type ScorecardFormatter interface { //nolint:golint | ||
// todo(camilamacedo86): The no lint here is for pkg/apis/scorecard/formatting.go:25:6: type name will be used as scorecard.ScorecardFormatter by other packages, and that stutters; consider calling this Formatter (golint) | ||
// However, was decided to not move forward with it now in order to not introduce breakchanges with the task to add the linter. We should to do it after. |
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.
👍
New changes are detected. LGTM label has been removed. |
/retest Please review the full test history for this PR and help us cut down flakes. |
New changes are detected. LGTM label has been removed. |
var AnsibleDelims = [2]string{"[[", "]]"} | ||
var ( | ||
AnsibleDelims = [2]string{"[[", "]]"} | ||
) |
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.
This isn't the correct fix for the lint error, which was
internal/scaffold/ansible/constants.go:30:1: comment on exported var `AnsibleDelims` should be of the form `AnsibleDelims ...` (golint)
The correct fix is:
// AnsibleDelims is a slice of two strings representing the left and right delimiters for ansible templates. Arrays can't be constants but this should be a constant.
var AnsibleDelims = [2]string{"[[", "]]"}
internal/flags/watch/flags.go
Outdated
/* | ||
The nolint is regards to: type name will be used as watch.WatchFlags by other packages, and that stutters; consider calling this Flags (golint) | ||
todo(camilamacedo86): Note that we decided to not introduce breakchanges to add the linters and it should be done after. | ||
From @joe: Even though watch.WatchFlags is an internal type, being embedded here means that changing it to watch.Flags is a breaking change |
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.
From @joe: Even though watch.WatchFlags is an internal type, being embedded here means that changing it to watch.Flags is a breaking change | |
From @joelanford: Even though watch.WatchFlags is an internal type, it is embedded in exported types, which means that changing it to watch.Flags is a breaking change. |
Then also delete line 31.
New changes are detected. LGTM label has been removed. |
/* | ||
* todo(camilamacedo86): remove //nolint:golint after merge of https://github.com/operator-framework/operator-sdk/pull/2250 | ||
Skip golint because it will be changed here: https://github.com/operator-framework/operator-sdk/pull/2250 | ||
receiver name store should be consistent with previous receiver name s for updaterStore (golint) |
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.
This should be fixable by renaming store
to s
. Is there a reason we aren't doing that?
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.
the above PR was merged. So, i will be working on it and let you know.
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.
One nit. Other than that, it LGTM.
@@ -97,6 +103,7 @@ type InstallStrategyUpdate struct { | |||
} | |||
|
|||
func (store *updaterStore) AddRole(yamlDoc []byte) error { | |||
|
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.
Nit: remove the extraneous new lines that were added in this PR.
Closes: #2227