feat(var-naming): restore golint behavior by default, backwards-compatible rename and invert skipPackageNameCollisionWithGoStd#1603
Open
chaimleib wants to merge 4 commits intomgechev:masterfrom
Conversation
… restore golint behavior by default fixes mgechev#1602
e071fa8 to
33aae86
Compare
Author
|
I marked these commits as "feat" instead of "fix" because the config flags have changed. In semver, I think this merits incrementing the minor version in major.minor.patch, rather than the patch version. |
37d1bfa to
33aae86
Compare
Author
|
Oops, the deprecation warning wasn't printing. I reverted that part, and I'm working on that in a separate branch based off of this. |
…ip-opt feat(var-naming): deprecate and gracefully translate skip option
Author
|
Now the deprecation works. Users will not see breakage with their configs if this gets merged, just a deprecation warning. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1602.
Motivation
As described in #1602, an empty config should result in behavior like golint, according to the RULES_DESCRIPTIONS.md for
var-naming:This contract broke between v1.12.0 and v1.13.0 when
skipPackageNameCollisionWithGoStdwas added in #1540.Changes
golint, skipping the check on package name collisions with the Go stdlibs.skipPackageNameCollisionWithGoStd, if provided, with a warning.slog.LevelWarnand above, even when not in DEBUG mode.slog.LevelDebugmessages were being suppressed, sinceslog.LevelDebug < 0, with 0 being the default and equal toslog.LevelInfo. Now DEBUG mode will emit debug-level messages.Testing
Makefile targets
make lint testpasses.Comparison with golint
Given the following folder structure:
And given the following content of
http.go:The original behavior of
golintgives no errors.The current
masterbranch ate174d6dgives an error:The modified
revivegives no errors.Enabling the check
Build the modified
revive.$ cd ../revive $ git switch fix/var-naming/1602-default-golint-behavior $ make buildMake the http dir like so:
http.gorevive.tomlAn error should appear when run.
Logging tests
All the below tests start from this basic state. Create a folder named
httplike so:http.gorevive.tomlBuild
revive:$ cd path/to/revive $ make buildNavigate to the
httpfolder:$ cd path/to/httpEmpty arguments
$ path/to/revive/revive . $ ls http.go revive.tomlNo errors, just like golint.
Debug mode, empty arguments
The command creates
revive.log. No errors, just INFOs.With deprecated skip option true
Edit
revive.toml:Expect no errors, just a deprecation warning.
With deprecated skip option false
Edit
revive.toml:Expect a deprecation warning and a lint error.
With new check option false
Edit
revive.toml:$ path/to/revive/revive .Expect no errors.