Skip to content

Commit

Permalink
Fix a bug where the assembly level issues would crash PR-CA (based on… (
Browse files Browse the repository at this point in the history
#1753)

* Fix a bug where the assembly level issues would crash PR-CA (based on master commit 4e68906)
  • Loading branch information
bgavrilMS committed May 19, 2016
1 parent 2027d31 commit 634216f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
32 changes: 23 additions & 9 deletions Tasks/SonarQubePostTest/PRCA/ReportProcessor-Module.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ function FetchAnnotatedNewIssues
CreateComponentKeyToPathMap $json

# '@' makes sure the result set is returned as an array
$newIssues = @($json.issues | Where {$_.isNew -eq $true})
$newIssues = @($json.issues | Where { $_.isNew -eq $true })
Write-Host "SonarQube found $($json.issues.Count) issues out of which $($newIssues.Count) are new"

$newFileLevelIssues = @($newIssues | Where {(IsFileLevelIssue $_)})
$difference = $newIssues.Count - $newFileLevelIssues.Count
if ($difference -gt 0)
{
Write-Host "$difference issue(s) do not relate to a specific file and will not be posted to the code review"
}

$newIssues = AnnotateIssuesWithRelativePath $newIssues
$newFileLevelIssues = AnnotateIssuesWithRelativePath $newFileLevelIssues

return $newIssues
return $newFileLevelIssues
}

#endregion
Expand Down Expand Up @@ -128,11 +135,6 @@ function GetComponentGuid

$tokens = $component.Split(":")

if ($tokens.Count -ne 4)
{
throw "Internal error: component $component is not in the expected format (expected 4 parts)"
}

#third token must be a guid
$guidToken = $tokens[2]

Expand Down Expand Up @@ -215,7 +217,7 @@ function AnnotateIssuesWithRelativePath
param ([Array]$issues)

foreach ($issue in $issues)
{
{
$filePath = GetPathRelativeToRepoRoot $($issue.component)

# Add a new property in the object which stores the file path so it can be consumed directly
Expand All @@ -225,6 +227,18 @@ function AnnotateIssuesWithRelativePath
return $issues
}

#
# File level issues have a 4-part component. Assembly level issues have a 3-part component.
#
function IsFileLevelIssue
{
param ([ValidateNotNullOrEmpty()]$issue)

$tokens = $issue.component.Split(":")

return ($tokens.Count -eq 4)
}

#endregion

# Export the public functions
Expand Down
2 changes: 1 addition & 1 deletion Tasks/SonarQubePostTest/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 45
"Patch": 46
},
"minimumAgentVersion": "1.99.0",
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/SonarQubePostTest/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 45
"Patch": 46
},
"minimumAgentVersion": "1.99.0",
"demands": [
Expand Down
10 changes: 10 additions & 0 deletions Tests/L0/SonarQubePostTest/PRCA/data/out/.sonar/sonar-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
"isNew": true,
"creationDate": "2016-02-29T14:10:20+0000"
},
{
"key": "3d04d8a1-1c8d-47be-8e47-09a1b4c037f6",
"component": "prca_test:prca_test:8C269B30-29BC-4BCD-9AB0-7ACFB763DB2E",
"message": "This issue is reported at the assembly level!",
"severity": "MAJOR",
"rule": "fxcop:MarkAssembliesWithNeutralResourcesLanguage",
"status": "OPEN",
"isNew": true,
"creationDate": "2016-05-17T23:16:56+0200"
},
{
"key": "AVMtPj5t2ux5vOqxVSsN",
"component": "prca_test:prca_test:8C269B30-29BC-4BCD-9AB0-7ACFB763DB2E:Class1.cs",
Expand Down

0 comments on commit 634216f

Please sign in to comment.