Skip to content

Commit 96a2b16

Browse files
authored
[CI Example Analyzer] Fix some bugs (Azure#18716)
* fix some bugs * fix some bugs * rollback for the $CODE_BLOCK_REGEX * fix codeRegex * change expression for codeRegex
1 parent 8a2c268 commit 96a2b16

File tree

5 files changed

+381
-224
lines changed

5 files changed

+381
-224
lines changed

build.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266

267267
<Target Name="StaticAnalysisExample" Condition="'$(RunStaticAnalysis)' == 'true'" DependsOnTargets="Build" AfterTargets="StaticAnalysisHelp">
268268
<Message Importance="high" Text="Running static analysis for PowerShell examples..." />
269-
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/StaticAnalysis/ExampleAnalyzer/Measure-MarkdownOrScript.ps1 -MarkdownPaths $(RepoArtifacts)/FilesChanged.txt -RulePaths $(RepoTools)/StaticAnalysis/ExampleAnalyzer/AnalyzeRules/*.psm1 -Recurse -AnalyzeScriptsInFile -OutputScriptsInFile -OutputResultsByModule &quot;"/>
269+
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/StaticAnalysis/ExampleAnalyzer/Measure-MarkdownOrScript.ps1 -MarkdownPaths $(RepoArtifacts)/FilesChanged.txt -RulePaths $(RepoTools)/StaticAnalysis/ExampleAnalyzer/AnalyzeRules/*.psm1 -AnalyzeScriptsInFile -OutputScriptsInFile &quot;"/>
270270
</Target>
271271

272272
<Target Name="StaticAnalysis" DependsOnTargets="StaticAnalysisBreakingChange;StaticAnalysisDependency;StaticAnalysisSignature;StaticAnalysisHelp;StaticAnalysisExample">

tools/StaticAnalysis/ExampleAnalyzer/AnalyzeRules/CommandName.psm1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,20 @@ function Measure-CommandName {
110110
$name = $($CommandParameterPair[$i].CommandName)
111111
$textInfo = (Get-Culture).TextInfo
112112
$CorrectName = $textInfo.ToTitleCase(($name -split "-")[0])
113-
$CorrectName += "-Az"
114-
$CorrectName += $textInfo.ToTitleCase(($name -split "Az")[1])
113+
if($name -match "Az"){
114+
$CorrectName += "-Az"
115+
$CorrectName += $textInfo.ToTitleCase(($name -split "Az")[1])
116+
}
117+
else{
118+
$CorrectName += "-"
119+
$CorrectName += $textInfo.ToTitleCase(($name -split "-")[1])
120+
}
115121
$Remediation = "Check the Capitalization Conventions. Suggest format: $CorrectName"
116122
$Severity = "Warning"
117123
}
118124
$ModuleCmdletExNum = $($CommandParameterPair[$i].ModuleCmdletExNum)
119125
$Result = [Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord]@{
120-
Message = "$ModuleCmdletExNum-@$Message@$Remediation";
126+
Message = "$ModuleCmdletExNum-#@#$Message#@#$Remediation";
121127
Extent = $Asts[$i].Extent;
122128
RuleName = $RuleName;
123129
Severity = $Severity
@@ -140,4 +146,4 @@ function Measure-CommandName {
140146
}
141147
}
142148

143-
Export-ModuleMember -Function Measure-*
149+
Export-ModuleMember -Function Measure-*

0 commit comments

Comments
 (0)