Skip to content

Commit 67eb2ac

Browse files
author
Kapil Borle
committed
Add comment based help to exported function in RuleMaker
1 parent b732c74 commit 67eb2ac

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

Utils/RuleMaker.psm1

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,19 +364,57 @@ Function Remove-RuleTest($Rule)
364364
Remove-Item -Path $ruleTestFilePath
365365
}
366366

367+
<#
368+
.SYNOPSIS
369+
Adds a C# based builtin rule to Rules project in PSScriptAnalyzer solution
370+
.EXAMPLE
371+
C:\PS> Add-Rule -Name UseCompatibleCmdlets -Severity Warning -CommonName 'Use Compatible Cmdlets' -Description 'Checks if a cmdlet is compatible with a given PowerShell version, edition and os combination' -Error '{0} command is not compatible with PowerShell version {1}, edition {2} and OS {3}'
372+
373+
This will result in the following.
374+
- create {PScriptAnalyzerSolutionRoot}/Rules/UseCompatibleCmdlets.cs
375+
- create {PScriptAnalyzerSolutionRoot}/Tests/Rules/UseCompatibleCmdlets.tests.ps1
376+
- create {PScriptAnalyzerSolutionRoot}/RuleDocumentation/UseCompatibleCmdlets.md
377+
- update {PScriptAnalyzerSolutionRoot}/Rules/Strings.resx
378+
- update {PScriptAnalyzerSolutionRoot}/Rules/ScriptAnalyzerBuiltinRules.csproj
379+
380+
.PARAMETER Name
381+
Rule name. An entry in Strings.resx is created for this value.
382+
383+
.PARAMETER Severity
384+
Severity of the rule from on the following values: {Information, Warning, Error}
385+
386+
.PARAMETER CommonName
387+
A somewhat verbose name of of the rule. An entry in Strings.resx is created for this value.
388+
389+
.PARAMETER Description
390+
Rule description. An entry in Strings.resx is created for this value.
391+
392+
.PARAMETER Error
393+
Error message. An entry in Strings.resx is created for this value.
394+
395+
.INPUTS
396+
None
397+
398+
.OUTPUTS
399+
None
400+
#>
367401
Function Add-Rule
368402
{
369403
param(
370404
[Parameter(Mandatory=$true)]
371405
[string] $Name,
372406

407+
[Parameter(Mandatory=$true)]
373408
[ValidateSet("Error", "Warning", "Information")]
374409
[string] $Severity,
375410

411+
[Parameter(Mandatory=$true)]
376412
[string] $CommonName,
377413

414+
[Parameter(Mandatory=$true)]
378415
[string] $Description,
379416

417+
[Parameter(Mandatory=$true)]
380418
[string] $Error)
381419

382420
$rule = New-RuleObject -Name $Name -Severity $Severity -CommonName $CommonName -Description $Description -Error $Error
@@ -411,6 +449,26 @@ Function Add-Rule
411449
}
412450
}
413451

452+
<#
453+
.SYNOPSIS
454+
Removes a rule from builtin rules
455+
456+
.EXAMPLE
457+
C:\PS> Remove-Rule -Name UseCompatibleCmdlets
458+
459+
This will result in the following.
460+
- remove {PScriptAnalyzerSolutionRoot}/Rules/UseCompatibleCmdlets.cs
461+
- remove {PScriptAnalyzerSolutionRoot}/Tests/Rules/UseCompatibleCmdlets.tests.ps1
462+
- remove {PScriptAnalyzerSolutionRoot}/RuleDocumentation/UseCompatibleCmdlets.md
463+
- remove UseCompatibleCmdlets entries from {PScriptAnalyzerSolutionRoot}/Rules/Strings.resx
464+
- remove UseCompatibleCmdlets entries from {PScriptAnalyzerSolutionRoot}/Rules/ScriptAnalyzerBuiltinRules.csproj
465+
466+
.INPUTS
467+
None
468+
469+
.OUTPUTS
470+
None
471+
#>
414472
Function Remove-Rule
415473
{
416474
param(

0 commit comments

Comments
 (0)