Skip to content

Detect += "/" manual path concatenation - #54986

Merged
pelikhan merged 2 commits into
mainfrom
copilot/fix-manualpathconcat-detection
Aug 23, 2026
Merged

pelikhan merged 2 commits into
mainfrom
copilot/fix-manualpathconcat-detection

Conversation

Copilot AI commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

manualpathconcat missed compound assignments because it only inspected nested BinaryExpr chains like x + "/" + y. As a result, path += "/" + suffix produced no diagnostic even though it manually builds a path with a slash separator.

  • Analyzer coverage

    • Adds AssignStmt handling for single-target += expressions.
    • Detects RHS expressions shaped as "/" + segment.
    • Reports diagnostics using the LHS as the implicit first path segment.
  • Test coverage

    • Adds an analysistest case for the previously missed compound-assignment pattern.

Example now detected:

absPath += "/" + relPath
// manual "/" path concatenation; use filepath.Join(absPath, relPath) (or path.Join) instead

Copilot AI changed the title [WIP] Fix manualpathconcat to detect compound-assignment concatenation Detect += "/" manual path concatenation Aug 23, 2026
Copilot AI requested a review from pelikhan August 23, 2026 04:38
@pelikhan
pelikhan marked this pull request as ready for review August 23, 2026 04:38
Copilot AI balanced review requested due to automatic review settings August 23, 2026 04:38
@pelikhan
pelikhan merged commit ae803cb into main Aug 23, 2026
@pelikhan
pelikhan deleted the copilot/fix-manualpathconcat-detection branch August 23, 2026 04:38

Copilot AI 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.

Pull request overview

Extends manualpathconcat to detect manual path construction using +=.

Changes:

  • Inspects single-target += assignments for "/" + segment.
  • Adds an analysistest regression case for issue #54983.
Show a summary per file
File Description
pkg/linters/manualpathconcat/manualpathconcat.go Adds compound-assignment analysis and diagnostics.
pkg/linters/manualpathconcat/testdata/src/manualpathconcat/manualpathconcat.go Tests the newly detected pattern.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.87.5

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.

manualpathconcat: plus-equals form of manual path concatenation is never detected

3 participants