Blame Error during SonarQube Scanner execution - sonarqube

I am using sonarqube-6.0 and i tried with a sample example to run with sonar-scanner
i am getting the blame ERROR when ever I run any project in sonar-scanner
The file Conf in sonar-scanner configuration is vi sonar-scanner.properties
#
# must be unique in a given SonarQube instance
sonar.projectKey=SonarSource-sonar-examples-8051d9d
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=java-maven-simple
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# the sonar-project.properties file.
sonar.sources=/Users/kingslee/work/software/projects/sonar-scanner-2.8/bin/sonar-examples
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
~
When i run command ./sonar-scanner these are the error which i get frequently
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Unable to blame file sonar-examples/plugins/java-custom-rules/src/main/java/org/sonar/samples/java/MyJavaFileCheckRegistrar.java
at org.sonarsource.scm.git.JGitBlameCommand.blame(JGitBlameCommand.java:128)
at org.sonarsource.scm.git.JGitBlameCommand.access$000(JGitBlameCommand.java:44)
at org.sonarsource.scm.git.JGitBlameCommand$1.call(JGitBlameCommand.java:112)
at org.sonarsource.scm.git.JGitBlameCommand$1.call(JGitBlameCommand.java:109)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at org.eclipse.jgit.internal.storage.file.UnpackedObjectCache$Table.index(UnpackedObjectCache.java:146)
at org.eclipse.jgit.internal.storage.file.UnpackedObjectCache$Table.contains(UnpackedObjectCache.java:109)
at org.eclipse.jgit.internal.storage.file.UnpackedObjectCache.isUnpacked(UnpackedObjectCache.java:64)
at org.eclipse.jgit.internal.storage.file.ObjectDirectory.openObject(ObjectDirectory.java:376)
at org.eclipse.jgit.internal.storage.file.WindowCursor.open(WindowCursor.java:142)
at org.eclipse.jgit.lib.ObjectReader.open(ObjectReader.java:226)
at org.eclipse.jgit.blame.BlameGenerator.push(BlameGenerator.java:317)
at org.eclipse.jgit.api.BlameCommand.call(BlameCommand.java:216)
at org.sonarsource.scm.git.JGitBlameCommand.blame(JGitBlameCommand.java:126)
... 7 more
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

Related

Getting Metric 'files' should not be computed by a Sensor when sinning run-sonar-swift.sh -v

Currently I am implementing SonarQube in project but after all setting I am getting error like
Running Lizard...Running SonarQube using SonarQube Runner..ERROR: Error during SonarQube Scanner execution
ERROR: Metric 'files' should not be computed by a Sensor
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
ERROR - Command 'sonar-scanner ' failed with error code: 1
Could you guys help me here please?

Sonarqube : The 'report' parameter is missing

