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

NPE: Preconditions.checkNotNull #15

Open
dajester2013 opened this issue Jul 31, 2017 · 4 comments
Open

NPE: Preconditions.checkNotNull #15

dajester2013 opened this issue Jul 31, 2017 · 4 comments
Assignees
Labels
Milestone

Comments

@dajester2013
Copy link

dajester2013 commented Jul 31, 2017

I'm getting an NPE running sonar-scanner with the following properties:

The problem goes away if I remove the exclusions. I have a feeling I've got a bad exclusion, but I'm not sure how to write it properly. If that is the case, it should throw a useful exception stating as such, not an NPE.

Sonar properties:

# must be unique in a given SonarQube instance
sonar.projectKey=redacted
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=redacted
sonar.projectVersion=1.0
 
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set. 
sonar.sources=modules,library,components

sonar.exclusions=**/*.java,**/*.class,**/extjs*/**/*,**/build/**/*
sonar.java.binaries=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

NPE Exception trace:

	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:187)
	at com.stepstone.sonar.plugin.coldfusion.cflint.CFlintAnalysisResultImporter.createNewIssue(CFlintAnalysisResultImporter.java:106)
	at com.stepstone.sonar.plugin.coldfusion.cflint.CFlintAnalysisResultImporter.handleIssueTag(CFlintAnalysisResultImporter.java:97)
	at com.stepstone.sonar.plugin.coldfusion.cflint.CFlintAnalysisResultImporter.parse(CFlintAnalysisResultImporter.java:74)
	at com.stepstone.sonar.plugin.coldfusion.cflint.CFlintAnalysisResultImporter.parse(CFlintAnalysisResultImporter.java:64)
	at com.stepstone.sonar.plugin.coldfusion.cflint.CFlintAnalysisResultImporter.parse(CFlintAnalysisResultImporter.java:53)
	at com.stepstone.sonar.plugin.coldfusion.ColdFusionSensor.importResults(ColdFusionSensor.java:74)
	at com.stepstone.sonar.plugin.coldfusion.ColdFusionSensor.execute(ColdFusionSensor.java:57)
@dajester2013
Copy link
Author

BTW, the java stuff is in there to get it to play nicely with the TFS SonarQube plugin - it's irrelevant otherwise.

@mpaluchowski mpaluchowski self-assigned this Aug 1, 2017
@mpaluchowski mpaluchowski added this to the 1.5.1 milestone Aug 1, 2017
@mpaluchowski
Copy link
Contributor

mpaluchowski commented Aug 1, 2017

We had similar reports in the past with #6, and those weren't related to any exclusions -- at least none of the examples reported there had any.

It looks like a paths problem. Specifically, the code that parses CFLint's XML output is trying to get a handle on the file for a given issue and most likely isn't finding it in the index of files of the sonar-scanner.

What could help is, if you could attach here:

  • the console output of your sonar-scanner, preferably after running it with --debug
  • the XML file output by CFLint (you'll find it at .scannerwork/cflint-result.xml inside the directory where you run sonar-scanner)
  • the structure of your code -- where your sonar-project.properties sits, vs. where the code is, and what's the working directory you're running sonar-scanner from.

@rudderfeet
Copy link

I'm running into the same issue scanning a reasonably large project. Unfortunately I can't share results because it's corporate code, but here's the stack trace:

INFO: ------------------------------------------------------------------------ INFO: EXECUTION FAILURE INFO: ------------------------------------------------------------------------ INFO: Total time: 3:11.611s INFO: Final Memory: 52M/532M INFO: ------------------------------------------------------------------------ ERROR: Error during SonarQube Scanner execution java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:187) at com.stepstone.sonar.plugin.coldfusion.cflint.CFlintAnalysisResultImporter.createNewIssue(CFlintAnalysisResultImporter.jav a:106) at com.stepstone.sonar.plugin.coldfusion.cflint.CFlintAnalysisResultImporter.handleIssueTag(CFlintAnalysisResultImporter.jav a:97) at com.stepstone.sonar.plugin.coldfusion.cflint.CFlintAnalysisResultImporter.parse(CFlintAnalysisResultImporter.java:74) at com.stepstone.sonar.plugin.coldfusion.cflint.CFlintAnalysisResultImporter.parse(CFlintAnalysisResultImporter.java:64) at com.stepstone.sonar.plugin.coldfusion.cflint.CFlintAnalysisResultImporter.parse(CFlintAnalysisResultImporter.java:53) at com.stepstone.sonar.plugin.coldfusion.ColdFusionSensor.importResults(ColdFusionSensor.java:74) at com.stepstone.sonar.plugin.coldfusion.ColdFusionSensor.execute(ColdFusionSensor.java:57) at org.sonar.batch.sensor.SensorWrapper.analyse(SensorWrapper.java:57) at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58) at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50) at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83) at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241) at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236) at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47) at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106) at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119) at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60) at com.sun.proxy.$Proxy0.execute(Unknown Source) at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:240) at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151) at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110) at org.sonarsource.scanner.cli.Main.execute(Main.java:72) at org.sonarsource.scanner.cli.Main.main(Main.java:60)

@rudderfeet
Copy link

Additional info: I was able to run CFLint successfully against Cold Fusion code that (one project) won't finish a Sonar scan without NPE: Preconditions.checkNotNull, and (another project) that scans into Sonar OK but doesn't let you drill down into the detailed issues - it shows zeros for each of the blocker, critical, major, minor and info issues, which doesn't match up with the summary stats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants