Skip to content

Accept settings as a hashtable, not only a file path - #20

Merged
thisjustin816 merged 1 commit into
mainfrom
feature/analyzer-settings-object
Jul 29, 2026
Merged

thisjustin816 merged 1 commit into
mainfrom
feature/analyzer-settings-object

Conversation

@thisjustin816

Copy link
Copy Markdown
Owner

Invoke-ScriptAnalyzer declares public object Settings and has always accepted a hashtable. This
module narrowed it to [String], so a caller assembling settings at run time had to serialize them to
a file first — writing to a temp path, cleaning it up, and keeping the write collision-free between
processes, all to satisfy a constraint that was never PSScriptAnalyzer's.

The casing workaround was already passing hashtables to Invoke-ScriptAnalyzer internally
($recursiveAnalyzerArguments.Settings = $settingsData, and again for $casingSettings), so the only
things standing in the way were the two parameter types and one Import-PowerShellDataFile.

  • Widen -Settings to [Object] on Invoke-PSModuleAnalyzer and the private casing workaround
  • Import the data file only when the value is a string
  • Copy the levels the split-casing run edits, so a caller''s hashtable is left alone — previously it
    set Rules.PSUseCorrectCasing.Enable = $false in place, which was safe only because the value
    always came from a fresh Import-PowerShellDataFile
  • 4.1.0: additive, since a string still binds

Two tests added: a hashtable run end to end, and a guard that the caller''s copy is unmodified.
74 tests pass; src is analyzer-clean.

Invoke-ScriptAnalyzer types its -Settings as object and has always taken a hashtable; this module
narrowed it to [String]. A caller assembling settings at run time therefore had to serialize them to
a file first, which meant writing to a temp path, cleaning it up, and keeping the write collision-free
between processes -- all to satisfy a constraint that was never PSScriptAnalyzer's.

The workaround already passed hashtables to Invoke-ScriptAnalyzer internally, so only the parameter
types and the one Import-PowerShellDataFile stood in the way.

- Widen -Settings to [Object] on Invoke-PSModuleAnalyzer and the private casing workaround
- Import the data file only when the value is a string
- Copy the levels the split-casing run edits, so a caller's hashtable is left alone
- Bump to 4.1.0; a string still binds, so nothing existing changes
@github-actions

Copy link
Copy Markdown

Test Results

74 tests  +2   74 ✅ +2   22s ⏱️ ±0s
18 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit d946410. ± Comparison against base commit 0d9029f.

@github-actions

Copy link
Copy Markdown

Summary

Summary
Generated on: 7/29/2026 - 3:29:31 PM
Coverage date: 7/29/2026 - 3:28:03 PM
Parser: JaCoCo
Assemblies: 2
Classes: 11
Files: 11
Line coverage: 91.5% (303 of 331)
Covered lines: 303
Uncovered lines: 28
Coverable lines: 331
Total lines: 1068
Covered branches: 0
Total branches: 0
Method coverage: Feature is only available for sponsors
Tag: 112_30465924129

Coverage

src/Private - 95%
Name Line Branch
src/Private 95% ****
src/Private/Get-PSModuleAnalyzerSettingsPath 100%
src/Private/Get-PSModuleGitMetadata 96%
src/Private/Get-PSModulePublishedManifest 100%
src/Private/Invoke-PSModuleAnalyzerCasingWorkaround 94.4%
src/Private/Resolve-PSModuleGitRemote 93.8%
src/Public - 88.8%
Name Line Branch
src/Public 88.8% ****
src/Public/Build-PSModule 77.9%
src/Public/Export-PSModuleAnalyzerSettings 84.2%
src/Public/Invoke-PSModuleAnalyzer 100%
src/Public/New-PSModuleManifest 97.6%
src/Public/Publish-PSModule 100%
src/Public/Test-PSModule 100%

@thisjustin816
thisjustin816 merged commit aa41c36 into main Jul 29, 2026
4 checks passed
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.

1 participant