1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-21 17:16:40 +02:00
Commit Graph

1023 Commits

Author SHA1 Message Date
Denis Voytyuk
ca0678cd08
fix: dot-imports does not check test files (#884) 2023-08-30 08:06:58 +02:00
renovate[bot]
883c4cc199
fix(deps): update module github.com/chavacava/garif to v0.1.0 (#882)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-28 10:49:56 -07:00
Denis Voytyuk
f900b6c2d4
feat: add support for import-alias-naming rule (#881) 2023-08-28 15:26:00 +02:00
Oleksandr Redko
0357df7bc0
fix: add missing defer when unlocking mutex (#879) 2023-08-25 13:20:27 +02:00
mgechev
9a87e6fd82 Update goreleaser 2023-08-24 10:41:23 -07:00
Denis Voytyuk
a4ae369945
build: shift to the supported go versions (1.20 and 1.21) (#878) 2023-08-22 09:18:10 +02:00
Denis Voytyuk
4ee7542478
fix: false positive in import-shadowing for method names (#876) 2023-08-21 23:45:41 +02:00
chavacava
e758901c9a
Revert "fix: unnecesary alert for use-any when comments inside interface{} (#873)" (#874)
This reverts commit 519ffbdd7a.
2023-08-19 08:07:28 +02:00
chavacava
9acfcc8f86
fix #863:false positive on return statement in a func lit passed to the deferred function (#870) 2023-08-18 11:21:42 -07:00
Damián Ferencz
519ffbdd7a
fix: unnecesary alert for use-any when comments inside interface{} (#873)
* feat: add rule for unused import alias

* fix: rename rule

* fix: rename rule

* fix: use-any skip comments inside interface{}
2023-08-18 11:21:10 -07:00
Martins Irbe
19a95d9a7f
resolve #867: remove k[A-Z][A-Za-z\d]*$ sub-rule from var-naming (#871) 2023-08-16 13:23:29 +02:00
chavacava
16871ed55f
fix #864: confusing-naming FP on methods of generic types (#869) 2023-08-12 10:56:53 +02:00
chavacava
7cb4540a46
fix #846: time-equal garbled message when time returned from function (#868) 2023-08-12 09:05:46 +02:00
fregin
72f9108792
(var-naming) support private uppercase constants #865 (#866) 2023-08-12 08:45:42 +02:00
Fagim Sadykov
310d1d76e4
per-rule file exclude filters (#850) (#857) 2023-08-12 08:21:11 +02:00
renovate[bot]
b4fc3db692
fix(deps): update module golang.org/x/tools to v0.12.0 (#859) 2023-08-11 07:36:18 +02:00
Fagim Sadykov
b31eb18b1f
adds [allowRegex] parameter for unused-parameter and unused-receiver rules (#858) 2023-08-11 07:35:08 +02:00
Denis Voytyuk
4c84a170af
Allow import-blacklist to run against go test files (#862) 2023-08-09 22:37:50 +02:00
renovate[bot]
df39256ea7
fix(deps): update module golang.org/x/tools to v0.11.1 (#855)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-04 11:26:37 +02:00
Fagim Sadykov
8941d19026
imporve var-naming - add upperCaseConst option to allow UPPER_CASED constants #851 (#852)
* imporve `var-naming`  - add upperCaseConst  option to allow UPPER_CASED constants #851

Co-authored-by: chavacava <salvadorcavadini+github@gmail.com>
2023-07-31 09:09:38 +02:00
Damián Ferencz
7bd666898c
feat: add rule for redundant import alias (#854) 2023-07-31 08:22:40 +02:00
renovate[bot]
26bc59f58c
fix(deps): update github.com/chavacava/garif digest to 4bd63c2 (#838)
* fix(deps): update github.com/chavacava/garif digest to 4bd63c2

* fix garif level compatibility

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: chavacava <salvadorcavadini+github@gmail.com>
2023-07-29 11:45:34 +02:00
Ricardo Martin Marcucci
a155d92342
fix: support method call from structures for string-format (#840)
* fix: support method call from structures for string-format

* fix: added test for MR
2023-07-29 11:27:07 +02:00
renovate[bot]
6a2c5b132e
fix(deps): update module golang.org/x/tools to v0.11.0 (#848)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-05 15:32:27 -07:00
kerneltravel
95fcfe36f6
doc: add milvus to README usage (#845) (#847) 2023-07-05 08:12:42 +02:00
renovate[bot]
9564ad9f07
fix(deps): update module golang.org/x/tools to v0.10.0 (#841)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-26 09:43:34 -07: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
Stephen Brown II
a2701259fe
Update defaults.toml to sort rules (#844) 2023-06-26 09:41:58 -07:00
Onur Cinar
e5d5d09026
Adding Checker Go library to the list of Who Uses. (#842)
Proposing to add the Checker Go library to the list of Who Uses.
2023-06-22 08:56:53 +02:00
renovate[bot]
da1c99ded9
fix(deps): update module github.com/burntsushi/toml to v1.3.2 (#835)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-14 08:31:32 +02:00
renovate[bot]
5ef33f1406
fix(deps): update github.com/chavacava/garif digest to 8144c22 (#836)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-06 14:30:47 -07:00
renovate[bot]
7cfe9d8eaf
fix(deps): update module golang.org/x/tools to v0.9.3 (#837)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-06 14:30:28 -07:00
meanguy
ca38cc3655
Fix typo in example documentation for early-return (#834)
The example for configuring `early-return` arguments mistakenly refers to the `exported` rule.
2023-05-30 10:24:09 +02:00
Minko Gechev
68bf7e5f38
build: remove go 1.17.x from ci (#833) 2023-05-23 19:19:56 +02:00
Miles Delahunty
ae07914dc4
ifelse: option to preserve variable scope (#832)
* ifelse: option to preserve variable scope
2023-05-23 10:10:09 +02:00
chavacava
2a1838f501
adds default config to enable all rules work out of the box (#830)
* adds default config to enable all rules out of the box
2023-05-20 14:44:34 +02:00
renovate[bot]
9117f8e621
fix(deps): update github.com/chavacava/garif digest to 4752330 (#831)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-19 14:04:54 -07:00
Miles Delahunty
4bb48df5d2
refactor: extract shared code for linting if-else chains (#821)
* 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
2023-05-17 13:51:35 +02:00
chavacava
81d85b505d
fix #824 (#829) 2023-05-16 10:31:25 +02:00
Minko Gechev
ed6d9ce652
Fix prefix trimming in struct-tag (#827)
Fix #813
2023-05-16 08:09:20 +02:00
Minko Gechev
6d5bc51b50
Move away from deprecated ioutils (#825)
Fix #806
2023-05-16 08:06:52 +02:00
renovate[bot]
b508fa8d91
fix(deps): update module golang.org/x/tools to v0.9.1 (#811)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-15 13:57:23 +02:00
Florian Karuhtz
cd336fc457
Fix invalid toml in rule.add-constant example (#819) 2023-05-15 13:56:34 +02:00
Nate Finch
e20c7788f9
add nolint to default list of acceptable comments for comment-spacings (#822) 2023-05-09 16:20:58 +02:00
Oleksandr Redko
022236f9e4 fix: error message typo in revivelib.New 2023-05-01 10:47:21 +02:00
Mario Valderrama
55585666b7 Prevent empty-block when looping over call expr 2023-05-01 10:44:48 +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
Abhinav Gupta
b03e54f617
empty-block: Fix false positive on select {} (#805)
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
2023-03-16 13:39:52 -07:00
renovate[bot]
5db07b5c97
fix(deps): update module github.com/fatih/color to v1.15.0 (#803)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-14 16:18:06 -07:00
renovate[bot]
9a00c13773
fix(deps): update module golang.org/x/tools to v0.7.0 (#801)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-14 16:17:53 -07:00