PowerShell / PowerShell/PSScriptAnalyzer
Custom rule is invoked twice for a single script
Open
Nobody has claimed this yet.
Area - Engine
Issue - Discussion
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
I am writing custom rules and I see an error reported twice when there should be just one report.
I invoke script analyzer like this:
#11 PS> Invoke-ScriptAnalyzer -CustomRulePath D:\gh\PesterAnalyzerRules -Path a.ps1
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PesterAnalyzerRules\Measure-ShouldT Information a.ps1 3 Pipe a script block to 'Should Throw' or 'Should Not Throw'
hrow
PesterAnalyzerRules\Measure-ShouldT Information a.ps1 3 Pipe a script block to 'Should Throw' or 'Should Not Throw'
hrow
@ D:\xtmp
#12 PS> cat a.ps1
Describe "a" {
"b" | Should Throw
}
In a debugger, I noticed my rule is getting called on two different threads.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with Invoke-ScriptAnalyzer, -CustomRulePath, and the a.ps1 example shown in the report. Trace the custom-rule invocation across the two observed threads and verify that the rule produces one report for the single script occurrence; the command output should contain only one diagnostic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100