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

11 Commits

Author SHA1 Message Date
Marcin Federowicz
501cc4a675
feat: ignore vendor if no exclude set (#1058) 2024-10-17 15:25:24 -07:00
Oleksandr Redko
59131927d3
Move away from deprecated github.com/pkg/errors (#1039) 2024-09-16 09:40:46 +02:00
Marcin Federowicz
25ae73a67a
fix:ignore color marks when compare stings in test (#926) 2023-10-29 07:43:52 +01:00
Marcin Federowicz
70ceb1cbfb
cleanup: removes or names unused parameters and receivers to _ (#907) 2023-09-24 08:55:14 +02:00
chavacava
5ccebe86c2
Code cleaunp (#905)
* fix minor lint issue

* fix package comments

* fix comments

* removes extra empty lines

* fix import alias name
2023-09-23 10:41:34 +02:00
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
Minko Gechev
6d5bc51b50
Move away from deprecated ioutils (#825)
Fix #806
2023-05-16 08:06:52 +02:00
Oleksandr Redko
022236f9e4 fix: error message typo in revivelib.New 2023-05-01 10:47:21 +02:00
chavacava
dc6909b49f
fix tests not passing after the modif of the default rules list (#817) 2023-05-01 10:30:48 +02:00
chavacava
04728cf0de
Lint cleanup (#679) 2022-04-10 11:55:13 +02:00
Bernardo Heynemann
318db94210
Separating lib from cli (#655)
* Separating lib from cli

* Renamed NewRevive to New

* Added GetLintFailures helper function

* Moved formatter to call to format since that's when it's needed

* makes fields of Revive struct non-public

* minor modifs in tests: remove unnamed constats

* Added lint package management to lint command

* README message for using revive as a library

* README formatting

* Removed unused method

* Slightly improved wording in README

* Handling format errors

* Renaming file to better reflect intent

* Refactoring pattern usage

* README heads

* renames excludePaths into excludePatterns

Co-authored-by: Bernardo Heynemann <bernardo.heynemann@coinbase.com>
Co-authored-by: chavacava <salvadorcavadini+github@gmail.com>
2022-03-29 17:31:52 +02:00