1
0
mirror of https://github.com/mgechev/revive.git synced 2025-01-04 03:02:13 +02:00
Commit Graph

839 Commits

Author SHA1 Message Date
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
renovate[bot]
b4fd11aa64
fix(deps): update module golang.org/x/tools to v0.4.0 (#777)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-12-14 16:26:10 -08:00
Miles Delahunty
b87d391ee4
Fix early-return false positive and other tweaks (#776) 2022-11-27 13:23:51 +01:00
renovate[bot]
d5d9da17ec
fix(deps): update module golang.org/x/tools to v0.3.0 (#772)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-11-11 18:18:49 -08:00
Reza Nikoopour
ae282a54c8
fix off by one issue in line and colums (#773) 2022-11-11 07:47:58 +01:00
Buyanov Vladimir
7b1458a9cb
fix #754 [rule.unhandled-error] change arguments to regexp (#757)
* fix #754 [rule.unhandled-error] change arguments to regexp

* Update unhandled-error-w-ignorelist.go

* Update unhandled-error_test.go

* Update unhandled-error-w-ignorelist.go

* adds config backward compatibility test

* fix #754 [rule.unhandled-error] change arguments to regexp

* fix #754 [rule.unhandled-error] change arguments to regexp

* fix #754 [rule.unhandled-error] change arguments to regexp

Co-authored-by: chavacava <salvadorcavadini+github@gmail.com>
2022-11-09 13:13:52 +01:00
Shubh Karman Singh
5f26378cc2
Comment spacing rule (#761)
* added comment-spacing rule for revive

* added test for comment-spacings rule

* adds comment-spacings rule to the configuration

* renames the source file to match rule name

* adds some tests

* refactor Comment-Spacings Rule to remove whiteList and avoid Panic at empty comment

* refactoring and adds rule configuration

* adds rule documentation

Co-authored-by: chavacava <salvadorcavadini+github@gmail.com>
2022-10-29 19:32:42 +02:00
renovate[bot]
5fd3b2c046
fix(deps): update github.com/chavacava/garif digest to b3ef358 (#767)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-10-27 14:45:32 +01:00
chavacava
32a0cb8052
Allows inversing the semantics of string-format rule configurations (#765)
* allows negating the regexp

* updates rule documentation

* adds mgechev remarks
2022-10-24 20:48:41 +02:00
chavacava
06881a9f54
speedup branch comparison (#764) 2022-10-24 17:21:48 +02:00
renovate[bot]
55e881a792
fix(deps): update module github.com/burntsushi/toml to v1.2.1 (#766)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-10-24 17:13:42 +02:00
renovate[bot]
3fe5f99860
fix(deps): update module golang.org/x/tools to v0.2.0 (#763)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-10-21 15:38:35 +02:00
Buyanov Vladimir
1c3a15caaa
fix #759 [rule.add-constant] change 'ignoreFuncs' expressions in documentation and test (#760) 2022-10-15 11:24:32 +02:00
Buyanov Vladimir
3d83403fb8
fix #751 [rule.add-constant] add ignoreFuncs to exclude constants in … (#756)
* fix #751 [rule.add-constant] add ignoreFuncs to exclude constants in functions

* Update add-constant.go

* Update add-constant.go

* fix #751 [rule.add-constant] add ignoreFuncs to exclude constants in functions

* add details to regex-related errors

Co-authored-by: chavacava <salvadorcavadini+github@gmail.com>
2022-10-13 13:23:23 +02:00
Tom
5cc9e27ddb
docs(README): add missing links and fix a broken one (#758) 2022-10-11 21:32:14 -07:00
Hsing-Yu (David) Chen
b4201ff650
Fix broken link of 'Comment Directives' in README (#753) 2022-10-06 11:05:23 +02:00
Attila Fabian
ec731c068d
go get reference updates (#750) 2022-10-04 10:26:40 +02:00
chavacava
3116818e59
fix bug #736 (#745) 2022-09-10 09:08:17 +02:00
chavacava
7c2ebbda24
fix #744 (#746) 2022-09-05 11:11:45 +02:00
chavacava
553604eace
fix bug #739: empty-lines false positive (#742) 2022-08-27 13:18:17 +02:00
Rafael Madriz
a4add4a769
docs(README): Add neovim support in text editors section (#734)
* add instructions for using revive from neovim
2022-08-20 06:58:47 +02:00
ccoVeille
fa350e6eb8
fix some typos in repository (#728) 2022-08-08 13:48:59 +02:00
ccoVeille
160dfbd4ad
fix documentation (#730)
An entry was missing since banned-characters was added

Closes #729
2022-08-08 13:21:09 +02:00