Skip to content

🌟 Let's talk about default exclusions #5298

Closed
@ldez

Description

@ldez

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

💭 The Proposal

  • No default exclusions
  • Removes (deprecates) exclude-use-default
  • Groups exclusions by topic with human-oriented names:
    • comments -> EXC0011, EXC0012, EXC0013, EXC0014, EXC0015
    • stdErrorHandling -> EXC0001
    • commonFalsePositives -> EXC0006, EXC0007, EXC0010
  • Removes (deprecates) useless exclusions:
    • related to golint: EXC0002 (comments), EXC0003
  • Removes (deprecates) "too specific" exclusions:
    • EXC0005, EXC0008, EXC0009, EXC0010
  • EXC0004?
# ...
  exclusions:
    default: # presets?
      - comments
      - stdErrorHandling
      - commonFalsePositives

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions