Description
Important
This is a proposal: I don't know if it is possible and what the impact could be inside the code.
The proposal may evolve.
The current configuration:
issues:
exclude-use-default: true
include:
- EXC0001
- EXC0002
- EXC0003
- EXC0004
⛑️ Problems
Useful vs Good Practice
I agree with Denis: most projects don't add docs and don't want to add docs.
#456 (comment)
But I also agree that is not a good practice.
#456 (comment)
The Names of the Embed Exclusions
The codes of the default exclusions are machine-oriented but we are humans.
- EXC0001: (errcheck) std error handling (ex:
os.Close
) - EXC0002: (golint) comment
- EXC0003: (golint) func name will be used as test.Test.* by other packages
- EXC0004: (govet) possible misuse of unsafe.Pointer|should have signature
- EXC0005: (staticcheck/SA4011) C-style with an explicit 'break' in a 'switch'
- EXC0006: (gosec/G103) Use of unsafe calls should be audited
- EXC0007: (gosec/G204) Subprocess launched with variable
- EXC0008: (gosec/G104) Duplicated errcheck checks.
- EXC0009: (gosec/G301|G302|G307) (G301|G302|G307): Expect (directory permissions to be 0750|file permissions to be 0600) or less
- EXC0010: (gosec/G304) False positive is triggered by 'src, err := ioutil.ReadFile(filename)'.
- EXC0011: (stylecheck/ST1000|ST1020|ST1021|ST1022) comments
- EXC0012: (revive) comments
- EXC0013: (revive) comments
- EXC0014: (revive) comments
- EXC0015: (revive) comments
Include?
I think that only a few people are understanding how the current configuration works.
For example, what those configurations are doing?
linters:
disable-all: true
enable:
- revive
issues:
exclude-use-default: true # <-- the difference is here
include:
- EXC0012 # related to revive and comments
- EXC0013 # related to revive and comments
- EXC0014 # related to revive and comments
- EXC0015 # related to revive and comments
linters:
disable-all: true
enable:
- revive
issues:
exclude-use-default: false # <-- the difference is here
include:
- EXC0012 # related to revive and comments
- EXC0013 # related to revive and comments
- EXC0014 # related to revive and comments
- EXC0015 # related to revive and comments
answers
The first configuration enables all the default exclusions but disables EXC0012, EXC0013, etc.
The second configuration disables all the default exclusions and that's all.
The include
section is ignored because this is only a filter on default exclusions.
Existing Issues
- Cannot change settings disabled by default in staticcheck and stylecheck to enabled #5043 (EXC0011) -> about comments
- detects whether declarations of exported variables, constants, functions, etc. have comments. #4828 (EXC0012, EXC0013, EXC0014, EXC0015) -> about comments
- errcheck does not work on Close #4262 (EXC0001) -> about std error handling
- Revive linters "exported" and "package-comments" do not work #3987 (EXC0012, EXC0013, EXC0014, EXC0015) -> about comments
- ignores unhandled errors of methods #3976 (EXC0001) -> about std error handling
- unsafeptr analyzer of govet is not reporting errors #3820 (EXC004) -> about govet rule
- Unable to detect exported codes, such as function and struct. #2827 (EXC0012, EXC0013, EXC0014, EXC0015) -> about comments
- Remove --exclude-use-default, default to false, or trim it WAY down #2239 (Ask to remove default exclusions)
- Stylecheck does not respect checks set in settings #2162 (EXC0011) -> about comments
- staticchecks errors are not reported #2049 (EXC0011) -> about comments
- revive: exported rule does not work #1937 (EXC0012, EXC0013, EXC0014, EXC0015) -> about comments
- golangci-lint does not return errors #1753 (EXC0002) -> about comments
- DefaultExcludePatterns should only be used for specified linter #1474 (side effect on plugin reports)
- golangci-lint run does not report issues. #1051 (EXC0002) -> about comments
- Error checking when the client is closed is not captured #609 (EXC0001) -> about std error handling
- please reconsider ignoring missing doc comments #456 (EXC0012, EXC0013, EXC0014, EXC0015) -> about comments
💭 The Proposal
- No default exclusions
- Removes (deprecates)
exclude-use-default
- Groups exclusions by topic with human-oriented names:
comments
-> EXC0011, EXC0012, EXC0013, EXC0014, EXC0015stdErrorHandling
-> EXC0001commonFalsePositives
-> EXC0006, EXC0007, EXC0010
- Removes (deprecates) useless exclusions:
- related to
golint
: EXC0002 (comments), EXC0003
- related to
- Removes (deprecates) "too specific" exclusions:
- EXC0005, EXC0008, EXC0009, EXC0010
- EXC0004?
# ...
exclusions:
default: # presets?
- comments
- stdErrorHandling
- commonFalsePositives