I am using MSBuild. I have Java 8 installed.
I am running the following commands:
SonarQube.Scanner.MSBuild.exe begin /k:"ABC" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="8b839xxxxxxxxxxxxxxxxxxxxxxx6b00125bf92" /d:sonar.verbose=true
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" /t:rebuild
SonarQube.Scanner.MSBuild.exe end /d:sonar.login="8b839xxxxxxxxxxxxxxxxxxxxxxx6b00125bf92"
The last step fails:
ERROR: Error during SonarQube Scanner execution
ERROR: The 'report' parameter is missing
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
The SonarQube Scanner did not complete successfully
12:53:21.909 Creating a summary markdown file...
12:53:21.918 Post-processing failed. Exit code: 1
The MSBuild version is greater than 14.
Java 8 is properly installed. Documentation indicates that Java 8 is adequate.
Any idea on what could be wrong?
Where do I add the -X switch? I tried on all 3 statements
Update :I installed Java SDK 9. Still same issue.
Update :With verbose logging and using /n naming parameter:
INFO: Analysis report generated in 992ms, dir size=4 MB
INFO: Analysis reports compressed in 549ms, zip size=1 MB
INFO: Analysis report generated in C:\ABC\.sonarqube\out\.sonar\scanner-report
DEBUG: Upload report
DEBUG: POST 400 http://localhost:9000/api/ce/submit?projectKey=ABC | time=1023ms
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 54.833s
INFO: Final Memory: 51M/170M
INFO: ------------------------------------------------------------------------
DEBUG: Execution getVersion
DEBUG: Execution stop
ERROR: Error during SonarQube Scanner execution
ERROR: The 'report' parameter is missing
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
Process returned exit code 1
The SonarQube Scanner did not complete successfully
Creating a summary markdown file...
Post-processing failed. Exit code: 1
I've struggled the same problem with SonarQube and I've finally found a solution:
You need to restart sonar service after using evaluation token.
Please note this isn't the answer, however I feel this feedback is valuable to getting this question answered.
I can reproduce this issue in POSTMan with a POST request to:
http://localhost:9000/api/ce/submit?projectKey=myProjectKey
This returns
{
"errors": [
{
"msg": "The 'report' parameter is missing"
}
]
}
You can get a similar error by removing the projectKey query parameter. I tried adding a report query parameter and received the same error:
http://localhost:9000/api/ce/submit?projectKey=brian3016&report=report
Given this, I feel there is a problem with their code. It should have included a report parameter when creating the POST request, but it failed to do so.
Verbose output seems to have changed from using the -X switch to /d:sonar.verbose=true. E.G.
SonarScanner.MSBuild.exe begin /k:"myProjectKey" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="myLogin" /d:sonar.verbose=true
Note the verbose logging didn't give me any valuable insight.
(Also note that the documentation currently says to use SonarQube.Scanner.MSBuild.exe, but the verbose logger told me to switch to SonarScanner.MSBuild.exe)
SO...how we we report this issue to someone that can fix it? Their documentation says to go to Stackoverflow. So here we are.
I thought it may have been an issue with a project. So I created a new project with nothing other than the startup template Console Application. Same error.
In my case SonarQube 7.9.1 (deployed with Helm to Kubernetes cluster) was missing temp directory /opt/sonarqube/temp/tc/work/Tomcat/localhost/ROOT after Helm rollback. No idea what happened to it.
Logfile /opt/sonarqube/logs/web.log inside SonarQube pod had this error:
2021.02.02 06:57:03 WARN web[AXdZ6l6MParQCncJACv3][o.s.s.w.ServletRequest] Can't read file part for parameter report
java.io.IOException: The temporary upload location [/opt/sonarqube/temp/tc/work/Tomcat/localhost/ROOT] is not valid
The fix was to exec into pod and create the missing directory. Would like to know the reason though...
The issue is with the sonar service starting up.
First try to stop the SonarStart.bat by using Ctrl+c, and then try to open localhost:9000 ( or whichever port you configured sonar server).
If it is still opening then go to task manager and search for wrapper.exe service and stop the service. If no service is found then go to:
Task manager>Details> and stop all java.exe process.
Note: If you running many Java applications, right-click the java.exe and choose goto service, and stop only those java.exe that belongs to AppX deployment.services
Now start sonarstart.bat as administrator..
today i face the same error when using jenkins to scanner the code.
get the error when POST /api/ce/submit and get 400 code by add the sonar.verbose=true
i use the below step to check reason
first to restart the sonarqube => failed
check the report file size by using "du -sh" get 108m and DB server support 1G => failed
login the sonar-qube server and check the access.log, web.log and another log, finally find the error reason " Processing of multipart/form-data request failed. No space left on device", so i check the server by command "df -h", some devices are used 100% => so i remove some no-using file and fix it!!!
check if you have enough memory
ex: free -m
In my case I had to upgrade memory.

SonarQube analysis fails after upgrade to 3.7.1 rules

Using SonarQube 5.2 - just the "click and go" distribution downloaded yesterday and running under Windows. Nothing fancy.
After upgrading the "Java" rules package from the bundled 3.6 version to 3.7.1, the sonar runner then fails during analysis.
There's a long stacktrace that is revealed when running with '-e' option however there is no detail on where in the file it failed (line-number, method) or which rule failed.
I have pared down the stack-trace to what I believe are the useful bits:
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
...
Caused by: org.sonar.squidbridge.api.AnalysisException: SonarQube is unable to analyze file : 'C:\Users\robert.rusk\Documents\cvs\ip_probe\src\com\robert\splat\MyClass.java'
...
Caused by: java.lang.IndexOutOfBoundsException: index (1) must be less than size (1)
...
at org.sonar.java.checks.PrintfCheck.verifyParameters(PrintfCheck.java:173)
at org.sonar.java.checks.PrintfCheck.onMethodInvocationFound(PrintfCheck.java:112)
...
You are encoutering the following issue : https://jira.sonarsource.com/browse/SONARJAVA-1369
It happens when you have a parameter with %< during the printf check (rule squid:S2275).
Issue has been fixed (few minutes ago for the record ;) ) and should be part of next release bound to happen within the next few days.
After some investigation I now believe the error occurs because String.format is called without enough parameters (should be 2), and when I comment out this line the analysis then runs without any problems.
splatDateStr = String.format("%tFT%<tRZ", splatDate);
I guess this is the PrintfCheck that is referred to in the stack-trace.

