Skip to content

[plan] Enable new v2 linters: modernize, gocritic, and gosec #7379

@github-actions

Description

@github-actions

Objective

Enable valuable new linters that are available in golangci-lint v2 to improve code quality and catch more issues.

Context

golangci-lint v2 includes several new linters that can help improve the codebase. This task enables the most valuable ones without being overly noisy.

Approach

  1. Add new linters to .golangci.yml configuration
  2. Run linters locally to see what issues are found
  3. Fix any critical issues found
  4. Add appropriate exclusions for false positives if needed
  5. Document why each linter is enabled

Linters to Enable

linters:
  enable:
    # Existing linters...
    - modernize      # Modern Go patterns (NEW in v2.6.0)
    - gocritic       # Comprehensive opinionated linter
    - gosec          # Security-focused (already in tools.go)
    - godot          # Comment punctuation
    - unconvert      # Remove unnecessary conversions

Files to Modify

  • .golangci.yml - Add linters to enable list
  • Source code files - Fix any issues found by new linters (as needed)

Testing Commands

# Test new linters locally
golangci-lint run --enable=modernize,gocritic,gosec,godot,unconvert

# Run full linting suite
make golint

# Check specific linter output
golangci-lint run --enable=modernize

Acceptance Criteria

  • New linters are enabled in .golangci.yml
  • make golint runs successfully
  • Critical issues found by new linters are fixed
  • Appropriate exclusions added for false positives
  • CI passes with new linters enabled
  • No excessive noise from new linters

Expected Issues

New linters may find:

  • Opportunities for modern Go patterns (modernize)
  • Code style improvements (gocritic)
  • Security vulnerabilities (gosec)
  • Missing comment punctuation (godot)
  • Unnecessary type conversions (unconvert)

Notes

Start with just these 5 linters. Additional linters can be enabled in future iterations based on value vs. noise ratio.
Related to #7375

AI generated by Plan Command for discussion #7356

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions