Skip to content

fix(linting): broken extension matching logic in Get-ChangedFilesWithExtensions #31

@WilliamBerryiii

Description

@WilliamBerryiii

Issue Description

The extension matching logic in Get-ChangedFilesWithExtensions function is broken and will cause incorrect behavior.

File: scripts/linting/Modules/LintingHelpers.psm1
Line 62

Problem

Current code:

$matchesExtension = $FileExtensions | Where-Object { $_ -like $_ } | ForEach-Object { $file -like $_ } | Where-Object { $_ } | Select-Object -First 1
  • \$_ -like \$_ always evaluates to true
  • \$file variable is undefined in this scope (should be \$_ from parent pipeline)

Expected Fix

$matchesExtension = $false
foreach ($pattern in $FileExtensions) {
    if ($_ -like $pattern) {
        $matchesExtension = $true
        break
    }
}

Impact

  • Severity: Critical
  • Function will fail or produce incorrect results when filtering files by extension

Source

Identified in PR #26 code review comment from Copilot reviewer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions