Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: PowerShell/PSScriptAnalyzer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a143b9f
Choose a base ref
...
head repository: PowerShell/PSScriptAnalyzer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4b0117c
Choose a head ref
  • 7 commits
  • 33 files changed
  • 6 contributors

Commits on May 4, 2026

  1. Improve pipeline indentation handling in UseConsistentIndentation rule (

    #2173)
    
    * Improve pipeline indentation handling in UseConsistentIndentation rule
    
    * Fix over-indentation when multiple openers appear on the same line
    liamjpeters authored May 4, 2026
    Configuration menu
    Copy the full SHA
    d97ddd4 View commit details
    Browse the repository at this point in the history

Commits on May 7, 2026

  1. Prevent duplicate rule ID suppression errors in -Fix and DSC scenar…

    …ios (#2181)
    
    * Enhance suppression error handling in ScriptAnalyzer and add tests for unapplied suppression errors
    
    * Skip new -Fix suppression test under Library Usage harness
    
    The `Library Usage` describe block in `LibraryUsage.tests.ps1` (only
    active on Windows PowerShell 5.1, since it's gated `-Skip:$IsCoreCLR`)
    re-runs `RuleSuppression.tests.ps1` against a hand-rolled
    `Invoke-ScriptAnalyzer` wrapper that drives the analyzer as a .NET
    library. That wrapper plugs in `PesterTestOutputWriter`, whose
    `WriteError` is intentionally a no-op:
    
        public void WriteError(ErrorRecord error)
        {
            // We don't write errors to avoid misleading
            // error messages in test output
        }
    
    So the unapplied-suppression `ErrorRecord` we now emit during the final
    `-Fix` pass never reaches `-ErrorVariable`, and `$fixErr | Should
    -HaveCount 1` fails with "Expected a collection with size 1, but got an
    empty collection". The behaviour itself is correct - the assertion is
    just unobservable through this test harness.
    
    Mark the new `It` block `-Skip:$testingLibraryUsage`, matching the
    existing pattern already used by the `Bad Rule Suppression` and
    `External Rule Suppression` contexts in the same file for the same
    reason. The regular pwsh and WinPS runs of `RuleSuppression.tests.ps1`
    (which `[+]` in the failing CI log) continue to exercise the assertion.
    
    The new `UseDSCResourceFunctions.tests.ps1` test isn't dot-sourced by
    `LibraryUsage.tests.ps1`, so it doesn't need the same guard.
    
    Drafted by Copilot (Claude Opus 4.7).
    
    * Add copilot review suggestions
    
    ---------
    
    Co-authored-by: Andy Jordan <2226434+andyleejordan@users.noreply.github.com>
    liamjpeters and andyleejordan authored May 7, 2026
    Configuration menu
    Copy the full SHA
    940024a View commit details
    Browse the repository at this point in the history
  2. Settings file creation and validation (#2176)

    * Add RuleOptionInfo class and update RuleInfo to include options for configurable rules
    
    * Add Test and New Cmdlets for PSScriptAnalyzer Settings Management
    
    - Implemented `New-ScriptAnalyzerSettingsFile` cmdlet to create a new PSScriptAnalyzer settings file, with options for presets and overwriting existing files.
    - Added `Test-ScriptAnalyzerSettingsFile` cmdlet to validate settings files, checking for parseability, rule existence, and valid options.
    - Created comprehensive tests for both cmdlets to ensure functionality and error handling.
    - Updated module manifest to export the new cmdlets.
    - Added documentation for both cmdlets, including usage examples and parameter descriptions.
    - Enhanced error messages in the strings resource file for better clarity during validation failures.
    
    * Enhance ScriptAnalyzer settings file validation and documentation
    
    - Update Helper.cs to return null for empty output paths instead of an empty array.
    - Add new error message for invalid option types in Strings.resx.
    - Extend tests for New-ScriptAnalyzerSettingsFile to check for new keys: CustomRulePath, IncludeDefaultRules, and RecurseCustomRulePath.
    - Modify Test-ScriptAnalyzerSettingsFile tests to validate output and error handling for various scenarios, including type mismatches and invalid values.
    - Improve documentation for New-ScriptAnalyzerSettingsFile and Test-ScriptAnalyzerSettingsFile to clarify behavior and parameters, including handling of custom rules and output format.
    
    * Apply docs suggestions from Sean's review
    
    Co-authored-by: Sean Wheeler <sean.wheeler@microsoft.com>
    
    * Add Copilot review suggestions
    
    ---------
    
    Co-authored-by: Sean Wheeler <sean.wheeler@microsoft.com>
    liamjpeters and sdwheeler authored May 7, 2026
    Configuration menu
    Copy the full SHA
    9c04a44 View commit details
    Browse the repository at this point in the history

Commits on May 15, 2026

  1. Add new MissingTryBlock rule (#2179)

    * #2098 Add new MissingTryBlock rule
    
    * Changed severity level of MissingTryBlock rule from Error to Warning in the rule definition and resolved copy-pasta in the rule description.
    
    Co-authored-by: Copilot <copilot@github.com>
    
    * Updated tests for MissingTryBlock rule to reflect severity change from Error to Warning.
    
    * Update Rules/MissingTryBlock.cs
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    * Grammar: “which is likely a mistake and result in … error” is ungrammatical.
    
    * Update Rules/Strings.resx
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    * Update Rules/MissingTryBlock.cs
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    * minor but worthwhile
    
    * Update docs/Rules/MissingTryBlock.md
    
    Co-authored-by: Sean Wheeler <sean.wheeler@microsoft.com>
    
    * Applied feedback from @andrewconnell to add a note about the rule not being enabled by default, and to add a note about potential false positives with functions named "catch" or "finally". Also added a test context for when the rule is disabled. Updated the rule implementation to inherit from ConfigurableRule and set Enable to false in the constructor. Updated the AnalyzeScript method to be an override, and added overrides for GetCommonName, GetDescription, GetName, GetSeverity, and GetSourceName.
    
    * Update docs/Rules/MissingTryBlock.md
    
    Co-authored-by: Liam Peters <liamjpeters@gmail.com>
    
    * Update Tests/Rules/MissingTryBlock.tests.ps1
    
    Co-authored-by: Liam Peters <liamjpeters@gmail.com>
    
    * Update Rules/MissingTryBlock.cs
    
    Co-authored-by: Liam Peters <liamjpeters@gmail.com>
    
    * Update Rules/MissingTryBlock.cs
    
    Co-authored-by: Liam Peters <liamjpeters@gmail.com>
    
    ---------
    
    Co-authored-by: Copilot <copilot@github.com>
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    Co-authored-by: Sean Wheeler <sean.wheeler@microsoft.com>
    Co-authored-by: Liam Peters <liamjpeters@gmail.com>
    5 people authored May 15, 2026
    Configuration menu
    Copy the full SHA
    97f30d6 View commit details
    Browse the repository at this point in the history

Commits on May 18, 2026

  1. Add new AvoidUsingArrayList rule (#2174)

    * Implemented the AvoidUsingArrayList rule to warn when the ArrayList class is used in PowerShell scripts. Added tests for both violations and non-violations of this rule. Updated documentation to include the new rule and its guidelines.
    
    * Testing-Commit-CSpell-issue
    
    * Apply suggestion from @liamjpeters
    
    I clearly used several other rules as a kind of template...🤪
    
    Co-authored-by: Liam Peters <liamjpeters@gmail.com>
    
    * Update docs/Rules/AvoidUsingArrayList.md
    
    Co-authored-by: Liam Peters <liamjpeters@gmail.com>
    
    * Updated rule help
    
    * Changed "unintentionally"
    
    * Update Rules/AvoidUsingArrayList.cs
    
    Co-authored-by: Liam Peters <liamjpeters@gmail.com>
    
    * Update Tests/Rules/AvoidUsingArrayList.tests.ps1
    
    Co-authored-by: Liam Peters <liamjpeters@gmail.com>
    
    * ArrayListName could be null
    
    * Resolved camelCase
    
    * Remove ComponentModel namespace
    
    * Fixed tests
    
    * Updated Tests
    
    * fixed and tested empty (dynamic) BoundParameter
    
    * Robuster Pester tests
    
    * Configurable (enable by default)
    
    * Fixed ConstantValue null check test and rule
    
    * Better UsingStatements handling and disable AvoidUsingArrayList by default
    
    * `[ArrayList]::new()` without a `using namespace System.Collections`
    
    * Potential fix for pull request finding
    
    Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
    
    * Resolve Copilot suggestions and resolved `Method not found: ScriptBlockAst.get_UsingStatements()` error
    
    ---------
    
    Co-authored-by: Liam Peters <liamjpeters@gmail.com>
    Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
    3 people authored May 18, 2026
    Configuration menu
    Copy the full SHA
    6dadae3 View commit details
    Browse the repository at this point in the history
  2. Add new InvalidMultiDotValue rule (#2180)

    * Add new InvalidMultiDotValue rule
    
    * Fixed several issues as commented by Liam.
    
    Co-authored-by: Copilot <copilot@github.com>
    
    * Potential fix for pull request finding
    
    Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
    
    * Improved wording based on Copilot suggestions.
    
    * Update docs/Rules/InvalidMultiDotValue.md
    
    Co-authored-by: Sean Wheeler <sean.wheeler@microsoft.com>
    
    * Update docs/Rules/InvalidMultiDotValue.md
    
    Co-authored-by: Sean Wheeler <sean.wheeler@microsoft.com>
    
    * **opt-in by default.**
    
    * Remove dead code and change `PSAvoidExclaimOperator` from documentation
    
    ---------
    
    Co-authored-by: Copilot <copilot@github.com>
    Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
    Co-authored-by: Sean Wheeler <sean.wheeler@microsoft.com>
    4 people authored May 18, 2026
    Configuration menu
    Copy the full SHA
    eb6cebe View commit details
    Browse the repository at this point in the history
  3. Add new AvoidDynamicallyCreatingVariableNames rule (#2178)

    * 1st commit
    
    * Avoid dynamic variable names rule implementation and tests
    
    * Removed `using System.Linq;` and added some tests
    
    * Covering Liam's feedback
    
    Co-authored-by: Copilot <copilot@github.com>
    
    * Update docs/Rules/AvoidDynamicallyCreatingVariableNames.md
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    * Update docs/Rules/AvoidDynamicallyCreatingVariableNames.md
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    * Update Rules/Strings.resx
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    * Corrected alphabetical order of rules in README.md
    
    * Corrected $ruleMessage in Test
    
    Co-authored-by: Copilot <copilot@github.com>
    
    * Changed newVariableAst.Parent.Extent to newVariableAst.Extent
    
    * Made rule configurable (disabled) and updated documentation and tests accordingly. Increased number of information tests to 20 in Get-ScriptAnalyzerRule tests.
    
    * Change rule name from PSAvoidExclaimOperator to PSAvoidDynamicallyCreatingVariableNames in documentation.
    
    ---------
    
    Co-authored-by: Copilot <copilot@github.com>
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    3 people authored May 18, 2026
    Configuration menu
    Copy the full SHA
    4b0117c View commit details
    Browse the repository at this point in the history
Loading