Skip to content

Fix PSReviewUnusedParameter code scanning alerts#2208

Merged
aholstrup1 merged 2 commits intomainfrom
aholstrup1/fix-unused-parameter-alerts
Apr 10, 2026
Merged

Fix PSReviewUnusedParameter code scanning alerts#2208
aholstrup1 merged 2 commits intomainfrom
aholstrup1/fix-unused-parameter-alerts

Conversation

@aholstrup1
Copy link
Copy Markdown
Collaborator

@aholstrup1 aholstrup1 commented Apr 10, 2026

Addresses open PSScriptAnalyzer code scanning alerts

Approach

The alerts fall into distinct categories, each handled differently:

Production code - true fixes:

  • Build-AppsInWorkspace: Removed MajorMinorVersion, BuildNumber, and RevisionNumber parameters. These were accepted but never used - version stamping is handled by Update-AppJsonProperties which is called separately before compilation. Also removed the corresponding entries from the \ splatting in Compile.ps1.
  • e2eTestHelper.psm1: The \ parameter was accepted by CreateNewAppInFolder but never written into the generated app.json. Added runtime to the output - this is a bug fix.
  • CompileFromWorkspace.psm1: Replaced an empty catch block (for unparseable .NET runtime versions) with an OutputDebug call that logs the version string and error.

Production code - suppressed:

  • Compile.ps1: \ is passed by the action YAML workflow and cannot be removed without updating the action definition. It may also be needed for future incremental build support (see existing TODO). Added a targeted SuppressMessageAttribute.

Test files - fixed:

  • AL-Go-Helper.Test.ps1: \ was assigned in BeforeEach but PSScriptAnalyzer flagged it as unused since usage was in separate It blocks. Scoped it to \ so the cross-block usage is explicit.

Test files - suppressed:

  • CompileFromWorkspace.Test.ps1 and DownloadProjectDependencies.Test.ps1: All 57 alerts are Pester mock scriptblock parameters that must match the mocked function's signature for positional binding. Added file-level SuppressMessageAttribute with justification.

- Remove unused MajorMinorVersion, BuildNumber, RevisionNumber params
  from Build-AppsInWorkspace (versioning handled by Update-AppJsonProperties)
- Suppress buildMode warning in Compile.ps1 (required by workflow binding)
- Add file-level SuppressMessageAttribute in test files for mock params
- Fix unused runtime param in e2eTestHelper by adding it to app.json
@aholstrup1 aholstrup1 requested a review from a team as a code owner April 10, 2026 06:26
Copilot AI review requested due to automatic review settings April 10, 2026 06:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces PowerShell code scanning noise by fixing or intentionally suppressing PSReviewUnusedParameter findings across production scripts, helper modules, and Pester tests—keeping the action/module APIs aligned with real usage.

Changes:

  • Removed unused version-stamping parameters from Build-AppsInWorkspace and stopped splatting them from the compile action.
  • Fixed CreateNewAppInFolder to actually persist the provided runtime into generated app.json.
  • Added targeted SuppressMessageAttribute suppressions for parameters that must exist (workflow-provided) and for Pester mock/callback signatures.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Tests/DownloadProjectDependencies.Test.ps1 Adds file-level suppression for unused mock parameters (Pester signature parity).
Tests/CompileFromWorkspace.Test.ps1 Adds file-level suppression for unused mock parameters while preserving the UTF-8 BOM.
e2eTests/e2eTestHelper.psm1 Writes runtime into generated app.json to match the function’s parameter contract.
Actions/CompileApps/Compile.ps1 Suppresses the workflow-provided-but-currently-unused buildMode parameter and removes unused build splat keys.
Actions/.Modules/CompileFromWorkspace.psm1 Removes unused Build-AppsInWorkspace parameters and updates comment-based help accordingly.

…ock alerts

- Scope baseSettings variable to script level in AL-Go-Helper.Test.ps1
  so PSScriptAnalyzer sees it used across BeforeEach/It blocks
- Replace empty catch block in CompileFromWorkspace.psm1 with
  OutputDebug logging for unparseable .NET runtime versions
@aholstrup1 aholstrup1 merged commit 4a049b1 into main Apr 10, 2026
8 checks passed
@aholstrup1 aholstrup1 deleted the aholstrup1/fix-unused-parameter-alerts branch April 10, 2026 12:17
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.

4 participants