1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-24 08:32:22 +02:00
Commit Graph

8 Commits

Author SHA1 Message Date
Robert Liebowitz
2b4286ede2
Drop if-return from default ruleset (#843)
The `if-return` rule was originally a golint rule which was removed
from their ruleset for being out of scope. Similarly, it was dropped
from revive intentionally as a result of #537. More recently, it was
reintroduced into the default ruleset as a result of #799 due to a
discrepancy in documentation without a discussion of whether this rule
in particular belonged as a part of that default rule set.

While it is no longer a goal of this project to align 100% with the
golint defaults, I believe that this rule gives bad advice often enough
that it should not be enabled by default.

For example, consider the following code:

```go
if err := func1(); err != nil {
	return err
}

if err := func2(); err != nil {
	return err
}

if err := func3(); err != nil {
	return err
}

return nil
```

The `if-return` rule considers this a violation of style, and instead
suggests the following:

```go
if err := func1(); err != nil {
	return err
}

if err := func2(); err != nil {
	return err
}

return func3()
```

While this is more terse, it has a few shortcomings compared to the
original. In particular, it means extending the size of the diff if
changing the order of checks, adding logic after the call that currently
happens to be last, or choosing to wrap the error. And in that last
case, it can make it less obvious that there is an unwrapped error being
propagated up the call stack.

This in practice has a very similar effect to disabling trailing commas;
while it is not necessarily wrong as a style choice, I don't believe it
warrants a position as part of the default ruleset here.

See-also: https://github.com/golang/lint/issues/363
2023-06-26 09:43:19 -07:00
Stephen Brown II
a2701259fe
Update defaults.toml to sort rules (#844) 2023-06-26 09:41:58 -07:00
Johan Walles
aea6254fca
Update default rule set to match recommendations (#799)
Before this change, Revive's defaults did not match the recommended
configuration:

https://github.com/mgechev/revive#recommended-configuration

With this change in place, Revive now defaults to following its own
recommendations.
2023-03-14 16:17:36 -07:00
mgechev
90f51530cc
Add white & black lists for var-naming
This PR introduces a white & black lists of initialisms for the
`var-naming` rule.

Now the rule can be configured with:

```toml
[rule.var-naming]
  arguments = [["ID"], ["VM", "BAR"]]
```

This way, the linter will ignore `customId` but will throw on `customVm` or `customBar`.

Fix #41
2018-09-15 15:05:31 -07:00
mgechev
a6c7415c67
Update documentation for generated files
Related to #4
2018-06-01 10:30:40 -07:00
mgechev
6c9ea8cf2d
Refactoring and renaming 2018-05-26 21:28:31 -07:00
mgechev
31b194f9bf Update the error code handling 2018-02-03 19:33:14 -08:00
mgechev
deb72d6238 Add default formatter 2018-01-27 17:01:18 -08:00