* modifies-value-receiver: warn on slice or map
Assignments which index into the slice or map are already ignored on
line 72, and those where the whole receiver is slice or map on line 50.
We should not ignore assignments where the member variable is slice
or map.
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
* Remove extra space
---------
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Co-authored-by: Denis Voytyuk <5462781+denisvmedia@users.noreply.github.com>
Add the ability to allow list of packages to be dot imported.
Add a new don-imports configuration:
* `allowedPackages`: (string) comma-separated list of allowed dot import packages
Example:
```toml
[rule.dot-imports]
arguments = [{ allowedPackages = "github.com/onsi/ginkgo/v2,github.com/onsi/gomega" }]
```
* refactor: extract shared code for linting if-else chains
The rules "early-return", "indent-error-flow" and
"superfluous-else" have a similar structure. This
moves the common logic for classifying if-else chains
to a common package.
A few side benefits:
- "early-return" now handles os.Exit/log.Panicf/etc
- "superfluous-else" now handles (builtin) panic
- "superfluous-else" and "indent-error-flow" now handle if/else
chains with 2+ "if" branches
* internal/ifelse: style fixes, renames, spelling
This fixes a false positive reported by revive on the following:
select {}
This is a way to block the program indefinitely.
It is used in cases like:
- Running a long-running server in a background thread
and blocking `main` from exiting until the application dies.
This is something you might do if your process has
multiple servers/listeners in the same process.
```go
go grpcListenAndServe()
go httpListenAndServe()
go logFlusher()
select {}
```
- In programs compiled to WASM to prevent the application from exiting,
so that the Javascript components may interact with it.
```go
func main() {
js.Global().Set("foo", foo)
select {}
}
```
Without this, one may see an error like,
"Error: Go program has already exited"
As a workaround, these programs can block forever
by receiving from a throwaway channel (`<-make(chan struct{})`),
but `select {}` is still a completely valid way of doing this,
so supporting it makes sense.
The issue was previously reported in #698 but was closed
because the author was satisfied with a `//nolint` comment.
Now that this rule is part of the default rule set (#799)
the case for addressing the false positive is stronger.
Resolves#804