mapping severity

130 views
Skip to first unread message

Marc Lustig

unread,
Feb 19, 2015, 6:09:29 AM2/19/15
to sonarqube-in...@googlegroups.com
Hi,
the plugin downloads the issues properly from Sonar, but it doesn't create any issues in IntelliJ (14) finally.
I think there is a problem mapping the severity:

INFO 12:05:56.425 > Downloading issues for SonarQube resource com.ams:ams-application:default
INFO 12:05:58.582 > Downloaded 2838 issues in 00:02:157
INFO 12:05:58.582 > Creating index for SonarQube resource com.ams:ams-application:default
INFO 12:05:58.584 > Start processing 2842 files and 2838 issues with 4 threads
INFO 12:05:58.587 > 34 / 2842 files processed
INFO 12:05:58.588 > 83 / 2842 files processed
INFO 12:05:58.591 > 166 / 2842 files processed
INFO 12:05:58.631 > 1411 / 2842 files processed
INFO 12:05:58.680 > 2822 / 2842 files processed
INFO 12:05:58.683 > Finished creating index with 0 issues for SonarQube resource com.ams:ams-application:default in 00:00:101

Please help to resolve this. It's highly appreciated :-)

Marc

omayevskiy

unread,
Feb 19, 2015, 11:36:45 AM2/19/15
to sonarqube-in...@googlegroups.com
Do you follow and fully understand the readme? 
In most cases the issue is with resource and how you run the analysis from the idea, depending on your project structure.

Marc Lustig

unread,
Feb 20, 2015, 4:35:27 AM2/20/15
to sonarqube-in...@googlegroups.com
Hi, which readme do you mean?
the zip-file doesn't have a readme.

omayevskiy

unread,
Feb 20, 2015, 4:47:37 AM2/20/15
to sonarqube-in...@googlegroups.com

Marc Lustig

unread,
Feb 20, 2015, 5:07:31 AM2/20/15
to sonarqube-in...@googlegroups.com
Yes, basically that's 
- configuring the SonarCube instance 
- adding the Maven parent-module
- creating an inspection profile to include 
- run Analyse -> inspect code
As I said, it does actually download all the issues that are displayed in SonarCube, but no one is reported.
Do I have to configure something else?

omayevskiy

unread,
Feb 20, 2015, 5:11:18 AM2/20/15
to sonarqube-in...@googlegroups.com

so you have a multi module maven project

- adding the Maven parent-module

won't work, you need instead add the sonar resource names of particular sub modules.

The recommended way is to have a idea module per maven sub project and configure sonar resource per that idea module

Marc Lustig

unread,
Feb 20, 2015, 8:34:22 AM2/20/15
to sonarqube-in...@googlegroups.com
thanks. that worked.

Now next problem is, all issues are interpreted as a WARNING in IntelliJ (as configured in the Inspections dialogue).
How can I filter then for Sonar CRITICAL issues? 
Without such filter the plugin is rather useless, because you want to fix issues according to priority.
So there is a mapping needed between Sonar and IntelliJ severity levels.

omayevskiy

unread,
Feb 20, 2015, 9:28:17 AM2/20/15
to sonarqube-in...@googlegroups.com
don't be confused by the warning level in intellij's inspection window, this is ignored in the editor.

there is a feature request to make the mapping configurable, but the default built in mapping is currently as following:

public static ProblemHighlightType toProblemHighlightType(String sonarSeverity) {
if (StringUtils.isBlank(sonarSeverity)) {
return ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
} else {
sonarSeverity = sonarSeverity.toUpperCase();
if (SonarSeverity.BLOCKER.toString().equals(sonarSeverity) || SonarSeverity.CRITICAL.toString().equals(sonarSeverity)) {
return ProblemHighlightType.ERROR;
} else if (SonarSeverity.MAJOR.toString().equals(sonarSeverity)) {
return ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
} else if (SonarSeverity.INFO.toString().equals(sonarSeverity) || SonarSeverity.MINOR.toString().equals(sonarSeverity)) {
return ProblemHighlightType.WEAK_WARNING;
} else {
return ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
}
}
}

see aslo https://github.com/sonar-intellij-plugin/sonar-intellij-plugin/issues/95 for how to filter critical issues.

>Without such filter the plugin is rather useless, because you want to fix issues according to priority.

cannot agree, the main use case for the plugin is to prevent devs from producing NEW issues, independent from how many issues you have. Illiminate all sonar issues in old project is an illusion like 100% test coverage.
Reply all
Reply to author
Forward
0 new messages