← Back to issue list

ci: enable gocyclo, errcheck and gosec linters

View original Github issue

Metadata

Project
fetch-service
Number
#545
Type
pull request
State
closed
Author
Copilot
Labels
Created
Updated
Closed

Current evaluation

Enabling gocyclo, errcheck, and gosec linters closed without merging. CI passed, but a reviewer requested reverting specific defer patterns. Misunderstood feedback left changes unresolved, resulting in closure.

Suggested action:

No scores available.

Issue body

- [x] Install golangci-lint v2 - [x] Generate version.txt file needed for build - [x] Analyze current errors from gocyclo, errcheck, and gosec linters - [x] Enable gocyclo, errcheck, and gosec in golangci-lint configuration - [x] Configure linters with appropriate settings consistent with other projects - [x] Fix errcheck errors (182 issues - unchecked error returns) - [x] Fix gosec errors (excluded reasonable false positives via configuration) - [x] Run full linting suite to verify all changes - 0 issues remaining - [x] Address code review feedback - fix error handling in test mocks - [x] Fix mock functions to not defer close before returning file handle - [x] Verify build succeeds - [x] CodeQL security scan - no vulnerabilities found - [x] Final code review - all issues addressed - [x] Add individual make targets for gocyclo, errcheck and gosec - [x] Make lint target depend on the three new lint targets - [x] Simplify net.Conn Close handling by excluding from errcheck - [x] Enable G115 linting with proper overflow checks ## Summary All three linters (gocyclo, errcheck, gosec) are now enabled and passing with 0 issues. ### Latest improvements: - Enabled G115 (integer overflow) linting as requested - Added proper overflow checking before all type conversions - Bounds validation for int -> uint32 conversions in tests - Overflow checks for uint64 -> int64 conversions - Safe timeout calculations with overflow protection - All conversions documented with #nosec comments explaining safety The code now has comprehensive integer overflow protection while maintaining readability. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Linters: enable gocyclo, errcheck and gosec</issue_title> > <issue_description>### What needs to get done > > Enable gocyclo, errcheck and gosec in the the golangci-lint configuration. > Tune the configuration to be consistent with other projects. > Solve returnes errors. > > ### Why it needs to get done > > These linters currently return many errors but are part of the "reasonable" set of linters we want to enable.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes canonical/fetch-service#495 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 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](https://gh.io/copilot-coding-agent-tips) in the docs.

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Enabling gocyclo, errcheck, and gosec linters closed without merging. CI passed, but a reviewer requested reverting specific defer patterns. Misunderstood feedback left changes unresolved, resulting in closure.

Update history

Date Change
created

Related issues

Issue Project State Summary Similarity
#495 Linters: enable gocyclo, errcheck and gosec fetch-service open Enable gocyclo, errcheck, and gosec linters in golangci-lint config and fix resulting errors. Triaged but inactive for ~9 months.
78%