-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: SonarQube JSON export format is invalid (#121)
The format used for the JSON SonarQube export is considered invalid by SonarQube (version 9.6) * ConfigFileNaming and FlowSubflowNaming rules didn't call the super constructor, causint the export to not include the engineId field which is required by the SonarQube importer * The exporter was generating a textRange for rules reporting violations with line 0. SonarQube importer requires the line number to be valid (> 0). Co-authored-by: Elias Rangel <Elias.Rangel@lla.com>
- Loading branch information
Showing
4 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...nter-core/src/test/groovy/com/avioconsulting/mule/linter/model/SonarQubeReportTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.avioconsulting.mule.linter.model | ||
|
||
import com.avioconsulting.mule.linter.model.rule.Rule | ||
import com.avioconsulting.mule.linter.model.rule.RuleViolation | ||
import com.avioconsulting.mule.linter.model.rule.RuleExecutor.SonarQubeReport | ||
import spock.lang.Specification | ||
|
||
class SonarQubeReportTest extends Specification { | ||
|
||
def 'check lineNumber reported correctly'() { | ||
given: | ||
SonarQubeReport sq = new SonarQubeReport(); | ||
DummyRule dummyRule = new DummyRule(); | ||
when: | ||
RuleViolation violationZeroLine = new RuleViolation(dummyRule, 'testPath', 0, 'testViolation') | ||
RuleViolation violationGreaterThanZeroLine = new RuleViolation(dummyRule, 'testPath', 11, 'testViolation') | ||
sq.getIssues().add(new SonarQubeReport.SonarQubeReportIssues(violationZeroLine)) | ||
sq.getIssues().add(new SonarQubeReport.SonarQubeReportIssues(violationGreaterThanZeroLine)) | ||
then: | ||
sq.getIssues()[0].primaryLocation.textRange == null | ||
sq.getIssues()[1].primaryLocation.textRange != null | ||
sq.getIssues()[1].primaryLocation.textRange.startLine == 11 | ||
} | ||
} | ||
|
||
class DummyRule extends Rule { | ||
static final String RULE_ID = 'DUMMY_RULE' | ||
static final String RULE_NAME = 'Dummy Test Rule.' | ||
@Override | ||
List<RuleViolation> execute(Application app){ | ||
return null | ||
} | ||
DummyRule() { | ||
super(RULE_ID, RULE_NAME) | ||
} | ||
} |