1
0
mirror of https://github.com/mgechev/revive.git synced 2024-12-10 10:40:23 +02:00
Commit Graph

861 Commits

Author SHA1 Message Date
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
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
chavacava
6fd2c76c7d
fix issue #520 (#802) 2023-03-14 16:16:12 -07:00
cce
d7bedbd946
add golint's package name MixedCaps rule as in 83fdc39ff7/lint.go (L561-L563) (#797) 2023-02-27 19:56:30 +01:00
renovate[bot]
e8d5df7741
fix(deps): update github.com/chavacava/garif digest to b8c73b2 (#798)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-27 19:50:35 +01:00
Edouard Choinière
cab1184197
Add tags to docker images built by GoReleaser (#794)
fixes Missing tag "latest" on container images uploaded to ghcr.io #786
2023-02-23 12:04:22 +01:00
chavacava
10d4f5fb1c
fix issue #792 (#793) 2023-02-18 10:57:06 +01:00
Vito (Victor Gama)
b2bc00bd75
refactor: Reduce package-comments output scope (#791)
This reduces the amount of lines reported by package-comments by only
reporting the `package XXXXXXX' line, instead of the whole file.
2023-02-17 21:39:51 +01:00
Felipe David
8c2cd33315
fixing comment spacings (#789)
* fixing comments spacing

* Updating comment spacing test cases

* adds test cases for multiline comments

---------

Co-authored-by: chavacava <salvadorcavadini+github@gmail.com>
2023-02-17 21:03:11 +01:00
renovate[bot]
4981346ff9
fix(deps): update module golang.org/x/tools to v0.6.0 (#785)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-14 09:10:15 -08:00
chavacava
a4f4632a3f
fix #781 (#782) 2023-01-26 13:50:35 -08:00
renovate[bot]
54ee9dbcde
fix(deps): update module github.com/fatih/color to v1.14.1 (#783)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-26 13:50:20 -08:00
renovate[bot]
cb6823a888
fix(deps): update module golang.org/x/tools to v0.5.0 (#780)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-09 14:57:01 -08:00