Skip to content

Adopt linters from Kubernetes #388

@nirs

Description

@nirs

Summary

Compare linters used by Kubernetes with this project and adopt useful ones.

Sources

Current comparison

Linters used by both projects

Linter Purpose
gocritic Code style and common mistakes
staticcheck Static analysis (150+ checks)
misspell Spelling errors

Linters used only by Kubernetes

Linter Purpose Recommendation
govet Go vet checks Add - catches real bugs, should always be enabled
ineffassign Useless assignments Add - catches dead code
unused Dead code detection Add - finds unused code
revive Modern golint replacement Add - more comprehensive than gocritic alone
modernize Modern Go idioms Consider - helps keep code up to date
depguard Dependency restrictions Skip - only useful for large projects with dependency policies
forbidigo Forbidden API calls Skip - only useful for banning specific APIs
ginkgolinter Ginkgo test patterns Skip - project doesn't use Ginkgo
kubeapilinter K8s API conventions Skip - K8s-specific
logcheck Structured logging Skip - K8s-specific custom linter
sorted Sorted imports/declarations Skip - too opinionated
testifylint Testify usage Skip - project doesn't use testify

Linters used only by this project

Linter Purpose Recommendation
gosec Security checks Remove or reduce - K8s doesn't use it, high false positive rate
goconst Repeated constants Keep - low noise
nolintlint Check nolint directives Keep - ensures nolint comments are valid
unconvert Unnecessary type conversions Keep - low noise

Recommendations

Add these linters

enable:
  - govet       # Go vet checks, catches real bugs
  - ineffassign # Useless assignments
  - unused      # Dead code detection
  - revive      # Modern golint replacement

Consider removing

  • gosec - Kubernetes doesn't use it. High false positive rate for CLI tools. Already disabled G602, G703, and G705 for tools/. Consider removing entirely and relying on code review for security.

Keep as-is

  • goconst, gocritic, misspell, nolintlint, staticcheck, unconvert

Notes

Kubernetes relies on staticcheck, custom linters for their specific conventions, and code review for security rather than generic security linters like gosec.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions