Bump PSScriptAnalyzer to 1.25.0 - #32
Conversation
Regenerates docs/patterns.json and docs/description/* via scripts/generateDocs.sh against the new module version, adding 5 new rules (disabled by default, matching current policy for non-security rules) and refreshing upstream rule descriptions/docs. Also truncates rule descriptions over 500 chars in install.ps1: upstream's Get-ScriptAnalyzerRule now returns longer text for AvoidUsingCmdletAliases and AvoidUsingInvokeExpression, which broke codacy-plugins-test's description length check. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
There was a problem hiding this comment.
Pull Request Overview
The PR successfully updates PSScriptAnalyzer to version 1.25.0 and incorporates five new rules, correctly configured as disabled by default. While the code is up to standards according to Codacy, there is a potential runtime error in the install.ps1 script due to a missing null check when processing rule descriptions. Additionally, minor typos in the documentation examples should be corrected to maintain quality. The proposed truncation logic for long descriptions is a good addition but requires validation as noted in the test plan.
Test suggestions
- Verify that rule descriptions exceeding 500 characters are correctly truncated with an ellipsis in description.json
- Confirm that all 5 new rules are initialized with 'enabled': false in patterns.json
- Validate that the tool version in patterns.json matches the content of psscriptanalyzer.version
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify that rule descriptions exceeding 500 characters are correctly truncated with an ellipsis in description.json
2. Confirm that all 5 new rules are initialized with 'enabled': false in patterns.json
3. Validate that the tool version in patterns.json matches the content of psscriptanalyzer.version
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
| $title = getTitle $patternNameCamelCased ; | ||
| if($title -eq $patternNameCamelCased) { Write-Output "$patternNameCamelCased"; $count = $count+1;} | ||
| $description = $pat.Description ; | ||
| if($description.Length -gt 500) { $description = $description.Substring(0, 497) + '...' } ; |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Accessing the .Length property on $description without a null check will cause a runtime error if a rule lacks a description. This might be a simple fix:
| if($description.Length -gt 500) { $description = $description.Substring(0, 497) + '...' } ; | |
| if ($description -and $description.Length -gt 500) { $description = $description.Substring(0, 497) + '...' } |
| # Inorrect | ||
| function f([Parameter()]$FirstParam) { |
There was a problem hiding this comment.
⚪ LOW RISK
Nitpick: There is a typo in the documentation: 'Inorrect' should be 'Incorrect'.
| # Inorrect | |
| function f([Parameter()]$FirstParam) { | |
| # Incorrect |
Summary
psscriptanalyzer.versionfrom1.24.0to1.25.0(latest release, confirmed present on both the PowerShell Gallery and the upstream GitHub tagPowerShell/PSScriptAnalyzer/archive/1.25.0.tar.gz).docs/patterns.jsonanddocs/description/*viascripts/generateDocs.sh/install.ps1:enabled: false(none are security-sensitive, so left disabled per existing policy — no rule was added to$enabledRules/subcategory arrays ininstall.ps1):psavoidreservedwordsasfunctionnames,psuseconsistentparametersetname,psuseconsistentparameterskind,psuseconstrainedlanguagemode,psusesinglevaluefrompipelineparameter.install.ps1: upstream'sGet-ScriptAnalyzerRulenow returns descriptions over 500 characters forAvoidUsingCmdletAliasesandAvoidUsingInvokeExpression, which brokecodacy-plugins-test's "descriptions must be ≤500 chars" check. Added truncation (to 497 chars +...) for any description over the limit, since this constraint isn't currently enforced anywhere else in the generator and would otherwise silently break future updates too.mcr.microsoft.com/powershell:lts-7.4-alpine-3.17) and CircleCI orb versions unchanged — 1.25.0 requires PowerShell Core ≥ 7.4.6, and the current base image tag already resolves to 7.4.7, so no bump needed there.Validation
docker build -f Dockerfile -t codacy-psscriptanalyzer .— succeeds.codacy-plugins-testrun locally against the freshly built image:sbt "runMain codacy.plugins.DockerTest json codacy/codacy-psscriptanalyzer:latest"— all tests passed (this initially failed on the two overlong descriptions above; passed after theinstall.ps1truncation fix).sbt "runMain codacy.plugins.DockerTest pattern codacy/codacy-psscriptanalyzer:latest"— all tests passed.sbt "runMain codacy.plugins.DockerTest multiple codacy/codacy-psscriptanalyzer:latest"— all tests passed (run_multiple_tests: true, matching what CI runs).Test plan
docker buildsucceedscodacy-plugins-testJsonTests passcodacy-plugins-testPatternTests passcodacy-plugins-testMultipleTests pass🤖 Generated with Claude Code