Sonar - Fail to request server version | HTTP Status 404 /

With each run done by console or by Jenkins throws me the following error:
SonarQube Runner 2.4
Java 1.8.0_51 Oracle Corporation (32-bit)
Linux 2.6.32-504.30.3.el6.i686 i386
INFO: Runner configuration file: /usr/local/sonar-runner/conf/sonar-runner.properties
INFO: Project configuration file: /opt/apps/php-sonar-runner/sonar-project.properties
INFO: Default locale: "es_ES", source code encoding: "UTF-8"
INFO: Work directory: /opt/apps/php-sonar-runner/./.sonar
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 0.042s
Final Memory: 0M/28M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Fail to request server version
ERROR: Caused by: Status returned by url : 'http://xxx.xxx.xx.xxx:9000/api/server/version' is invalid : 404
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Open the URL 'http://xxx.xxx.xx.xxx:9000/api/server/version' in a browser, see if it gives you a 404 error. If so, you need to find the right path to Sonar root on the remote server, maybe 'http://xxx.xxx.xx.xxx:9000/sonar/'?
When you have the full URL of Sonar, update the sonar.host.url property in your pom accordingly. See full documentation for more details.
Check the value of sonar.web.context = /myPath maybe you have some path and you configure other path in your url at your jenkis, tfs, etc. That is the reason you get an 404 error.
In your example you should not have that value configurated or without a value.
'http://xxx.xxx.xx.xxx:9000/myPath/api/server/version
In your sonar-runner.properties file
define #--- Default SonarQube sever as give below
sonar.host.url=http://localhost:9000/sonar
Also cross check in sonar.properties file i.e
sonar.web.port=9000
sonar.web.host=127.0.0.1
sonar.web.context=/sonar

Failure running sonar-runner locally

I have an instance of sonar running on my local machine at localhost:9000, and I'm able to go to and use the console. When I try to run sonar-runner from the command line for a project, I get a 500 error:
Exception in thread "main" org.sonar.runner.RunnerException: org.picocontainer.PicoLifecycleException: PicoLifecycleException: method 'public void org.sonar.batch.bootstrap.DatabaseCompatibility.start()', instance 'org.sonar.batch.bootstrap.DatabaseCompatibility#3848110b, org.sonar.api.utils.HttpDownloader$HttpException: Fail to download [http://localhost:9000/api/server]. Response code: 500
at org.sonar.runner.Runner.delegateExecution(Runner.java:288)
at org.sonar.runner.Runner.execute(Runner.java:151)
at org.sonar.runner.Main.execute(Main.java:84)
at org.sonar.runner.Main.main(Main.java:56)
Caused by: org.picocontainer.PicoLifecycleException: PicoLifecycleException: method 'public void org.sonar.batch.bootstrap.DatabaseCompatibility.start()', instance 'org.sonar.batch.bootstrap.DatabaseCompatibility#3848110b, org.sonar.api.utils.HttpDownloader$HttpException: Fail to download [http://localhost:9000/api/server]. Response code: 500
at org.picocontainer.monitors.NullComponentMonitor.lifecycleInvocationFailed(NullComponentMonitor.java:77)
...
...
But when i visit the url in my browser, I get the following xml response:
<server>
<id>20131007131041</id>
<version>3.4.1</version>
<status>UP</status>
</server>
I'm not sure where to go from here. Any advice?
The current workaround is to unset GEM_PATH and GEM_HOME variables before launching the sonar webservice:
unset GEM_PATH GEM_HOME
./sonar.sh console
This doesn't have to be done for the sonar-runner environment.
The problem is caused due to conflict with Ruby local installation.
As per the sonar-runner documentation you need to create a sonar-project.properties in your project root and then run sonar-runner from command line
ref Sonar runner docs
In my case it worked with following workaround
1: export GEM_HOME=''
2: export GEM_PATH=''
3: restart sonar webserver
4: run sonar-runner in project path

Resources