Skip to content

Commit

Permalink
Add easily-enabled lints
Browse files Browse the repository at this point in the history
This set seems useful, and only has one violation:
```
common/testing/event_generator.go:420:2: [modifies-value-receiver] suspicious assignment to a by-value method receiver
```
That has been fixed in this commit.
It appears unused, and is likely just a mistake from copying the value getters.
And I've kept this lint especially because I can't see a legitimate reason to allow it - it's fairly error-prone, due to implicit copies when passed by value.

The other lints are pretty obvious by their name, have zero results currently, and have no significant impact on runtime.
They seem worth maintaining going forward.
  • Loading branch information
Groxx committed Feb 2, 2021
1 parent fedcdaf commit db2a0e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common/testing/event_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func (c HistoryEventEdge) GetCondition() func(...interface{}) bool {
}

// SetAction sets an action to perform when the end vertex hits
func (c HistoryEventEdge) SetAction(action func()) {
func (c *HistoryEventEdge) SetAction(action func()) {

c.action = action
}
Expand Down
14 changes: 14 additions & 0 deletions revive.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,17 @@ arguments=[["loop","method-call","recover","return"]]
# string(int) is almost always a bug.
# go vet considers this a fatal error, but only in 1.15 or newer, and go.mod currently targets 1.13
[rule.string-of-int]

#### added because we currently have zero violations, and they seem decent enough to retain

[rule.atomic] # correct use of sync code, important
[rule.call-to-gc] # beneficial
[rule.constant-logical-expr] # minor code simplifier
[rule.identical-branches] # code simplifier / failures are pretty dubious
[rule.modifies-parameter] # beneficial
[rule.modifies-value-receiver] # probably beneficial, prevents subtle bugs
[rule.range-val-address] # beneficial
[rule.range-val-in-closure] # beneficial
[rule.unconditional-recursion] # probably a good idea
[rule.unreachable-code] # code simplifier
[rule.waitgroup-by-value] # correct use of sync code, important

0 comments on commit db2a0e5

Please sign in to comment.