Skip to content

(MAINT) Update PowerShell adapter code for PSSA - #1770

Open
Mikey Lombardi (He/Him) (michaeltlombardi) wants to merge 1 commit into
PowerShell:mainfrom
michaeltlombardi:maint/main/adapter-pssa
Open

Mikey Lombardi (He/Him) (michaeltlombardi) wants to merge 1 commit into
PowerShell:mainfrom
michaeltlombardi:maint/main/adapter-pssa

Conversation

@michaeltlombardi

Copy link
Copy Markdown
Collaborator

PR Summary

This change updates the source code to fix or explicitly suppress the violation rules without changing code functionality.

The most common fixes are:

  • Using parameters explicitly instead of positionally
  • Suppressing false positives for PSUseDeclaredVarsMoreThanAssignments
  • Moving function code into the process block when a function supports input from the pipeline instead of defining directly in the body

PR Context

Prior to this change the PowerShell adapter script and module files raised numerous errors, warnings, and lower severity violations for PSScriptAnalyzer.

Prior to this change the PowerShell adapter script and module files
raised numerous errors, warnings, and lower severity violations for
PSScriptAnalyzer.

This change updates the source code to fix or explicitly suppress the
violation rules without changing code functionality.

The most common fixes are:

- Using parameters explicitly instead of positionally
- Suppressing false positives for `PSUseDeclaredVarsMoreThanAssignments`
- Moving function code into the `process` block when a function supports
  input from the pipeline instead of defining directly in the body
@michaeltlombardi
Mikey Lombardi (He/Him) (michaeltlombardi) marked this pull request as ready for review October 22, 2026 13:56
Copilot AI balanced review requested due to automatic review settings October 22, 2026 13:56

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.

🔵 Needs a closer look

Cross-version validation on Windows PowerShell 5.1 and PowerShell 7 is needed to confirm that the process-block refactoring preserves adapter behavior.

No open issues 🎉

What changed in this PR

This PR cleans up the PowerShell DSC adapter scripts for PSScriptAnalyzer, with the stated intent of preserving existing behavior.

Changes:

  • Adds explicit parameter names and targeted analyzer suppressions.
  • Moves pipeline-capable function bodies into process blocks.
  • Renames helpers and updates their call sites, while removing unused module-import assignments.
File Description
adapters/​powershell/​psDscAdapter/​win_psDscAdapter.psm1 Applies analyzer cleanup and process-block refactoring to the Windows PowerShell adapter.
adapters/​powershell/​psDscAdapter/​psDscAdapter.psm1 Updates helper names, parameter usage, suppressions, and pipeline processing.
adapters/​powershell/​psDscAdapter/​powershell.resource.ps1 Updates tracing and operation dispatch with process blocks and explicit parameters.

Review effort: Balanced

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.

3 participants