Skip to content

Commit 5dfea6b

Browse files
CfrancCyrillebegarco
authored andcommitted
Fix #9 & #8 (#18)
* Fix #9 & #8 : bad langage analysis and cancel NaN comment-ratio metrics
1 parent dd36c15 commit 5dfea6b

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/main/java/fr/cnes/sonarqube/plugins/icode/report/AnalysisProject.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public String toString() {
5757
@Override
5858
public boolean isF77() {
5959
boolean res=false;
60-
if(listOfAnalysisRule != null && !listOfAnalysisRule.isEmpty()
61-
&& listOfAnalysisRule.get(0).analysisRuleId.startsWith(AnalysisRule.F77)){
60+
if(analysisFile != null && analysisFile.languageField != null && !analysisFile.languageField.isEmpty()
61+
&& analysisFile.languageField.toLowerCase().endsWith(AnalysisRule.F77.toLowerCase())){
6262
res=true;
6363
}
6464
return res;
@@ -67,8 +67,8 @@ public boolean isF77() {
6767
@Override
6868
public boolean isF90() {
6969
boolean res=false;
70-
if(listOfAnalysisRule != null && !listOfAnalysisRule.isEmpty()
71-
&& listOfAnalysisRule.get(0).analysisRuleId.startsWith(AnalysisRule.F90)){
70+
if(analysisFile != null && analysisFile.languageField != null && !analysisFile.languageField.isEmpty()
71+
&& analysisFile.languageField.toLowerCase().endsWith(AnalysisRule.F90.toLowerCase())){
7272
res=true;
7373
}
7474
return res;
@@ -177,7 +177,8 @@ public ReportFunctionRuleInterface[] getRatioCommentMeasureByFunction(){
177177
List<ReportFunctionRuleInterface> listOfRes = new ArrayList<>();
178178
for (AnalysisRule analysisRule : listOfAnalysisRule) {
179179
if(analysisRule.analysisRuleId.endsWith(AnalysisRule.RATIO_COMMENT)
180-
&& analysisRule.resultField.resultTypePlace.equals(METHOD_TYPE_PLACE)){
180+
&& analysisRule.resultField.resultTypePlace.equals(METHOD_TYPE_PLACE)
181+
&& !Double.isNaN(Double.parseDouble(analysisRule.resultField.resultValue))){
181182
listOfRes.add(analysisRule);
182183
}
183184
}

src/main/java/fr/cnes/sonarqube/plugins/icode/report/XmlReportReader.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,15 @@ public void endElement(String uri, String localName, String qName) throws SAXExc
172172
case ANALYSIS_PROJECT:
173173
LOGGER.info("End report analysis:" + qName);
174174
break;
175+
case ANALYSIS_INFORMATIONS:
176+
LOGGER.info("End report analysis:" + qName);
177+
break;
178+
case ANALYSIS_FILE:
179+
LOGGER.info("End report analysis:" + qName);
180+
break;
181+
case AnalysisRule.RESULT:
182+
LOGGER.info("End report analysis:" + qName);
183+
break;
175184
default:
176185
LOGGER.error("Unexpected report analysis end element:" + qName);
177186
}

0 commit comments

Comments
 (0)