Skip to content

Fix for Useless assignment to local variable#26

Merged
jacoblehr merged 1 commit into
mainfrom
finding-autofix-c89c7494
May 15, 2026
Merged

Fix for Useless assignment to local variable#26
jacoblehr merged 1 commit into
mainfrom
finding-autofix-c89c7494

Conversation

@jacoblehr
Copy link
Copy Markdown
Contributor

General fix: remove dead local assignments and only declare variables when their value is actually produced/used.

Best fix here: in internal/app/service.go, update the if statement in analyzeLog so it no longer initializes prepErr in the if initializer. Instead, use a plain condition and declare prepErr only at the assignment from prepareAnalysisWithStore (a, prepErr := ...). This preserves current functionality and keeps prepErr scoped to the block.

No imports, new methods, or new definitions are needed.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@jacoblehr jacoblehr marked this pull request as ready for review May 15, 2026 23:02
Copilot AI review requested due to automatic review settings May 15, 2026 23:02
@jacoblehr jacoblehr merged commit fe27c3a into main May 15, 2026
5 of 6 checks passed
@jacoblehr jacoblehr deleted the finding-autofix-c89c7494 branch May 15, 2026 23:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to remove a dead local assignment in analyzeLog by eliminating an if initializer that existed only to declare prepErr, and instead declaring variables closer to where they’re produced/used.

Changes:

  • Removes the if prepErr := error(nil); ... initializer in analyzeLog.
  • Introduces a short variable declaration (:=) when calling prepareAnalysisWithStore.

Comment thread internal/app/service.go
if prepErr := error(nil); a != nil || errors.Is(err, engine.ErrNoMatch) {
a, prepErr = prepareAnalysisWithStore(a, string(data), "log", surface, opts, persist)
if a != nil || errors.Is(err, engine.ErrNoMatch) {
a, prepErr := prepareAnalysisWithStore(a, string(data), "log", surface, opts, persist)
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