Skip to content

Fix golangci-lint errors and enforce lint in CI#759

Open
aravindtga wants to merge 3 commits into
kptdev:mainfrom
Nordix:golangci-lint-errors-and-ci-gate
Open

Fix golangci-lint errors and enforce lint in CI#759
aravindtga wants to merge 3 commits into
kptdev:mainfrom
Nordix:golangci-lint-errors-and-ci-gate

Conversation

@aravindtga

@aravindtga aravindtga commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Description

  • What changed: Fixed all golangci-lint errors (errcheck, gosec, staticcheck) across go/fn and added || exit 1 to the lint-modules Makefile target so lint failures actually break CI.
  • Why it's needed: The lint target was silently swallowing failures - golangci-lint could fail without affecting the CI result. Additionally, several unchecked return values and a path traversal warning needed addressing.
  • How it works:
    • internal/docs/render.go: Explicitly discard fmt.Fprint/fmt.Fprintf return values with _, _ =
    • run.go: Same for fmt.Fprint calls; use filepath.FromSlash + //nolint:gosec for CLI-arg file reads
    • Test files: Use _ = for Close() calls, fmt.Fprintf instead of WriteString(fmt.Sprintf(...)), wrap os.RemoveAll in closure
    • go/Makefile: Add || exit 1 to lint-modules loop so lint failures propagate

Related Issue(s)

  • N/A

Type of Change

  • Bug fix
  • Enhancement

Checklist

  • Code follows project style guidelines
  • Self-reviewed changes
  • Tests added/updated
  • Documentation added/updated
  • All tests and gating checks pass

AI Disclosure

  • I have used AI in the creation of this PR.

If so, please describe how:
- Kiro to identify and fix all golangci-lint errors and the CI gating issue.

Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
@aravindtga aravindtga force-pushed the golangci-lint-errors-and-ci-gate branch from b420db9 to 1d381f2 Compare June 11, 2026 13:44
@aravindtga aravindtga changed the title Enforce lint in CI Fix golangci-lint errors and enforce lint in CI Jun 11, 2026
@aravindtga aravindtga self-assigned this Jun 11, 2026
@aravindtga aravindtga marked this pull request as ready for review June 11, 2026 13:49
Copilot AI review requested due to automatic review settings June 11, 2026 13:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR primarily addresses lint-related error handling for I/O operations and introduces path sanitization when reading resources from files.

Changes:

  • Explicitly ignore or capture return values from Close()/Fprint()/Fprintf() to satisfy error-checking linters.
  • Use fmt.Fprintf in the property test generator to avoid fmt.Sprintf allocation.
  • Apply filepath.Clean before os.ReadFile in file-mode execution.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
go/fn/run_flags_test.go Updates test helpers to explicitly ignore Close() errors.
go/fn/run_filemode_property_test.go Uses fmt.Fprintf into a buffer and ignores RemoveAll error in defer.
go/fn/run.go Cleans file paths before reading; explicitly discards fmt.Fprint return values.
go/fn/internal/docs/render.go Explicitly discards fmt.Fprint/Fprintf return values during help rendering.
go/Makefile Ensures golangci-lint failures stop the lint-modules loop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread go/fn/run_flags_test.go Outdated
Comment thread go/fn/run_flags_test.go Outdated
Comment thread go/fn/run_flags_test.go Outdated
Comment thread go/fn/run_flags_test.go Outdated
Comment thread go/fn/run_flags_test.go Outdated
Comment thread go/fn/run.go Outdated
Comment thread go/fn/internal/docs/render.go Outdated
Comment thread go/fn/internal/docs/render.go Outdated
Comment thread go/fn/internal/docs/render.go Outdated
Comment thread go/fn/internal/docs/render.go Outdated
@aravindtga aravindtga requested a review from Copilot June 11, 2026 14:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Comment thread go/fn/internal/docs/render_test.go
Comment thread go/fn/run_flags_test.go
Comment thread go/fn/run_filemode_property_test.go Outdated
Comment thread go/fn/run.go
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
@aravindtga aravindtga force-pushed the golangci-lint-errors-and-ci-gate branch from a01fa97 to 6397b63 Compare June 11, 2026 14:18
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
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.

2 participants