Skip to content

Enable v2 linters: modernize, gocritic, gosec, unconvert#7447

Merged
pelikhan merged 4 commits intomainfrom
copilot/enable-new-linters-v2
Dec 23, 2025
Merged

Enable v2 linters: modernize, gocritic, gosec, unconvert#7447
pelikhan merged 4 commits intomainfrom
copilot/enable-new-linters-v2

Conversation

Copy link
Contributor

Copilot AI commented Dec 23, 2025

Enables 4 new golangci-lint v2 linters to improve code quality and security analysis. All issues addressed through configuration exclusions and minimal comment formatting fixes.

Linters Enabled

  • modernize - Modern Go patterns (Go 1.21+ features excluded for compatibility)
  • gocritic - Opinionated code quality checks (8 noisy checks disabled)
  • gosec - Security vulnerability detection (false positives excluded)
  • unconvert - Unnecessary type conversions

Note: godot linter evaluated but not enabled - too pedantic with 100+ trivial issues.

Configuration Approach

gocritic exclusions (8 disabled checks):

disabled-checks:
  - appendAssign     # Appending to different variable is intentional
  - elseif           # else-if pattern is acceptable
  - unlambda         # Explicit lambdas can be clearer

modernize exclusions (12 Go 1.21+ features):

rules:
  - text: "rangeint|slicescontains|stringscutprefix"  # Requires Go 1.21+
  - text: "stringsseq"                                 # Requires Go 1.23+

gosec exclusions (15 path-based rules):

rules:
  - text: "G204"              # Allow exec.Command in controlled contexts
    path: pkg/awmg/gateway\.go
  - text: "G101|G602|G115"    # False positives

Code Changes

Minimal comment formatting in 14 files - added periods to public function/type comments for consistency. No functional changes.

Validation

  • make golint passes with 0 issues
  • 210 lines of documented exclusion rules in .golangci.yml
Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Enable new v2 linters: modernize, gocritic, and gosec</issue_title>
<issue_description>## 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

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 23, 2025 22:09
…vert)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Enable new v2 linters for code quality improvement Enable v2 linters: modernize, gocritic, gosec, unconvert Dec 23, 2025
Copilot AI requested a review from pelikhan December 23, 2025 22:37
@pelikhan pelikhan marked this pull request as ready for review December 23, 2025 22:59
@pelikhan pelikhan merged commit ab39950 into main Dec 23, 2025
123 checks passed
@pelikhan pelikhan deleted the copilot/enable-new-linters-v2 branch December 23, 2025 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants