Skip to content

refactor: Extract shared boilerplate from linting wrapper scripts #323

@WilliamBerryiii

Description

@WilliamBerryiii

Issue Description

Invoke-YamlLint.ps1 and Invoke-PSScriptAnalyzer.ps1 share nearly identical boilerplate for parameter handling, changes-only filtering, and result reporting. This common structure could be extracted into a shared pattern or helper function to reduce maintenance overhead.

Additional Context

Shared patterns between the scripts:

  • Same parameter sets (-ChangesOnly, -BaseBranch, -OutputFormat)
  • Identical imports of LintingHelpers.psm1
  • Same pattern for collecting changed files and filtering
  • Similar result aggregation and output format handling

Recommended approach:

  1. Create a New-LintingContext function in LintingHelpers.psm1 that handles common setup (file discovery, changes-only filtering)
  2. Update both scripts to use the shared context builder
  3. Keep tool-specific logic (PSScriptAnalyzer vs actionlint invocation) in each script

Testing:

  • Run both npm run psscriptanalyzer and npm run lint:yaml
  • Verify -ChangesOnly behavior still works for both
  • Run existing Pester tests

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions