Closed itsamirhn closed 3 weeks ago
Hey, thank you for opening your first Pull Request !
In order for a pull request adding a linter to be reviewed, the linter and the PR must follow some requirements.
go/analysis
.v1.0.0
, v0.1.0
.init()
.panic()
.log.fatal()
, os.exit()
, or similar..golangci.next.reference.yml
.golangci.next.reference.yml
must be updated..golangci.reference.yml
must NOT be edited.enable
and disable
options.golangci.yml
of golangci-lint itself must not be edited and the linter must not be added to this file.lintersdb/builder_linter.go
and .golangci.next.reference.yml
.WithLoadMode(...)
):
goanalysis.LoadModeSyntax
-> no WithLoadForGoAnalysis()
in the lintersdb/builder_linter.go
goanalysis.LoadModeTypesInfo
, it requires WithLoadForGoAnalysis()
in the lintersdb/builder_linter.go
WithSince(...)
must be the next minor version (v1.X.0
) of golangci-lint.WithURL()
must contain the URL of the repository.jsonschema/golangci.next.jsonschema.json
should be updated.jsonschema/golangci.jsonschema.json
must NOT be edited..gitignore
(IDE files, binaries, OS files, etc. should not be committed)The golangci-lint team will edit this comment to check the boxes before and during the review.
The code review will start after the completion of those checkboxes (except for the specific items that the team will help to verify).
The reviews should be addressed as commits (no squash).
If the author of the PR is a member of the golangci-lint team, he should not edit this message.
This checklist does not imply that we will accept the linter.
Why var scope?
Sometimes this is useful for debug in IDE, especially if function result cannot be executed at breakpoint time. JFYI
The reviews should be addressed as commits (no squash).
Oh my bad. I was bumping up my linter version.
As long as the elements required by the checklist (except those related to maintainer actions) are not handled, the review will not start.
I'm sorry but i think I make the changes done (such as adding to the list of available linters or .gitignore) but it's still uncheck. What should i do?
What should i do?
please read the checklist.
I'm not a bot: the checklist is updated by hand.
So, please read the checklist.
The linter must be added to the list of available linters (alphabetical case-insensitive order)
Is't already added and sorted?
The full quote:
[ ] The linter must be added to the list of available linters (alphabetical case-insensitive order).
enable
anddisable
options
Although the items required by the checklist are still not addressed, I will provide a review.
The following examples are illustrations of what we may call false positives:
error handling:
func sample() {
if err := operation(); err == nil {
fmt.Println("foo")
}
}
multiple values:
func sample(req *http.Request, a string) {
if myHeader := req.Header.Get("My-Header"); myHeader == "" && a != "" {
fmt.Println(a)
}
}
named boolean:
func sample() {
if isPreflight := operation(); isPreflight {
fmt.Println("foo")
}
}
All those cases are legit because the variables are used for readability.
IMO, this linter will lead to bad practices: readability is more important than removing a local variable that the compiler already removes during compilation.
So I will decline this linter.
You can still use it as a plugin: https://golangci-lint.run/contributing/new-linters/#how-to-add-a-private-linter-to-golangci-lint
Thanks for your review and time.
Hi,
I'd like to add a new linter: whyvarscope
It looks for variable scoped if statements and if the variable can be removed, it suggest to do that.
For example:
Could be convert to:
It also cares for some edge cases like and do not report error: