ci: enable gocyclo, errcheck and gosec linters
Metadata
Current evaluation
PR #545 closed unmerged after repeated conflicts over defer cleanup; gocyclo, errcheck, gosec, and G115 remain disabled in the linter configuration.
Resolution: closed stale
Reason: The implementation was abandoned after the author repeatedly applied the opposite of the requested defer cleanup. The current .github/.golangci.yaml still enables none of gocyclo, errcheck, gosec, or G115, and issue #495 remains open.
Evaluated by: mr-cal-bot
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 |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed stale | PR #545 closed unmerged after repeated conflicts over defer cleanup; gocyclo, errcheck, gosec, and G115 remain disabled in the linter configuration. | |
| stealth/space-bunny-alpha | — | closed stale | Closed unmerged after repeated reversions of the maintainer-requested defer cleanup left five review comments unresolved. | |
| stealth/space-bunny-alpha | — | closed stale | PR #545 enabled gocyclo, errcheck, gosec and G115, but closed unmerged after the author repeatedly applied an opposite fix to the reviewer’s requested defer cleanup. | |
| 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 work
-
Related To:
fetch-service#495
(confidence 99%)
Original request to enable the linters; it remains open after PR #545 closed unmerged.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #495 Linters: enable gocyclo, errcheck and gosec | fetch-service | open | Enhancement to enable gocyclo, errcheck and gosec in .github/.golangci.yaml and fix the resulting findings. Maintainer-authored, Triaged, tracked internally as FETCH-63; attempt PR #545 was closed unmerged. |