Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getQualityProfilesName: NullPointerException #204

Closed
traw opened this issue Mar 31, 2021 · 3 comments · Fixed by #232 or #279
Closed

getQualityProfilesName: NullPointerException #204

traw opened this issue Mar 31, 2021 · 3 comments · Fixed by #232 or #279
Assignees
Labels
bug Something isn't working done This issue was solved but not merged in master
Milestone

Comments

@traw
Copy link

traw commented Mar 31, 2021

java -jar sonar-cnes-report.jar   -t XXXXXXX -s https://sonarqube.com/ -p project-name -o project-name
SonarQube URL: https://sonarqube.com/
SonarQube online: true
Detected SonarQube version: 8.6.0
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.poi.openxml4j.util.ZipSecureFile$1 (file:/Users/user/project/sonar-cnes-report/target/sonar-cnes-report.jar) to field java.io.FilterInputStream.in
WARNING: Please consider reporting this to the maintainers of org.apache.poi.openxml4j.util.ZipSecureFile$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.lang.NullPointerException
	at fr.cnes.sonar.report.model.Report.getQualityProfilesName(Report.java:290)
	at fr.cnes.sonar.report.exporters.docx.DataAdapter.loadPlaceholdersMap(DataAdapter.java:444)
	at fr.cnes.sonar.report.exporters.docx.DocXExporter.export(DocXExporter.java:140)
	at fr.cnes.sonar.report.factory.ReportFactory.report(ReportFactory.java:104)
	at fr.cnes.sonar.report.ReportCommandLine.execute(ReportCommandLine.java:137)
	at fr.cnes.sonar.report.ReportCommandLine.main(ReportCommandLine.java:77)
@traw traw added the bug Something isn't working label Mar 31, 2021
@traw
Copy link
Author

traw commented Mar 31, 2021

Solution:

diff --git a/src/main/java/fr/cnes/sonar/report/model/Report.java b/src/main/java/fr/cnes/sonar/report/model/Report.java
index 543627c..5cd360a 100644
--- a/src/main/java/fr/cnes/sonar/report/model/Report.java
+++ b/src/main/java/fr/cnes/sonar/report/model/Report.java
@@ -287,7 +287,7 @@ public class Report {
         Language language;
         for(ProfileMetaData q : project.getQualityProfiles()) {
             language = project.getLanguage(q.getLanguage());
-            sb.append(q.getName()).append(" [").append(language.getName()).append("]; ");
+            sb.append(q.getName()).append(" [").append(language != null? language.getName(): q.getLanguage()).append("]; ");
         }

         return sb.toString();

@Sancretor
Copy link
Contributor

Hi @traw

Thanks for your feedback !
We will soon work on the SonarQube 8.x compatibility, so it will be extremely useful !

@Sancretor Sancretor added this to the 4.0.0 milestone Apr 1, 2021
@Sancretor
Copy link
Contributor

Hi @traw

We just went through your modification and I have to admit, we don't understand how you triggered this NullPointerException.
In this method, we check that the configured inside your QualityProfile matches a known language in the SonarQube server.
This way, we can retrieve the language fullname.

So... how can your Quality Profile be configured for a language that does not exist in SonarQube ...?
We are quite interested to know which plugin/language triggers this issue.
So could you please answer this question ?

ErwanGauduchon added a commit that referenced this issue May 4, 2021
@Sancretor Sancretor linked a pull request May 7, 2021 that will close this issue
12 tasks
@ErwanGauduchon ErwanGauduchon added done This issue was solved but not merged in master bug Something isn't working and removed bug Something isn't working labels May 7, 2021
traw added a commit to traw/sonar-cnes-report that referenced this issue Jul 27, 2021
@Sancretor Sancretor mentioned this issue Aug 27, 2021
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working done This issue was solved but not merged in master
Projects
None yet
3 participants