stepstone-tech / sonar-coldfusion

SonarQube ColdFusion Analyzer
Apache License 2.0
24 stars 18 forks source link

NPE: Preconditions.checkNotNull #15

Open dajester2013 opened 7 years ago

dajester2013 commented 7 years ago

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 commented 7 years ago

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

mpaluchowski commented 7 years ago

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:

rudderfeet commented 6 years ago

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 commented 6 years ago

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.