Skip to content

linter: unused-parameter - #832

Merged
mzihlmann merged 1 commit into
mainfrom
lint-unused-param
Jul 14, 2026
Merged

linter: unused-parameter#832
mzihlmann merged 1 commit into
mainfrom
lint-unused-param

Conversation

@mzihlmann

@mzihlmann mzihlmann commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Carves the unused-parameter cleanup out of #539. Unused named function parameters are renamed to _ (e.g. the cobra Run: func(_ *cobra.Command, _ []string) handlers), as flagged by revive's unused-parameter rule. Purely mechanical and behaviour-preserving. The rule itself is not enabled in the config here, that stays in #539, so this is a code cleanup with no CI change.

Summary by CodeRabbit

  • Refactor

    • Clarified unused callback and method parameters across command execution, image handling, filesystem utilities, and credential operations.
    • Preserved existing command, caching, snapshot, archive, and transport behavior.
  • Tests

    • Updated test doubles and callbacks to accurately indicate ignored inputs.
    • Existing assertions, mocked results, and test behavior remain unchanged.

@mzihlmann
mzihlmann requested review from 0hlov3, BobDu, babs and nejch June 26, 2026 10:02
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/creds/env_keychain.go 0.00% 2 Missing ⚠️
cmd/executor/cmd/version.go 0.00% 1 Missing ⚠️
pkg/commands/copy.go 0.00% 0 Missing and 1 partial ⚠️
pkg/dockerfile/dockerfile.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@mzihlmann mzihlmann added standardization Aligning behavior with Docker/BuildKit/OCI linter Pull requests that improve linting or code cleanup easy-review Mechanical or self-contained change needing little domain reasoning to approve and removed standardization Aligning behavior with Docker/BuildKit/OCI labels Jul 7, 2026
@osscontainertools osscontainertools deleted a comment from coderabbitai Bot Jul 13, 2026
@osscontainertools osscontainertools deleted a comment from coderabbitai Bot Jul 13, 2026
@mzihlmann

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change replaces unused Go callback and method parameters with blank identifiers across CLI, command, filesystem, credential, production, and test code. Filesystem ignore-list and internal copy handling also change in pkg/util/fs_util.go.

Changes

Parameter cleanup and filesystem utilities

Layer / File(s) Summary
Production callback and command signatures
cmd/executor/cmd/*, cmd/warmer/cmd/*, integration/tar.go, pkg/commands/*, pkg/creds/env_keychain.go, pkg/dockerfile/dockerfile.go, pkg/snapshot/snapshot.go
Unused callback and command parameters are represented with blank identifiers without changing surrounding command behavior.
Test callback and mock signatures
cmd/executor/cmd/root_test.go, pkg/buildcontext/https_test.go, pkg/commands/*_test.go, pkg/executor/*_test.go, pkg/image/**/*_test.go, pkg/util/transport_util_test.go
Test doubles and helper callbacks discard unused inputs while preserving their existing returns, assertions, and control flow.
Filesystem ignore and copy behavior
pkg/util/fs_util.go
Ignore checking uses the package-level ignore list, internal copying ignores FileContext, and the copy skip callback ignores unused parameters.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: 0hlov3, babs, bobdu

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing the repository's required template sections like Fixes, Submitter Checklist, Reviewer Notes, and Release Notes. Rewrite the PR description using the template headings and add the required checklist, notes, and release notes sections.
Docstring Coverage ⚠️ Warning Docstring coverage is 17.39% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the PR's unused-parameter cleanup.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch lint-unused-param

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/util/fs_util.go (1)

973-984: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve FileContext exclusions in CopyFileInternal.

Ignoring this parameter removes the exclusion behavior previously applied by this copy path. Any non-empty FileContext can now result in an excluded source being created at the destination; this is a behavioral regression, not merely unused-parameter cleanup.

Restore the context.ExcludesFile(src) guard, matching CopyFile, before opening or creating the destination.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/util/fs_util.go` around lines 973 - 984, Restore FileContext handling in
CopyFileInternal by naming the parameter and checking context.ExcludesFile(src)
before opening the source or creating the destination; return without copying
when the source is excluded, matching CopyFile behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/util/fs_util.go`:
- Around line 549-552: Update CheckCleanedPathAgainstProvidedIgnoreList to
iterate over its caller-provided ignore list parameter instead of the
package-level ignorelist, preserving the existing prefix-match logic and return
behavior.

---

Outside diff comments:
In `@pkg/util/fs_util.go`:
- Around line 973-984: Restore FileContext handling in CopyFileInternal by
naming the parameter and checking context.ExcludesFile(src) before opening the
source or creating the destination; return without copying when the source is
excluded, matching CopyFile behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6e236235-602e-49a0-91a4-79db848e7c9b

📥 Commits

Reviewing files that changed from the base of the PR and between f8e626b and d7e47ed.

📒 Files selected for processing (27)
  • cmd/executor/cmd/root.go
  • cmd/executor/cmd/root_test.go
  • cmd/executor/cmd/version.go
  • cmd/warmer/cmd/root.go
  • integration/tar.go
  • pkg/buildcontext/https_test.go
  • pkg/commands/add.go
  • pkg/commands/cmd.go
  • pkg/commands/copy.go
  • pkg/commands/copy_test.go
  • pkg/commands/entrypoint.go
  • pkg/commands/healthcheck.go
  • pkg/commands/onbuild.go
  • pkg/commands/run.go
  • pkg/commands/run_test.go
  • pkg/commands/shell.go
  • pkg/commands/workdir_test.go
  • pkg/creds/env_keychain.go
  • pkg/dockerfile/dockerfile.go
  • pkg/executor/build_test.go
  • pkg/executor/fakes_test.go
  • pkg/executor/push_test.go
  • pkg/image/image_util_test.go
  • pkg/image/remote/remote_test.go
  • pkg/snapshot/snapshot.go
  • pkg/util/fs_util.go
  • pkg/util/transport_util_test.go

Comment thread pkg/util/fs_util.go
@mzihlmann
mzihlmann merged commit 12c0e86 into main Jul 14, 2026
15 checks passed
@mzihlmann
mzihlmann deleted the lint-unused-param branch July 14, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

easy-review Mechanical or self-contained change needing little domain reasoning to approve linter Pull requests that improve linting or code cleanup

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant