Skip to content

powershell: strict PSScriptAnalyzer default, strict mode and ErrorActionPreference check #14675

Open

Description

@TrapsterDK

Where

  • quality/tiers/psscriptanalyzer/standard.psd1:1-6, strict.psd1:1-7: formatter rules only; no extra lint rules, no severity.
  • quality/tools.bzl:1930-1975: psscriptanalyzer, no severity().
  • quality/adapter/src/parsers/psscriptanalyzer.rs:37-41: Information maps to info, so it never fails.
  • powershell/: no check for Set-StrictMode or $ErrorActionPreference.
  • docs/cli/commands/quality.md:428: no PSScriptAnalyzer config row or tier text.

Fix

Guard rules (do first):

  • Confirm on and failing: PSAvoidUsingInvokeExpression, PSAvoidUsingWriteHost, PSAvoidUsingEmptyCatchBlock, PSAvoidUsingCmdletAliases, PSAvoidUsingPositionalParameters, PSAvoidAssignmentToAutomaticVariable, PSPossibleIncorrectComparisonWithNull.
  • AST check: every non-module .ps1 sets Set-StrictMode -Version 3.0 and $ErrorActionPreference = 'Stop' near the top.
  • AST check: SuppressMessageAttribute needs a non-empty Justification.
  • AST check: -ErrorAction SilentlyContinue or Ignore needs a comment.

Then:

  • Add PSUseCorrectCasing, PSUseConsistentParameterSetName, PSUseSingleValueFromPipelineParameter.
  • severity(default = "warning") so Information findings fail.
  • Document the tiers in quality.md.

Excluded

PSUseCompatibleSyntax, PSUseCompatibleCommands, PSUseCompatibleTypes, PSUseCompatibleCmdlets, PSUseConstrainedLanguageMode, PSAvoidLongLines, PSAlignAssignmentStatement, PSAvoidSemicolonsAsLineTerminators, PSAvoidUsingDoubleQuotesForConstantString, PSUseConsistentParametersKind, PSAvoidExclaimOperator, PSProvideCommentHelp, PSUseSingularNouns, PSUseOutputTypeCorrectly, DSC rules.

Test

  • Negative fixture per guard (Write-Host, iex, empty catch, missing strict mode, empty Justification) fails dx lint.
  • Parser test: an Information finding fails.
  • Clean fixture passes. tier = "standard" still passes.

Verify every rule ID and flag against the pinned tool version before landing; some come from memory.

Part of #14647

Activity

  1. added
    cloud-pool
    on Nov 22, 2026
  2. TrapsterDK commented on Nov 22, 2026

    @TrapsterDK
    CollaboratorAuthor

    Paths in this issue are from an old layout. Branch from origin/main; quality code is in core/quality/, wrappers in /private/. Rebase on #14647 (strict default) and #14685 (severity floor).

    Related: #14691 makes psscriptanalyzer a default linter.

    🤖 Generated with Claude Code

  3. TrapsterDK commented on Nov 22, 2026

    @TrapsterDK
    CollaboratorAuthor

    cloud-claim 1c14ee10


    Generated by Claude Code

  4. TrapsterDK commented on Nov 22, 2026

    @TrapsterDK
    CollaboratorAuthor

    Blocked on #14647 (strict default) and #14685 (severity floor), both open; this rebases on them.


    Generated by Claude Code

  5. added
    blocked
    cloud-taken
    and removed
    cloud-pool
    on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedcloud-taken

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions