Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to run all the linters present #2337

Closed
el10savio opened this issue Nov 2, 2021 · 3 comments
Closed

Ability to run all the linters present #2337

el10savio opened this issue Nov 2, 2021 · 3 comments
Labels
question Further information is requested

Comments

@el10savio
Copy link

el10savio commented Nov 2, 2021

Your feature request related to a problem? Please describe.

When running golanglintci with an exhaustive linter check it becomes tedious to specify all the linters with the -E/--enable flag as the linters need to be hardcoded and need to get updated when a new linter gets added.

Describe the solution you'd like.

An -A/-all flag or -E/--enable without any linter arguments passed to include all of them.

Describe alternatives you've considered.

Trying with the -fast flag does help, but at times when the CI run time is not a problem. It is better to have this functionality to include all the linters.

Additional context.

No response

@el10savio el10savio added the enhancement New feature or improvement label Nov 2, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Nov 2, 2021

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez
Copy link
Member

ldez commented Nov 2, 2021

Hello, the option already exists it's --enable-all

@ldez ldez closed this as completed Nov 2, 2021
@ldez ldez added question Further information is requested and removed enhancement New feature or improvement labels Nov 2, 2021
@el10savio
Copy link
Author

el10savio commented Nov 2, 2021

Thanks a lot for the quick reply!

It does look like the flag isnt present in neither the CLI documentation (it's present for the config documentation) nor when running the -h CLI command for v1.42.1 added below. Looks like a documentation issue.

Run the linters

Usage:
  golangci-lint run [flags]

Flags:
      --out-format string              Format of output: colored-line-number|line-number|json|tab|checkstyle|code-climate|html|junit-xml|github-actions (default "colored-line-number")
      --print-issued-lines             Print lines of code with issue (default true)
      --print-linter-name              Print linter name in issue line (default true)
      --uniq-by-line                   Make issues output unique by line (default true)
      --sort-results                   Sort linter results
      --path-prefix string             Path prefix to add to output
      --modules-download-mode string   Modules download mode. If not empty, passed as -mod=<mode> to go tools
      --issues-exit-code int           Exit code when issues were found (default 1)
      --build-tags strings             Build tags
      --timeout duration               Timeout for total work (default 1m0s)
      --tests                          Analyze tests (*_test.go) (default true)
      --print-resources-usage          Print avg and max memory usage of golangci-lint and total time
  -c, --config PATH                    Read config from file path PATH
      --no-config                      Don't read config
      --skip-dirs strings              Regexps of directories to skip
      --skip-dirs-use-default          Use or not use default excluded directories:
                                         - (^|/)vendor($|/)
                                         - (^|/)third_party($|/)
                                         - (^|/)testdata($|/)
                                         - (^|/)examples($|/)
                                         - (^|/)Godeps($|/)
                                         - (^|/)builtin($|/)
                                        (default true)
      --skip-files strings             Regexps of files to skip
      --allow-parallel-runners         Allow multiple parallel golangci-lint instances running. If false (default) - golangci-lint acquires file lock on start.
      --allow-serial-runners           Allow multiple golangci-lint instances running, but serialize them	around a lock. If false (default) - golangci-lint exits with an error if it fails to acquire file lock on start.
  -E, --enable strings                 Enable specific linter
  -D, --disable strings                Disable specific linter
      --disable-all                    Disable all linters
  -p, --presets strings                Enable presets (bugs|comment|complexity|error|format|import|metalinter|module|performance|sql|style|test|unused) of linters. Run 'golangci-lint linters' to see them. This option implies option --disable-all
      --fast                           Run only fast linters from enabled linters set (first run won't be fast)
  -e, --exclude strings                Exclude issue by regexp
      --exclude-use-default            Use or not use default excludes:
                                         # EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
                                         - Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
                                       
                                         # EXC0002 golint: Annoying issue about not having a comment. The rare codebase has such comments
                                         - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
                                       
                                         # EXC0003 golint: False positive when tests are defined in package 'test'
                                         - func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
                                       
                                         # EXC0004 govet: Common false positives
                                         - (possible misuse of unsafe.Pointer|should have signature)
                                       
                                         # EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
                                         - ineffective break statement. Did you mean to break out of the outer loop
                                       
                                         # EXC0006 gosec: Too many false-positives on 'unsafe' usage
                                         - Use of unsafe calls should be audited
                                       
                                         # EXC0007 gosec: Too many false-positives for parametrized shell calls
                                         - Subprocess launch(ed with variable|ing should be audited)
                                       
                                         # EXC0008 gosec: Duplicated errcheck checks
                                         - (G104|G307)
                                       
                                         # EXC0009 gosec: Too many issues in popular repos
                                         - (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
                                       
                                         # EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
                                         - Potential file inclusion via variable
                                       
                                         # EXC0011 stylecheck: Annoying issue about not having a comment. The rare codebase has such comments
                                         - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
                                       
                                         # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments
                                         - exported (.+) should have comment( \(or a comment on this block\))? or be unexported
                                       
                                         # EXC0013 revive: Annoying issue about not having a comment. The rare codebase has such comments
                                         - package comment should be of the form "(.+)...
                                       
                                         # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments
                                         - comment on exported (.+) should be of the form "(.+)..."
                                       
                                         # EXC0015 revive: Annoying issue about not having a comment. The rare codebase has such comments
                                         - should have a package comment, unless it's in another file for this package
                                        (default true)
      --exclude-case-sensitive         If set to true exclude and exclude rules regular expressions are case sensitive
      --max-issues-per-linter int      Maximum issues count per one linter. Set to 0 to disable (default 50)
      --max-same-issues int            Maximum count of issues with the same text. Set to 0 to disable (default 3)
  -n, --new                            Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.
                                       It's a super-useful option for integration of golangci-lint into existing large codebase.
                                       It's not practical to fix all existing issues at the moment of integration: much better to not allow issues in new code.
                                       For CI setups, prefer --new-from-rev=HEAD~, as --new can skip linting the current patch if any scripts generate unstaged files before golangci-lint runs.
      --new-from-rev REV               Show only new issues created after git revision REV
      --new-from-patch PATH            Show only new issues created in git patch with file path PATH
      --fix                            Fix found issues (if it's supported by the linter)
  -h, --help                           help for run

Global Flags:
      --color string              Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
  -j, --concurrency int           Concurrency (default NumCPU) (default 4)
      --cpu-profile-path string   Path to CPU profile output file
      --mem-profile-path string   Path to memory profile output file
      --trace-path string         Path to trace output file
  -v, --verbose                   verbose output
      --version                   Print version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants