Skip to content

[code-simplifier] refactor: simplify recent code changes for clarity and idiomaticity#19753

Merged
pelikhan merged 2 commits intomainfrom
code-simplifier/2026-03-05-700de51fa3419cd4
Mar 6, 2026
Merged

[code-simplifier] refactor: simplify recent code changes for clarity and idiomaticity#19753
pelikhan merged 2 commits intomainfrom
code-simplifier/2026-03-05-700de51fa3419cd4

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 5, 2026

This PR applies targeted simplifications to recently merged code (last 24 hours) to improve clarity, consistency, and idiomaticity while preserving all functionality.

Files Simplified

  • pkg/fileutil/tar.go — use errors.Is(err, io.EOF) instead of direct == comparison
  • pkg/parser/schema_utilities.go — inline single-use ignored variable
  • pkg/cli/audit_report_analysis.go — split long sliceutil.Map call for readability

Improvements Made

1. Idiomatic error comparison (pkg/fileutil/tar.go)

Changed err == io.EOF to errors.Is(err, io.EOF). The project has errorlint enabled in .golangci.yml which flags direct sentinel error comparisons in favour of errors.Is. This is consistent with Go 1.13+ best practices.

2. Inline single-use variable (pkg/parser/schema_utilities.go)

Removed the intermediate ignored variable that was assigned and immediately used in the next if statement. The inline form is more direct and removes unnecessary indirection.

Before:

ignored := slices.Contains(constants.IgnoredFrontmatterFields, key)
if ignored {

After:

if slices.Contains(constants.IgnoredFrontmatterFields, key) {

3. Split long line (pkg/cli/audit_report_analysis.go)

Broke a single long sliceutil.Map(...) call (>120 chars) onto multiple lines, improving readability without changing behavior.

Changes Based On

Recent PRs from the last 24 hours:

Testing

  • ✅ Build passes (go build ./...)
  • ✅ Package tests pass (go test ./pkg/fileutil/... ./pkg/parser/...)
  • ✅ Code formatted (make fmt)
  • ✅ No functional changes — behavior is identical

Review Focus

Please verify:

  • The errors.Is change is semantically equivalent (it is — io.EOF is a simple sentinel, not wrapped)
  • The inlined variable doesn't reduce clarity (it doesn't — ignored added no meaning beyond the expression itself)
  • The multi-line Map call is readable (it is — matches Go conventions for multi-arg function calls)

References: §22732114386

Generated by Code Simplifier ·

  • expires on Mar 6, 2026, 7:10 PM UTC

- pkg/fileutil/tar.go: use errors.Is(err, io.EOF) instead of == comparison
  (errorlint linter requires idiomatic error comparison)
- pkg/parser/schema_utilities.go: inline single-use 'ignored' variable
  to reduce unnecessary intermediate assignment
- pkg/cli/audit_report_analysis.go: split long sliceutil.Map call onto
  multiple lines for improved readability

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan merged commit 0482b40 into main Mar 6, 2026
46 of 48 checks passed
@pelikhan pelikhan deleted the code-simplifier/2026-03-05-700de51fa3419cd4 branch March 6, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant