Skip to content

Commit 5d63841

Browse files
authored
enable gen sdk issue suppress (#23559)
1 parent 1f3ffef commit 5d63841

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

tools/StaticAnalysis/CmdletDiffAnalyzer/CmdletDiffAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void Analyze(
117117
string moduleName = psd1FileName.Replace(".psd1", "");
118118
Directory.SetCurrentDirectory(directory);
119119

120-
Console.WriteLine("Analysing module: {0}", moduleName);
120+
Console.WriteLine("Analyzing module: {0}", moduleName);
121121
processedHelpFiles.Add(moduleName);
122122

123123
var newModuleMetadata = MetadataLoader.GetModuleMetadata(moduleName);

tools/StaticAnalysis/GeneratedSdkAnalyzer/SDKGeneratedCodeVerify.ps1

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,40 @@ $SavePath = $PWD
3131

3232
$MissReadMe = 9000
3333
$GenSdkChanged = 9090
34+
35+
function EnsureModuleName {
36+
param([string]$moduleName)
37+
if (-not [System.String]::IsNullOrEmpty($moduleName) -and -not $moduleName.StartsWith("Az."))
38+
{
39+
return "Az.$moduleName"
40+
}
41+
return $moduleName
42+
}
43+
44+
function Get-NonExceptionSdkRecord{
45+
param(
46+
[GeneratedSdkIssue[]]$records
47+
)
48+
$exceptionPaths = "$PSScriptRoot\..\..\..\tools\StaticAnalysis\Exceptions"
49+
$errors = @()
50+
foreach($record in $records){
51+
$exceptionPath = Join-Path -Path $exceptionPaths -ChildPath (EnsureModuleName($record.Module)) -AdditionalChildPath "GeneratedSdkIssues.csv"
52+
if(Test-Path -Path $exceptionPath){
53+
$exceptionContents = Import-Csv -Path $exceptionPath
54+
foreach($exceptionContent in $exceptionContents) {
55+
if($exceptionContent.Module -eq $record.Module -and $exceptionContent.Sdk -eq $record.Sdk -and $exceptionContent.Severity -eq $record.Severity -and $exceptionContent.ProblemId -eq $record.ProblemId -and $exceptionContent.Description -eq $record.Description){
56+
$needAdd = $false
57+
break
58+
}
59+
}
60+
}
61+
if($needAdd){
62+
$errors += $record
63+
}
64+
}
65+
return $errors
66+
}
67+
3468
try {
3569
if ((Test-Path $FilesChangedPaths -PathType Leaf) -and $FilesChangedPaths.EndsWith(".txt")) {
3670
# Read Changedfiles and check if generted sdk code is updated.
@@ -136,6 +170,7 @@ try {
136170
}
137171
Set-Location $SavePath
138172
}
173+
$ExceptionList = Get-NonExceptionSdkRecord $ExceptionList
139174
}
140175
catch {
141176
Write-Host "An error occurred: $_"

0 commit comments

Comments
 (0)