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

dev: remove unrelated flags from config and linters command #4284

Merged
merged 3 commits into from
Feb 3, 2024

Conversation

mateusoliveira43
Copy link
Contributor

config and linters command would present all flags from run command to users. This PR removes unnecessary flags from those commands.

@ldez ldez changed the title fix: Remove unrelated flags from config and linters command dev: remove unrelated flags from config and linters command Dec 23, 2023
@ldez ldez added the topic: cosmetic changes contain cosmetic improvements label Dec 23, 2023
@ldez ldez self-requested a review December 23, 2023 18:38
@ldez ldez added the blocked Need's direct action from maintainer label Dec 23, 2023
@mateusoliveira43
Copy link
Contributor Author

@ldez would like to merge this one to work on others ideas that touch same part of code (to avoid rebases later). There is anything I can do to get this one merged?

@ldez
Copy link
Member

ldez commented Feb 2, 2024

Diff of the help commands to help the review:

go run ./cmd/golangci-lint --help
diff
10c10
<   config      Config
---
>   config      Config file information

go run ./cmd/golangci-lint cache --help
diff

go run ./cmd/golangci-lint completion --help
diff

go run ./cmd/golangci-lint config --help
diff
1c1
< Config
---
> Config file information

go run ./cmd/golangci-lint help --help
diff

go run ./cmd/golangci-lint linters --help
diff
7,99c7,15
<       --out-format string              Format of output: colored-line-number|line-number|json|tab|checkstyle|code-climate|html|junit-xml|github-actions|teamcity (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)
<       --go string                      Targeted Go version
<       --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.
<       --show-stats                     Show statistics per linter
<   -E, --enable strings                 Enable specific linter
<   -D, --disable strings                Disable specific linter
<       --enable-all                     Enable all linters
<       --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 help 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)
<                                        
<                                          # 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
<                                         (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
<       --whole-files                    Show issues in any part of update files (requires new-from-rev or new-from-patch)
<       --fix                            Fix found issues (if it's supported by the linter)
<   -h, --help                           help for linters
---
>   -c, --config PATH       Read config from file path PATH
>       --no-config         Don't read config file
>   -D, --disable strings   Disable specific linter
>       --disable-all       Disable all linters
>   -E, --enable strings    Enable specific linter
>       --enable-all        Enable all linters
>       --fast              Enable only fast linters from enabled linters set (first run won't be fast)
>   -p, --presets strings   Enable presets (bugs|comment|complexity|error|format|import|metalinter|module|performance|sql|style|test|unused) of linters. Run 'golangci-lint help linters' to see them. This option implies option --disable-all
>   -h, --help              help for linters

go run ./cmd/golangci-lint run --help
diff
6a7,8
>   -c, --config PATH                    Read config from file path PATH
>       --no-config                      Don't read config file
20,21d21
<   -c, --config PATH                    Read config from file path PATH
<       --no-config                      Don't read config
35d34
<   -E, --enable strings                 Enable specific linter
37d35
<       --enable-all                     Enable all linters
38a37,39
>   -E, --enable strings                 Enable specific linter
>       --enable-all                     Enable all linters
>       --fast                           Enable only fast linters from enabled linters set (first run won't be fast)
40d40
<       --fast                           Run only fast linters from enabled linters set (first run won't be fast)

go run ./cmd/golangci-lint version --help
diff

@ldez
Copy link
Member

ldez commented Feb 2, 2024

The PR contains some unrelated changes and introduces some opinionated ways to handle flags.

The unrelated changes (like the messages related to the list of linters) are "minor" (and partially wrong, I fixed them) but this should be avoided.

Some flags (ex: --internal-cmd-test) have been designed to be used across commands but this PR changed that, for now, we can accept that because it's only used for the run command but this can increase maintenance work in the future.

@ldez ldez added area: CLI Related to CLI and removed blocked Need's direct action from maintainer labels Feb 2, 2024
@ldez ldez force-pushed the fix/only-related-flags branch 2 times, most recently from 84bd215 to 3bb4f79 Compare February 2, 2024 21:13
mateusoliveira43 and others added 3 commits February 3, 2024 17:29
Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
@ldez ldez merged commit a727aa5 into golangci:master Feb 3, 2024
12 checks passed
Antonboom pushed a commit to Antonboom/golangci-lint that referenced this pull request Mar 3, 2024
…#4284)

Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
@ldez ldez modified the milestone: v1.56 Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: CLI Related to CLI topic: cosmetic changes contain cosmetic improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants