Response
stringlengths
8
2k
Instruction
stringlengths
18
2k
Prompt
stringlengths
14
160
SonarQube architecture is not intended to support this use case.However, you can "trick" SonarQube. First, you can run CFR to have source files to show in SonarQube. Second, in order to have bug reports, you can run SpotBugs manually and place the report at either/target/findbugsXml.xmlor/target/spotbugsXml.xml. If a file is present, SpotBugs plugin will assume that analysis has already been done with Maven and loaded the issues from the XML.What might break : - Some issue might be hard to map to their decompiled source file. - The line mapping will likely fail because the decompiler does not provide a 1 to 1 mapping.Alternative:Here is a Jenkins configuration example which combined a couple of tools including CFR and FSB:https://github.com/GoSecure/jenkins-fsb
I have some jar files that I'd like to run sonarqube scans (especially findbugs) against but I do not have the source. Is there any change to run the scans only against the class files?When running sonar-scanner against the extracted jar file I always get a message like this:18:49:58.364 DEBUG: 'freemarker/template/TemplateServletUtils.class' indexed with language 'null'and when I define the language in sonar-project.properties as "java" I get18:58:41.487 WARN: File '/home/hans/testcode/testproj/freemarker/template/SimpleHash.class' is ignored because it doesn't belong to the forced language 'java'Thank you!
Can I analyze only .class files wih sonarqube?
Remove the zero:"There was an error deleting id: {}"
I am getting aInvoke method(s) only conditionallywarning from SonarQube for the following code.void deleteMyTableRow(Integer id) { if (myTable.deleteById(id) != 1) { log.error(LogMessageBuilder .message( "There was an error deleting id: {0}", String.valueOf(accountId)) .cause("Some cause.") .effect("Some effect.") .solution("Some solution.") .build()); throw new UpdateFailureException("my_table"); } }I thought the issue is with how I was concatenating this initially. Initially it was"There was an error deleting id: "+id, but changing it to string format (as given in sonarqube docs for this warning) didnt help. Could someone point out what is wrong with this?The full message that SonarQube is showing me is here:https://rules.sonarsource.com/java/RSPEC-2629
Sonarqube: "Invoke method(s) only conditionally" cannot figure out the reason
The parameter you are passing to theRoslynSonarQubePluginGeneratorisn't quite right.You just need to pass the id of your NuGet package to the generator, not the full name of the package file e.g.RoslynSonarQubePluginGenerator /a:AnalyzerExampleIf there are multiple versions of the package, the generator will use the latest released version. If you want to pick a specific version, add a colon and the version to the command line e.g.RoslynSonarQubePluginGenerator /a:AnalyzerExample:1.0.6971.18074
I am trying to write custom rules in sonar for C#. After doing some research, got something on how to write rules and integrate with sonar. For the reference please look at the posthttps://stackoverflow.com/a/53889326/6499361.So basically we have to follow three steps to do so:Use Roslyn to Write a Live Code Analyzer.Building this project will generate a .nupkg fileUse the SonarQube Roslyn SDK to generate a custom SonarQube plugin that wraps the Roslyn analyzer.Running this tool will generate a jar. I am using RoslynSDK-2.0Use the generated jar file as a rule in Sonar, which could be integrated to sonar by using it as a pluginI have written analyzer code which works fine.I have the .nupkg file with me which is generated after building the project. Now I want to generate a plugin for sonar. So when I run the generator tool by following command:RoslynSonarQubePluginGenerator /a:AnalyzerExample.1.0.6971.18074.nupkgI get the following error:No packages with the specified id were found: AnalyzerExample.1.0.6971.18074.nupkgI have tried putting the .nupkg file at different locations, as mentioned in the following post:https://github.com/SonarSource/sonarqube-roslyn-sdk#configuring-nuget-feedsI have attached images, when I run Roslyn plugin generator.Screenshot of the error
Roslyn SDK cannot locate the nuget package locally
Add ipynb in next line as shown in image below.
I am using Sonarqube to scan my GIT repository , and have Installed a plugin called "SonarPython".It scans all python files (.py) but does not pick up any of the jupyter notebook with extension (.ipynb).Is this a right plugin to scan jupyter notebook ? Are there any other ways scan jupyter notebook in SonarPythonMy Sonar project file# must be unique in a given SonarQube instance sonar.projectKey=Python:KeyValueeeeeee # this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. sonar.projectName=Myproject 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=./ # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8Even added a setting on Sonarqube :
Sonarpython not scanning Jupyter notebook .ipynb
To answer your question, you can simply disable the rules you don't want in SonarQube, it's completely customizable to your needs.And as of v 4.3 of Spring, you don't even need to put the@Autowiredannotation if you have only one constructor, it is implicit,see Spring doc. So you only need this :@Service @RequiredArgsConstructor public class FooService { private final FooDAO fooDAO; }
For all my @Component and @Service, I use@RequiredArgsConstructor(onConstructor = @__(@Autowired)).It makes the code much cleaner an works just fine.But SonarQube only accepts this for components. All fields in the service classes have the critical issue:"Annotate this member with "@Autowired", "@Resource", "@Inject", or "@Value", or remove it."Is there a solution to fix it or a workaround? I don't want to disable the rule, because it helps sometimes.My code:@Service @RequiredArgsConstructor(onConstructor = @__(@Autowired)) public class fooService { private final FooDAO fooDAO; // Annotate this member with "@Aurowired"... // rest of the class }
SonarQube doesn't see @RequiredArgsConstructor for @Service, any advice?
The following solution isn't as elegant as I'd like, but the best I can come up with.Uselcovinstead ofgcovrto initially generate the coverage reports. This creates.infofiles whichlcovis capable of combining down to a single.infofile.Unstash all.infofiles from previous stages, then uselcov -ato combine them into a single.infofile. (Reference)Next, use thelcov-to-coberturaconverter to convert this.infofile into an xml file which can be reported to SonarQube.
I have the following Jenkinsfile:pipeline{ stages { stage ("Compile Everything") {/**/} // Code coverage flags turned on // Stashes compiled test binaries. stage ("Parallel Tests"){ parallel{ stage ("Run Tests A-L") {/**/} // These stages unstash and run groups of tests, stage ("Run Tests L-Z") {/**/} // causing coverage files to be created. // I analyze those coverage files via // gcovr and stash the results as xml. } } stage ("Combine and Publish Coverage") {/**/} // Here I can unstash all of the xml // code coverage files, but don't know // how to combine them. } }In that final stage, "Combine and Publish Coverage" is it possible to combine all of the xml files created by gcovr?Has anyone solved the problem of testing in parallel and combining coverage results in another way entirely?
Combining C++ Coverage Results from Parallel stages in a Jenkins Pipeline
Go toQuality Profiles>Profilethat you selected and search for the rule finally unchecked it. All as administrator
is there any regex or configuration that I can tell the sonarqube, not to consider the equal and hashcode methods in the analyze?
How to remove sonarqube equals and hashcode duplicate code validation?
The violation suggests that there is already a Functional Interface that can solve the purpose of what you're trying to implement using your custom interface i.e.BiFunction<T,U,R>.So at places where you're defining the methodmakeRESTServiceGetCallof yourXYZService, you can instead simply create aBiFunctionin your code as:BiFunction<String, Integer, XYZProfile> xyzProfileBiFunction = (string, integer) -> { return xyzProfile; // the GET call implementation using 'string' &'integer' };and then at places where you were calling the methodmakeRESTServiceGetCall, you can simplyapplythe above implementation as :XYZProfile xyzProfileNullPointer = xyzProfileBiFunction.apply("nullpointer", 0); XYZProfile xyzProfileParth = xyzProfileBiFunction.apply("Parth", 1);
I defined a functional interface with one method declaration, and the implementation of the method in a class of another project. SonarQube violation is that I am redefining a standard functional interface that is already provided in Java 8.@FunctionalInterface /*access modifier*/ interface XYZService { XYZProfile makeRESTServiceGetCall(String str, Integer id); } "Drop this interface in favor of "java.util.function.BiFunction<String,Integer,XYZProfile>"Drop this interface in favor of "java.util.function.BiFunction<String,Integer,XYZProfile>"The REST service GET call simply takes the inputs and returnsXYZProfile. Generally, the project structure requires the using interfaces, but to solve the Sonar violations shall I remove the 'interface', and change themakeRESTServiceGetCallmethod call to the bifunction syntax?
SonarQube Violation Java 8 Bifunction Requirement
It is possible. You just have to addsonar.jacoco.reportPathsparameter.Examples:SonarQube Scanner +sonar-project.properties:sonar.jacoco.reportPaths=/path/jacoco.exec,/path/another/jacoco.execGradle:sonarqube { properties { property "sonar.jacoco.reportPaths", "/path/jacoco.exec,/path/another/jacoco.exec" } }Maven:mvn sonar:sonar -Dsonar.jacoco.reportPaths=/path/jacoco.exec,/path/another/jacoco.execRead more here:Java Unit Tests and Coverage Results Import
I ran code coverage with jacoco(using javaagent)integrating it in startup.bat of tomcat and got jacoco.exec. I also got a html report for that.Now, I want code coverage in sonarqube. I ran sonar-scanner and got all the details except "Code-coverage".Is there a way to have Code-Coverage without updating the pom.xml? Or if I could have code-coverage in sonarqube using jacoco.exec?
Code Coverage with SonarQube integrated with Tomcat without Maven
curl --location 'https://<SonarToken>@<Sonar-end-point>/api/ce/component?component=<Component-key>' --header 'Content-Type: application/json'This will fetch you the latest task id of background tasksTake id from above response and pass it to task end pointcurl --location 'https://<sonar-auth-token>@<Sonar-end-point>/api/ce/task?id=<Taskid>' --header 'Content-Type: application/json'Sonar Version: 9.9
Our sonarqube server had 10+ pending tasks. I canceled one and now we can make tasks in the process.How can I know they are pending now, and how to confirm when to cancel them? Because we want to manage sonar's tasks by Web API, not manually.I find ataskIdthat I can use it to check the status of it. But how can I know thetaskIdwithout monitoring the console output of MAVEN BUILD?taskId:/api/ce/task?id=AVo_WHJYU5rNTJ7ZmiZqI tried to use thisapi/ce/componentto get the status, but sometimes when I useprojectKeyas a component parameter, I got"queue": []. I can't get JSON"current": {}. Why it's empty because theprojectKeyis the correct one?Another problem is how to configure the sonar.properties or etc? To make our sonar server, more stable (we only use one server, not cluster). Because I want to know why these tasks are pending.My problems are:I want to know how to check the status of a project task (taskId), then I can choose when and which one I need to cancel.I want to know how to config my sonar better for best stability, just like JVM setting? My server's memory is 4 GB.
Pending task in SonarQube & Stability config for Sonar
One possible difference could be the fact that in the second case you're limiting the metrics that are being considered bymetricKeys=sqaleIndex.
I am using SonarQube Version 7.2.1 and I have analyzed a Multi Module Maven Project.In order to retrieve all the project's open issues I call/api/issues/search?componentKeys=COMPONENT_KEY&ps=500&resolved=false. Then I sum-up either theeffortor thedebtproperty in order to calculate the amount of debt of the open issues. I get a total of:3704 mins.Later I realized that there is another endpoint namely: GETapi/measures/componentwhen I call it/api/measures/component?component=COMPONENT_KEY&metricKeys=sqale_indexthe amount of TD is different:3449 mins.Which of the above numbers is correct and why is there a difference?
Technical Debt measured by GET api/measures/component VS GET api/issues/search
First of, as stated by the report, you are missing all package-info.java files. See theGithub Repofor more information, especially theworkaround for missing package-info.java files.Secondly, you need to modify your Java quality profile to also include the jDepend rules. For this, go to Quality Profiles, clone the Sonar way rule set and than go to rules, filter forrepositoryjDepend. Bulk edit to include jDepend rules.In the end, you need to a new scan with the new rules and package-info.java files.
I have an existingJenkins-Sonarqubeintegration for daily sonar violation check usingSonarScanner. Recently there was a discussion toexplore a Project Dependency Diagram_on sonarqube, where I heard about JDepend plugin & tried integrating JDepend plugin in sonarqube and scanned the project.Looking into projects Jdepend measures shows 0 however there are 82 packages found - please find screenshot below : -Can someone suggest on this as I am completely new with project dependency graph or suggest any other plugin (open source/freeware) to achieve my requirement.Sonarqube: 5.6.4 JDepend: 1.1.1 Jenkins: 2.89.4
Sonarqube project dependency graph
I also faced same error:[error][SQ] API GET '/api/server/version' failed, error was: {"code":"UNABLE_TO_GET_ISSUER_CERT_LOCALLY"To fix this issue:First I installed Java 17 to devOps build agent machinehttps://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.htmlJava SE Development Kit 17.0.5 Windows x64 Installer. Installed path: C:\Program Files\Java\jdk-17.0.5Then add two devOps build pipeline variables: NODE_EXTRA_CA_CERTS and SONAR_SCANNER_OPTSSONAR_SCANNER_OPTS: Copy your cacerts and replace existing one. path: “…\Java\jdk 17.0.5\lib\security\cacerts”Then add both paths in devOps SONAR_SCANNER_OPTS variable:-Djavax.net.ssl.trustStore="C:\program files\Java\jdk 17.0.5\lib\security\cacerts" -Djavax.net.ssl.keyStore="C:\program files\Java\jdk 17.0.5\lib\security\cacerts"NODE_EXTRA_CA_CERTS: copy your cert *.PEM file and replace it the existing one in devops build agent path: C:\devOps_Agent\sonarchain.pemAfter this step SonarQube prepare starting to work.
Sonarqube error in VSTS Build when version 4 of sonar extension is used.Error -[SQ] API GET. '/api/server/version' failed, error was: {"code":"UNABLE_TO_GET_ISSUER_CERT_LOCALLY"} .SonarQube extension version 3 build runs successfully. We are usingSonarqube version 7.1
Sonarqube Error
Unfortunately, there is no way to restore the previous state. SonarQube allows to delete analysis result (Activitytab in 7.1), but all except the last. It means that you can fix statistics by removing accidental analysis, but you must fix issues statuses manually.
Accidentally changed the underlying branch for a sonar project and ran the analysis and now after reverting the to original branch, all the issues marked as wont fix are again show on the dashboard. Is there any option available in sonarqube to the previous state of the project which was working fine or any possible solution to restore the quality profile.
How to rollback to old analysis in sonarqube
It's not your fault.Please check following reply on GitHub -https://github.com/SonarSource/SonarJS/issues/1110Hello, as you note, this is just a warning and it can be safely ignored. We cannot fix this warning easily, because it's a dependency of our parser which would need fixing. However we started migration to another parser in 5.0 and gradually we will migrate all rules to the new parser. This will eventually allow to drop dependency on sslr and fix the warning
I try to analyse a .net project with jenkins & sonarqube. When I try to analyze the project localy on my workstation without jenkins the analysis works and the results are uploaded and displayed in sonarqube. When I use jenkins in combination with sonar msbuild and execute the very same cmd I get the error message: WARNING: An illegal reflective access operation has occurred WARNING: WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/C:/Users/xyz/.sonar/cache/132aaa5c3a6da2c09af83d327b1fc182/sonar-javascript-plugin-4.1.0.6085.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1 WARNING: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: WARNING: All illegal access operations will be denied in a future release WARNING: WARN: Analyzer working directory does not exist: 'D:\Jenkins\workspace\GLB\.sonarqube\out\2\output-cs'. Analyzer results won't be loaded from this directory.As far as I could see this is the only difference between the local working version vs. the not working version via jenkins.I already invested a lot of time in investigating and research but did not find a solution for that.kind regards
Jenkins & Sonarqube - Illegal Reflect
withless PATH_TO_YOUR_SONAR_LOGS/access.log | grep /api/ce/submityou should see the trigger from sonar - never the less not the call itself :(
I have integrated SonarQube into a Build Pipeline according to this:SonarQube DocumentationI am using SonarQube Scanner for Maven. The analysis works fine, the communication from Jenkins to SonarQube is okay.To break the build if a Quality Gate is failed, I use waitForQualityGate() as described in the documentation. This works, but only when I add a sleep statement before it.It seems, that the Webhook in SonarQube, is not working. The waitForQualityGate() Method waits forever.The Webhook which I have configured in SonarQube looks like this:http://<my-jenkins>/jenkins/sonarqube-webhook/I have used the configured Url to trigger the webhook manually using curl from the sonarqube server (I have manipulated the payload and added the related taskId which has been created by the build job in jenkins). The waitForQualityGate() Method retrieves the manually triggered webhook and everything works as expected.But SonarQube can not send the webhook request to Jenkins.I used the SonarQube Api to get more information:http://<my-sonar-qube>/sonarqube/api/webhooks/deliveries?ceTaskId=<task-id>There I can see, that the status is '403' and 'success=false'. But calling exactly the same url from the sonarqube server via curl succeeds.In which Jenkins and SonarQube logfiles can I find detailed information about the webhook request/response?Jenkins Version: 2.89.2 SonarQube Version: 6.7
Jenkins - SonarQube Integration: Webhook retrieves 403, where can I find logs?
You appear to want to regress your project landing page approximately 3 major SonarQube versions. That's simply not possible without starting over with a 3.x SonarQube instance.The standardized project homepage (your first screenshot) was introduced in the 5.x series, and customizable dashboards were dropped in 6.2. If you want the features of a modern version of SonarQube, you'll have to live with the benefits of the upgraded interface as well.
I need to change the Sonar Qube report theme. I have the default theme for the report but I want to customize it. Please find the attachment for demo purpose. I have report with theme like this:but I want to make it change like this:How can I do that?
How to change Sonar Qube theme
This case should be perfectly handled by SonarJava. Lombok annotations are taken into account at least since version 3.14 (SONARJAVA-1642). The issues you are getting are resulting from a misconfiguration of your Java project. No need to write any custom rules to handle this, this is natively supported by the analyzer.SonarJava reads bytecode to know which annotation are used. Consequently, if you arenot providing bytecode from your dependencies, on top of bytecode from your own code, the analyzer will behave erratically.In particular, setting propertysonar.java.librariesshould solve your issue. Note that this property is normally automatically set when using SonarQube maven or gradle scanners.Please have a look at documentation in order to correctly configure your project:https://docs.sonarqube.org/display/PLUG/Java+Plugin+and+Bytecode
import lombok.Data; @Data public class Filter { private Operator operator; private Object value; private String property; private PropertyType propertyType; }For code above there are 4 squid:S1068 reports about unused private fields. (even they are used by lombok generated getters). I've seen that some fixes related to support of "lombok.Data" annotation have been pushed, but still having these annoying false positives.Versions: SonarQube 6.4.0.25310SonarJava 4.13.0.11627SonarQube scanner for Jenkins (2.6.1)
Why does SonarQube consider a private filed as unused? [duplicate]
As Olaf points out: This question was also posted tohttps://web.liferay.com/community/forums/-/message_boards/message/104477676You could configure all the subprojects as a different SonarQube project with the following in yourbuild.gradle:subprojects{ sonarqube { properties { property 'sonar.projectName', "${-> project.name}" } } }You can also set the propertysonar.projectKeyor any other property fromhttps://docs.sonarqube.org/display/SONAR/Analysis+ParametersI took the idea of the lazily evaluated project name from:How can I make Gradle extensions lazily evaluate properties that are set dynamically by tasks?
I am working with Liferay DXP and I would like integrate SonarQube in my workspace, I am using gradle.My workspace is called: test-workpaceMy gradle.properies file (path: test-workspace/gradle.properties) is:systemProp.sonar.host.url=http://localhost:9000 systemProp.sonar.sourceEncoding=UTF-8 systemProp.sonar.forceAuthentication=true systemProp.sonar.login=<mytoken> # Definición de variables para el proyecto. description = 'Gradle - Sample Project' group = 'com.test.sonarqube.gradle' version = '1.0.0'My build.gradle file (path: test-workspace/build.gradle) is:buildscript { repositories { mavenLocal() jcenter() maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath group: "org.sonarsource.scanner.gradle", name:"sonarqube-gradle-plugin", version:"2.5" } } group = 'com.test.sonarqube.gradle' apply plugin: "org.sonarqube"When I execute "gradle sonarqube" all workspace is scanned but I would like to configure each modules like a project in SonarQube.Someone know how to configure gradle files to do it?.Thank you very much!
Configure gradle projects in SonarQube
Find Security Bugsis the plugin you are looking for.Find Security BugsThe FindBugs plugin for security audits of Java web applications.According to the authors it provides:Extensive references are given for each bug patterns with references to OWASP Top 10 and CWE.
I have checked OWASP in SonarQube, but I'm looking for other security metrics to test my proyects in java. I've already checked the Security option in Sonarqube, but it seems to be related to variable names and simple security rules, so maybe there's a security plugin that could help me.
How do I measure security in SonarQube 7.0?
If you have python tests, you can use coverage.py, it provides python code coverage that can be imported in SonarQube using SonarPython:Python Coverage Results Import.If you have java tests, you can use JaCoCo, it provides java code coverage that can be imported in SonarQube using SonarJava:Usage of JaCoCo with Java Plugin.If you have in the same project python+java code, coverage of both languages will be uploaded in SonarQube. But if you are looking for a coverage tool that support tests mixing java and python code, I mean initiating tests in one language and recording the coverage in both languages, this tool does not exist.
Devlopment stack is in Python (flask) and our automation suite(API) is coded in Java . So which is the best library can be used for code coverage
How to cover java test using Coverage.py library
Look at Project B/a.cs in SonarQube. The file header will show you the path as SonarQube understands it, e.g.:Use all or part of that path in your exclusion specification.
I'm using SonarQube (6.7 at the time of this writing) to analyze my C# solution. I'm now struggling with excluding files from duplication or full analysis.I can exclude files like:<Property Name="sonar.exclusions">**/*.Designer.cs</Property>or duplications like:<Property Name="sonar.cpd.exclusions">**/*.g.cs,Tests/UITest*.cs</Property>As I know, the exclusion pattern is relative to the root of the project.Now if I have the following setup:Project Aa.csb.csProject Ba.csc.csAnd I only want to exclude the filea.csfrom Project B but not from Project A.Addinga.csto the exclusions excludes it from both projects.The only way I found to do this is by using an absolute path like:file:C:/Development/Solution/Src/Project_B/a.csThis works but then I get a warning that using absolute filepaths (by using file:) is deprecated so this will get removed somewhen and therefore should not be used.I already tried using relative paths like:../Project_B/a.csOR./../Project_B/a.csBut that didn't exclude any file.Is there any non-deprecated way of removing a file only from one project?
How to exclude a project specific file in SonarQube
The formula to calculate code duplication isDuplicated lines (%) = Density of duplication = Duplicated lines / Lines * 100as per thedocumentation.You can configure the duplication rules yourself:This is also documentedhere.
I generally use SonarQube for performing static code analysis of on going projects to detect best pratice violations and possible anomalies.(Also using SonarLint plugin but it's out of scope.) I know that keeping duplication ratio as low as possible is important as having graded with A for Reliability, Security and Maintainability metrics. However, how much low is desired for a software project? SonarQube(Version 6.7.1 (build 35068)) usesthis matrixfor duplication ratio assesment.Searched for source of the values used in matrix and read all the web pages that come up in first 3 pages of searh results. However, all that I could find was related with how duplication ratio of SonarQube works and is configured, importance of keeping dupliation ratio low(any number is not mentioned) and SonarQube features that guides users on solving duplications.After not being able to find any results in SonarQube domain, I expanded my researches to learn what is desired and acceptable duplication ratio for a software. Again couldn't find any numbers except some sites that states it should be zero which seems some unrealistic to me.Could someone justify how the values used in matrix are decided? Why below 3 is graded as A, instead of 4?
How does SonarQube duplication ratio assessment/grading matrix decided?
I guess I found a way around this. I setup a rule like this in the quality gate:and added more code to the project without tests.Then I ran the analysis and my quality gate failed with following message:(Ignore the coverage on new code rule on the left)I think the key here was to set the "Over leak period" checkbox ticked
I need to create a sonarqube quality gate condition that fails a build if the code coverage drops from the last version. The leak period is now set as the 'previous_version'. I know that there was a delta analysis feature in the older versions of sonarqube. But I think this is no longer available.For example, in the previous build the coverage was 30% and in the current build it is 29%. So there is a drop in the overall coverage. In this case I need to fail the build. Again I cannot do absolute comparison(like Coverage < 30 etc.) because the coverage varies in different projects and I am doing a global configuration.I am using sonarqube 6.7 LTS Community versionIs this even possible? If not is there a different way?
Is it possible to create a sonarqube quality gate condition to catch reduction in the code coverage in latest sonarqube(Version 6.7)?
MariaDB is not supported by SonarQube, seerequirements.
I installed MariaDB with yum in CentOS 7.SonarQube throws this exception:org.sonar.api.utils.MessageException: Unsupported mysql version: 5.5. Minimal supported version is 5.6.When I reinstall MariaDB with version 10, SonarQube still throws the same exception.How does SonarQube-5.5 detect the MySQL version?The API of MariaDB 10 is compatible with MySQL 5.6 and CentOS 7 has replaced MySQL with MariaDB.Why does it not support MariaDB 10?
SonarQube is not starting [duplicate]
You can usePHPStanin your CLI, the same way you probably use coding standard checks or PHPUnit tests:vendor/bin/phpstan analyse src --level=0Set this in your pre/post-commit hook and you are ready to go. Read more inshort post about first install of PHPStan
We are running static analysis tests on two points:On Git pre-commit hook, and in that case we are using phpcs, phpmd, stylelint and eslint engines (vanilla installations + Drupal Coder for Drupal standards addition)Once in a week we are updating our project's dashboard on SonarQube, which runs the following quality profiles: Drupal (PHP), JS and SCSSWe want to align our standards to a single standard, but using different engines makes it much harder (or even impossible?). I can think of some possible ways to achieve that:Manually align the rules on both pre-commit and SonarQubeUse SonarQube for our pre-commit testsI'm not sure about that, since by looking at the Drupal standards at SonarQube, it seems like there are much less rules there than on the Drupal PHPCS standards (from Drupal Coder) -relevant question I found about it(also another relevant question about aligning SonarQube's PHP plugin with phpCS)Create a custom plugin for SonarQube with our engines set (no way..)The ideal solution in my way of thinking is to have SonarQube read the rules files (e.g. phpcs.dist.xml) in the Git repo just like most of the static analysis tools out there.I also saw theSonarQube and stylelint Rule Mapping- which is the only mapping I found about those engines.How can we overcome that issue in the simplest way?
Static analysis - SonarQube to test same standards as on Git pre-commit hook
I don't really have the answer for you, but I guess it might be worth looking more in depth at the Exceptions. I looked up the following definitions on docs.oracle.com:ExecutionException: Exception thrown when attempting to retrieve the result of a task that aborted by throwing an exception. This exception can be inspected using the Throwable.getCause() method.InteruptedException: Thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity. Occasionally a method may wish to test whether the current thread has been interrupted, and if so, to immediately throw this exception. The following code can be used to achieve this effect: if (Thread.interrupted()) // Clears interrupted status! throw new InterruptedException();That being said, maybe the nature of the ExecutionException means that we don't have to worry about catching the InteruptedException (since an ExcecutionException is thrown when mishandling another thrown exception). So maybe we try something like this:public void methodName() throws ExecutionException {}
I have a method likepublic void methodName() throws ExecutionException, InterruptedException {}SonarQube raises an issue on this method, suggesting to refactor this code.If I replace those exceptions withException(which both of them extend), then it says throwingExceptionis too generic.How can I resolve this issue?Exact sonarQube message: Refactor this method to throw atmost one checked exception instead of ExecutionException , InterruptedExceptionDetailed Hint by sonarQube:https://sbforge.org/sonar/rules/show/squid:S1160?layout=false
Refactor method to throw at most one checked exception instead of ExecutionException and InterruptedException
Just adding an answer here just in case someone may be interested.The approach I took was to mark all resurfaced debt aswon't fixand adding a specific comment to it (could possibly have used a tag too).Now that we changed to another leak period, I simply reopened all the issues with that specific comment and as expected they all got related to the old technical debt, not the new leak period.
We have an on-premises installation of SonarQube, and after upgrading from version 6.0 to 6.5 I noticed that several bugs and code smells as old as 2012 have resurfaced. I wasn’t expecting that to happen, as perSonarQube 6.3 release notes– see section“Remove noise on the Leak period for newly activated rules”.Since they are old and we have no plans to handle them now, they are impacting our gate status – which is currently red – and I don’t see how I can get rid of them in a proper way.I can think of two options:Shorten the leak period, which is not a good approach as existing valid smells in this leak period would be considered technical debt;Mark them as"false positive"or"won’t fix", which is also not a good idea as we would lose traceability of existing bugs and smells we could eventually plan to fix one day.In such cases, what's the best approach to be taken?
How should old resurfaced technical debt be handled within leak period?
The issue has since been resolved with a newer version of the scanner. It was a issue with that particular version of the scanner.
Recently I tried to update my SonarQube Scanner for MsBuild to v3 from v2 on my VSTS builds.1) I re-ran my VSTS Build to make sure it was still successful before making any changes and it ran without error.2) I updated the version of the scanner by just changing the version drop down in the task in VSTS [linked a image below of what I saw].3) Then I ran the build again and on my Build Solution step I got a error.This error had to do with trying to delete a file from the.sonarqube/outdirectory.Error MSB3061 : Unable to delete file "[filepath].sonarqube\out\f_AnyCPU_Release_[GUID]\ProjectInfo.xml". Access to the path '[filepath].sonarqube\out\f_AnyCPU_Release_[GUID]\ProjectInfo.xml" is deniedIt is possible the issue is with the double slash in the file path (\) but this was not happening before I updated the version of the scanner. Does anyone know what I can do to solve this issue?
Sonarqube scanner for Msbuild v3.0.1 causes issue with Build Solution in VSTS
With the new version of SonarQube 6.6, the problem seems to be fixed somehow. SonarQube Server is able to start now.
I have just installed SonarQube server on my Windows 8 computer according to "Get Started in Two Minutes" instructions. I have the latest Java (jre1.8.0_131) on my machine. I got an error at startup in web.log. How can i fix that?2017.07.17 05:24:33 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQubejava.lang.IllegalArgumentException: Custom Analyzer [ındex_words_analyzer] failed to find filter under name [word_filter]at org.elasticsearch.index.analysis.CustomAnalyzerProvider.build(CustomAnalyzerProvider.java:76)
SonarQube server does not start because of a Background initialization failure
This has now been fixed so you should see an error if run this way.Seehttps://github.com/SonarSource/sonar-csharp/issues/535
I'm trying to execute and report aSonarQube code analysis(without test coverage for now) against a.NET Coreproject from aLinuxbuild agent.I downloadedsonar-scannerfromthis page, and trying to run the report with the following command (the server url is set up in the configuration).sonar-scanner -Dsonar.projectKey="MyProject" -Dsonar.projectName="MyProject" -Dsonar.sources=$PWDThe execution seems to be successful, I uploaded the full output tothis gist.However, if I go to the project dashboard on the SonarQube site, I don't see any issues or code smells whatsoever.I wanted to make sure that my project contains at least one error, so I added agotostatement to one of the source files, and checked if that warning is enabled in our Quality Profile, but I still get no issue.(The sources files themselves are picked up correctly, I can see the list of files and all the source in SonarQube.)Am I doing something wrong, or is this not expected to work?(Just to clarify that this is not a duplicate of the existing question about .NET Core: the same command I showed here works for me on Windows, it only does not work on Linux.)
Can I run SonarQube code analysis for .NET Core (C#) on Linux?
In my recent experience this problem is caused by thejacocoTestReporttask writing its report into the same location for all flavors, with the result being that the last one is the only one present when thesonarqubetask runs. The source doesn't match up with the coverage report.
This question already has answers here:Sonarqube scan error with line out of range?(13 answers)Closedlast year.I'm sending reports to my sonarqube instance in order to analyse my code for testing coverage and quality/security issues.My project has 12 different flavours (12 different apps with the same core codebase). There are some classes in the flavour folders which replace the ones from the main folder.One class, named SignupFragment, resides in all the flavour folders, thus having 12 different versions.For this class, sonarqube task fails with this message:* What went wrong: Execution failed for task ':app:sonarqube'. > Line 30 is out of range in the file src/mama/java/com/giorgos/section/stampcard/ui/fragment/SignupFragment.java (lines: 6)Weird thing is that none of the flavours/versions of this class has 30 lines. The biggest one has 15 lines of code.Any ideas what is wrong ?I'm using Sonarqube 5.6.2 on a mac and sending my android code reports via a gradle task.PS: For now I added an exclusion rule to ignore this class, but I would like to figure out an actual solution.Edit: I tried with Sonarqube 6.3.1 and problem remains.Edit2: I'm using in Sonarqube the SonarJava plugin 4.5.0.8398 (the one that comes out of the box) and in mybuild.gradlethe gradle pluginorg.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2.
Sonarqube fails for classes in android studio flavour folders [duplicate]
Yes, NOSONAR issupported in version 2.9of SonarPLSQL. There's alsoa rule to track usages of NOSONAR.
How to suppress Sonar warning from PL/SQL inline code? For Java its simple, by using//NOSONARWill--NOSONARwork on PL/SQL Code?
Supressing Sonar issues on PL/SQL code
Binding to a project makes sense, because that's where you assign quality profileand other settingssuch as exclusions, that areproject-specific. So it is not devoid of sense.Binding to a Quality Profile could also be useful for some situations; perhaps you have a feature request there ;)(I realize I'm only addressing the primary question, the one that is featured in the title -- no good answer for the secondary question)
Very confused on how SonarLint works and keep running into issues between SonarLint in IntelliJ and SonarQube, maybe someone can offer some insight.First, I don't understand why are we binding the code to a project. From what I understand, all the rules are in a Quality Profile, wouldn't it make more sense to just bind to a quality profile rather than a specific branch of a project? Not sure if it's that our SonarQube was not configured with best practices, but anytime I want to ensure I'm using the correct rules, I have to go through a huge list of projects and branches in IntelliJ to bind to vs just going through only two quality profiles. Any reason why?In addition, my local IntelliJ plugin raises issues that's not even configured in the SonarQube server. I made sure I'm in connected mode and the binding was updated recently, but I keep getting these ghost rules. Ideas?
Why must we bind a Java project to a project in Sonar instead of the Quality Profile
The permission "Execute Analysis" is required to execute an analysis. In order to set credential to the scanner, you need to use sonar.login and sonar.password. For more information, please have a look at :Authorization :https://docs.sonarqube.org/display/SONAR/AuthorizationScanner parameters :https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
I'm frustrated with this problem, Our sonarqube server is behind http basic authentication and local runner fails with 401 error. Is it somehow possible to provide credentials to it? AOfficial docs shows how to provide sonarqube's internal user...http://www.it1me.com/it-answers?id=35790175&s=User%20talk:Omotecho&ttl=Authenticate+sonar-runner+via+basic+authany idea or experiences about it?
Authenticate sonarScanner via basic auth
All non-hidden measures (there are some metrics that are hidden either because they're deprecated or because they're calculated solely to feed other metrics) are displayed automatically in the Measures space.If you have a plugin that's creating Mutations Coverage metrics, those values should already be available. But such measures are not created by default.Tangential but relevant: SonarQube 6.2 consolidated coverage metrics into simply Coverage. Now you can feed as many coverage reports as you want, assuming the language plugin has been upgraded to support that, but the values are consolidated under the theory that by and large people don't carehowthe code is covered, onlythat it is.
In a quality gate, we are able to specify values for 'Mutations Coverage', that specify when a warning or error is generated. Is there a way to display the mutations coverage value.For example in theMeasures -> Coverage tab?This is where It coverage and the number of unit tests are displayed.Any suggestions would be most welcome
Can I display coverage metrics for mutation tests?
As I found out by talking to the developers of the Cxx-plugin it needs another plugin like cppcheck to have the bugs generated.
We have SonarQube 6.0 with Cxx (Community) 0.9.7-SNAPSHOT installed.Although we receive code smell issues the number of reported bugs is 0.Does anyone have a clue why that might be?Best regards Marc
Sonarqube with Cxx plugin does not show bugs only code smells
As far I know Once the job is complete, the plugin will detect that a SonarQube analysis was made during the build and display a badge and a widget on the job page with a link to the SonarQube dashboard as well as quality gate status.Please referthisand verify your configurations.
I use jenkins and sonar to analyze some projects. The sonar analyzing triggered over the groovy pipeline script with the following code:stage('SonarQube analysis') def scannerHome = tool 'SonarQube_Scanner_Prod'; sh "${scannerHome}/bin/sonar-scanner -e -Dsonar.host.url=... -Dsonar.projectKey=... -Dsonar.projectName=... -Dsonar.sources=... -Dsonar.projectVersion=..."This work fine. Now I want a link on the jenkins job page. To come to the sonar results on the server. After the sonar analysis run, the link is on the console. Can i add this link to the status page? Or add a link to the left menu? Thank you for help.
Show SonarQube result link on Jenkins Job page
No, JaCoCo does not record time.SonarQubereads time of execution of tests from reports generated by maven-surefire-plugin.
You can runJUnittests with theJacocoagent to produce wonderful coverage reports. (It produces an opaque*.execfile during the running of the unit tests).Some tools such asSonar- read the*.execfile and gather data to produce reports. Sonar is able to tell Unit test duration - but I'm not sure if it gets it from this*.execfile.My question is:Does Jacoco record unit test duration?(Regardless of whether it shows it in its generated report).
Does Jacoco record unit test duration?
The propertysonar.cs.msbuild.testProjectPatternhas been deprecated in Sonarqube 5.1 and removed in 6.7. SeePR 917 at sonar-csharp.Now Parametersonar.msbuild.testProjectPatternon the Client side should be used instead.
I've read some questions which answers mention that sonar.cs.msbuild.testProjectPattern is used by SonarQube to skip code analysis for Projects that match the pattern.Currently I have a big solution which one of it's projects contains "UnitTesting" as part of it's Name and also as part of the physical path.Example:The project name is something like "Something.MoreText.UnitTesting" (with a .csproj file name of "Something.MoreText.UnitTesting.csproj")The physical path is "C:\Something\Folder\Etc\UnitTesting"The default pattern is [^\]test[^\]$ which enforces 'test' being case sensitive.This project is getting excluded from analysis. I want to make sure I understand the reason why it is getting excluded. Other projects in the same solution are getting analyzed just fine.I want to understand how the usage of the pattern works. Does the pattern applies to the project name? to the project path in the disk? It is not case sensitive as it seems the default pattern is? Is there another reason my project is being excluded (we haven't added any explicit exclusion keys to the project files)?Note: I came across this articleDetection of Test Projects, there it saysProjects with "test" in their names.Some answers mention that it is the file path, some that it is the name, some that it is both...Environment: SonarQube 5.6.1, C# 6 projects. VS 2015 MSBuild 14, SonarQube Scanner for MSBuild 2.2, OpenCover, nUnit 2.3
How to use sonar.cs.msbuild.testProjectPattern
If you want to get major, minor, critical issues change below linequery.rules("Major","Minor","Critical");toquery.severities("MAJOR","MINOR","CRITICAL");
I need to write Java code which retrieves the issue list with full description from SonarQube. I used Sonar WS Client JAR to write following code but I get following error:java.lang.IllegalStateException: Fail to request 127.0.0.1:9001/api/issues/search?rules=Major,Minor,Criticalpublic class App { public static void main(String args[]) { try { String url = "http://127.0.0.1:9001"; String login = "admin"; String password = "admin"; SonarClient client = SonarClient.builder() .url(url) .login(login) .password(password) .build(); IssueQuery query = IssueQuery.create(); query.rules("Major","Minor","Critical"); IssueClient issueClient = client.issueClient(); Issues issues = issueClient.find(query); List<Issue> issueList = issues.list(); for (int i = 0; i < issueList.size(); i++) { System.out.println(issueList.get(i).projectKey() + " " + issueList.get(i).componentKey() + " " + issueList.get(i).line() + " " + issueList.get(i).ruleKey() + " " + issueList.get(i).severity() + " " + issueList.get(i).message()); } } catch (Exception ex) { System.out.println(ex); } } }How to get issue list using Sonar WS Client service?
How to get issue list using Sonar WS Client with Java code?
Roslyn analyzers can load parameters from files. This API is not too strict, meaning you can easily write an analyzer that requires a single file, multiple files, or whatever parameter loading that you can come up with. We haven't yet generalized this in the SonarQube Roslyn API, so there's no way to define additional files.However, you can set up your projects to use your stylecop.json the same way as you'd do without SonarQube being in the picture. Then the SonarQube Scanner for MsBuild will pull down the analyzer DLLs from the SonarQube server, add them to your project during build, and with the latest version it will not clear theAdditionalFilesproperty, so your stylecop.json will be passed to the analyzers.
I want to use the rules of the StyleCop analyzer for Roslyn in SonarQube, In order to do that and following the documentation founded, I downloaded the SonarQube Roslyn SDK, and I generate the plugin.In my development environment I have a JSON file (stylecop.json) that add configuration:{ "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", "settings": { "documentationRules": { "companyName": "XXXXXX", "copyrightText": " My Copyright (c) ", "xmlHeader": true, "fileNamingConvention": "metadata" }, "namingRules": { "allowedHungarianPrefixes": ["as", "do", "id", "if", "in", "is", "my", "no", "on", "to", "ui"] } } }This configuration works perfectly with VS2015, but when I run the analysis, the plugin does not get it, I am aware that I do not setup that file when I create the plugin. I am able to recreate the plugin, but how do I setup that JSON file for the plugin creation process?
How to set stylecop.json creating Stylecop Anayzers plugin for Sonarqube?
From a quick look at the source code (org/sonar/api/utils/XpathParser.java) it looks to me as if the application is using the JAXP service API to instantiate an XPath parser. See what happens if you(a) put Saxon on the classpath, and (b) set the value of the system property "javax.xml.xpath.XPathFactory" to the value "net.sf.saxon.xpath.XPathFactoryImpl"Note that step (a) on its own isn't enough, because Saxon no longer nominates itself as an XPath parser using the META-INF mechanism - this was causing too many problems with applications that were written to assume use of Xalan.This may or may not succeed in picking up Saxon, and if it does pick up Saxon, then it may or may not succeed in running it. There could be other problems - for example, I note that the XpathParser class in sonarqube creates a DOM with namespaceAware set to false, which isn't a good start.
I need to validate a rule over a xml and I need the regex feature, only found on XPath 2.0. I downloaded the last Sonarqube 6.1, but the XPath continue being the version 1.0. Is there a way to use version 2.0?
Is there a way to use xpath 2.0 on Sonarqube?
The preview mode does not do the calculations required to find new issues on coverage or duplications. The old issue you're seeing is pulled from the server.
Tried with sonar-scanner 2.5 & 2.8In the 'Rules' section of SonarQube, for JavaScript, I have Branch coverage and Line coverage. Branch coverage is a Minor, with a minimum coverage ratio of 65Line coverage is a Major, with a minimum coverage ratio of 70My code doesn't pass these rules when I run the full sonar over it and read the report on the server. But if I run it locally in preview mode,sonar_runner -Dsonar.analysis.mode=previewOn the console, it only reports a minor issue, and looking at the local HTML report, it shows files that are below the Branch coverage. But no major issues flagged, or no reference to files not passing the Line coverage.I read it doesn't support Quality Gates in preview mode, but it should support Rules, and the fact it reports on the Branch coverage, I'm not sure what has gone wrong. Is anyone else getting Line Coverage rule working in Preview mode?Any help appreciated, thanks
SonarQube Line Coverage Rule in Preview Mode
The root cause here is the using JUnit's assertThat method:import static org.junit.Assert.assertThat;Instead of Hamcrest's one:import static org.hamcrest.MatcherAssert.assertThat;I've recently faced theproblem with the same solution.
We are running Sonarqube 5.5 with Java Plugin 3.14 and analyze via sonar-maven-plugin version 3.0.2 calling "mvn clean deploy sonar:sonar".We still get violations "Add at least one assertion to this test case" about missing assertThat when test code contains stuff like the following.import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.assertThat; [...] @Test public void testByClassicCompare() throws InvalidPropertiesFormatException { final CompareFilter compareFilter = new CompareFilter("gid", 333, Operation.LT); assertThat(findAll(compareFilter), hasSize(1)); }findAll() is a method in the test class. It just calls some hibernate finder and returns a collection of objects:protected Collection<MyObject> findAll(final HbnFilter filter)Update: When we change the assert to the following, sonar recognizes the assert.assertThat(findAll(compareFilter).size(), eq(1));
Why are our Hamcrest assertions not recognized as valid assertions for rule S2699?
You need to provide full path to the .trx file. With below changes in begin analysis and try it again.Change/d:sonar.cs.vstest.reportsPaths=../TestResults/*.trxTo/d:sonar.cs.vstest.reportsPaths=../TestResults/Mytest.trx
Environment : SonarQube 5.6 - SonarQube Runner 2.4 - MSBuild.SonarQube.Runner-2.0 - TFS 2015 - C#6I've a Visual Studio 2015 solution with C# 6 projects and unit tests. On my TFS 2015 server, I define a build (task-based, not xaml). On my build, I've added the following steps : - SonarQube for MSBuild - Begin Analysis. - Visual Studio Test - SonarQube for MSBuild - End Analysis.Everything run fine (build, unit tests execution, code coverage, analysis results based on SonarLint, ... except that I don't see the tests results in the Sonar report (code coverage is there !).I've tried to add some parameters : - begin analysis : I've added : /d:sonar.cs.vstest.reportsPaths=../TestResults/*.trx - vstests console : /Logger:trxIn the end analysis logs, I see this :Attempting to locate a test results (.trx) file... Located a test results file: E:\agent_work\3\TestResults\tests_results_2016-06-23 14_07_22.trx Sensor org.sonar.plugins.csharp.CSharpUnitTestResultsProvider$CSharpUnitTestResultsImportSensor Sensor org.sonar.plugins.csharp.CSharpUnitTestResultsProvider$CSharpUnitTestResultsImportSensor (done) | time=0msAny idea why I see always Unit tests=0 in the Sonar report ?
C# unit test results in SonarQube 5.6
I think you would have considered below solution already, if not please go throw by below suggestion once and give a try :You can use the connected mode to bind your project in the IDE to a project inSonarQube.SonarLintwill use the same code analyzers and rules as the ones inSonarQube. InSonarQube, it's possible to change the quality profile assigned to projects andenable/disablerules also.More information:http://www.sonarlint.org/intellij/index.html#Connected
I have aSonarQubeserver up and running which has custom rules configured which needs to be reflected inSonarLint. I have run aSonarQubescan, and the projects are being shown inhttps://localhost:9000UI screen.lets come to theSonarLint. Without binding the project, I am getting issues as per default rules configured inSonarLint.But when I bind the module with theSonarQubeproject, issues are not showing up. Its not even single violation in any one of class.Please guide me to use the feature.
How to use SonarLint connected mode for custom configured rules in STS
You can use a sonar-project.properties file for configuration. There are some example projects provided bySonarSourcethat might be helpful.Here's a quick example of how you could set the source directory, test directory, and files to ignore:sonar.sources=client-app/src sonar.tests=client-app/test sonar.exclusions=client-app/node_modules, client-app/libUPDATE:The sample projects have movedhere. There isn't a JavaScript example anymore, but the syntax would be the same for any language.The documentation for parameters that can be set is currently located here:https://docs.sonarqube.org/display/SONAR/Analysis+Parameters
I installed the TSLint plugin for sonarqube in my Jenkins serverhttps://github.com/Pablissimo/SonarTsPlugin. But its not described the git page as to how to set the configuration properties and values. How to specify the source directory, how to ignore test directory are two main concerns. Can some one provide an example configuration property set with basic configurations that I can use in my Jenkins?
How to configure the TSLint plugin for sonarqube in Jenkins?
Take a look into this topic (and answer):SonarQube how to create Profile and import new rules to itYou can import the rules simply by using the class RulesDefinitionXmlLoader with the method load like this:RulesDefinitionXmlLoader.load(repository, new BufferedReader(newInputStreamReader(ruleset.xml)));Hope it helps to get you going.
I have a ruleset.xml file with custom PMD rules. How do I use this file in SonarQube 5.5?
How do I use a custom PMD rule in SonarQube 5.5?
As Susheel Rao commented on his question, MySQL 5.5 is no more supported by SonarQube 5.5. Workaround is to downgrade to SonarQube 5.4 or to uprade MySQL.
I am trying to setup Sonar in my localsystem and I have done creating the MY SQL DB , after that I also created Default sonar schema too. Now while starting my Sonar Server ... I get this Exception,2016.05.18 15:17:37 INFO web[o.a.c.h.Http11NioProtocol] Starting ProtocolHandler ["http-nio-0.0.0.0-9000"] 2016.05.18 15:17:37 INFO web[o.s.s.a.TomcatAccessLog] Web server is started 2016.05.18 15:17:37 INFO web[o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000 2016.05.18 15:17:37 WARN web[o.s.p.ProcessEntryPoint] Fail to start web java.lang.IllegalStateException: Webapp did not start at org.sonar.server.app.EmbeddedTomcat.isUp(EmbeddedTomcat.java:84) ~[sonar-server-5.5.jar:na] at org.sonar.server.app.WebServer.isUp(WebServer.java:48) [sonar-server-5.5.jar:na] at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:105) ~[sonar-process-5.5.jar:na] at org.sonar.server.app.WebServer.main(WebServer.java:69) [sonar-server-5.5.jar:na]I cant see any other issues at my logs can you help me .Below are my versions ,Java : JDK1.7SonarQube : 5.5Mysql : 1.2.16
java.lang.IllegalStateException: Webapp did not start at SONARQUBE
Problem solved by making maven ignore the jar in cleaning phase.
I'm currently using sonarqube LTS(4.5.7) with Findsecbugs plugin installed.The problem is when running mvn clean install with sonar profile the build fail and it says :Failed to clean project,failed to delete C:..\myproject..\findsecbugs.jarso it's clear that the findsecbugs.jar cannot be removed in the cleaning phase i've done some research and it seems that Java process is locking the resource. Is there anyway to solve the problem knowing that if I kill the Java process it will stop mvn Build.PS: I cannot move to the latest version of sonarqube since generating issues report in publish mode is no longer supported.
findsecbugs sonar plugin maven build fail
Nope.You've actually listed two goals in your question:analyze multiple projects in a single run.view multiple projects in a single, aggregate dashboard.The first is not possible. The second is, but to accomplish it you'll need to analyze each project individually, then aggregate them using the commercialViews Plugin.
I want run Sonar onMultiple Project (Not Multiple Module)in single run(All are Java projects).For Ex: I have the Folder structure as belowRootFolder|--- Project1 |--- Project2 |--- Project3I want to run Sonar on Project1,Project2 and Project3 in single run.For Ex: If i run Sonar on 'Rootfolder' report should be generated for all project(Project1,Project2 etc..) and in sonar dash board should be single entry with all project inside that.I used sonar-runner but it runs on individual Project Level ,But i need at root level so that in single run i get the resultIs there any way to achieve this?
Running SonarQube on Multiple Project (Not Multiple Module)
For Maven or Ant steps, you need to set the variables to point the scanner to the sonarqube server.For Standalone, you can define the sonar server installation directly.Instructions
I'm trying to configure code quality check with SonarQube in Jenkins. I've added in Jenkins Sonar - plugin and configured it in Manage Jenkins - Configure system - MSBuild SonarQube RunnerBut when I try to buid my project with Jenkins, I get the error:FATAL: No SonarQube installation assigned for this job. There are 0 available installations that can be configured. If you want to reassign a lot of jobs to a different SonarQube installation seehttp://docs.sonarqube.org/display/PLUG/Reassign+Jobs+to+Another+SonarQube+InstanceBuild step 'Invoke Standalone SonarQube Analysis' marked build as failure channel stoppedEDITThe page cited in the error message has moved. The new URL is:https://docs.sonarqube.org/display/SCAN/Reassign+Jobs+to+Another+SonarQube+Instance
FATAL: No SonarQube installation assigned for this job. There are 0 available installations that can be configured
Use a version of c# plugin not dependant/utilise sonarlint, I used 3.3, problem is that it is an older version, so not up to date with the latest rules.
I am trying to analyse a c# project using sonarqube, but I keep on getting an error saying that sonarlint is not a valid win32 application, what is the reason for this?[15:51:01]: [Step 1/3] 15:51:01.807 INFO - Sensor FileHashSensor... [15:51:01]: [Step 1/3] 15:51:01.838 INFO - Sensor FileHashSensor done: 31 ms [15:51:01]: [Step 1/3] 15:51:01.838 INFO - Sensor org.sonar.plugins.csharp.CSharpSensor@375465a1... [15:51:02]: [Step 1/3] INFO: ------------------------------------------------------------------------ [15:51:02]: [Step 1/3] INFO: EXECUTION FAILURE [15:51:02]: [Step 1/3] INFO: ------------------------------------------------------------------------ [15:51:02]: [Step 1/3] Total time: 26.359s [15:51:02]: [Step 1/3] Final Memory: 53M/1397M [15:51:02]: [Step 1/3] ERROR: Error during Sonar runner execution [15:51:02]: [Step 1/3] INFO: ------------------------------------------------------------------------ [15:51:02]: [Step 1/3] ERROR: Unable to execute Sonar [15:51:02]: [Step 1/3] ERROR: Caused by: java.io.IOException: Cannot run program "X:\xxxx\xxxx\xxxx\xxxxxx\.\.sonar\SonarLint.Runner\SonarLint.Runner.exe": CreateProcess error=193, %1 is not a valid Win32 application [15:51:02]: [Step 1/3] ERROR: Caused by: Cannot run program "X:\xxxx\xxxx\xxxxx\xxxxx\.\.sonar\SonarLint.Runner\SonarLint.Runner.exe": CreateProcess error=193, %1 is not a valid Win32 application [15:51:02]: [Step 1/3] ERROR: Caused by: CreateProcess error=193, %1 is not a valid Win32 application
sonarlint.exe is not a valid win32 application
Upgrade to the latest release version of SonarQube. Before SonarQube 5.2, a database connection was established from the analysis machine to the database, and there werea lot of round-tripsto upload the analysis results.Since 5.2, the analysis machine zips the analysis results and sends it to the server, which will process it and store it in the database in a much more optimized way.Also feel free to investigate and report what the bottleneck is once you're on the latest released versions and if you still face performance issues.
Currently I have an instance of SonarQube 5.1.2 with C# plugin and MSBuild runner in order to analyze a 1.200.000 LOC project, the analysis is taking between 16 and 20 hours. Digging into the logs, the building process (including the execution of test) takes about 2 hours, starting from there, SonarQube start its analysis.SonarQube is setup as it comes out of the box, it is installed in a machine with 8Gb in RAM, 4 processors. Usually, the analysis process only uses 20% of the CPU and 1.5 GB of RAM.What actions should I take to reduce the analysis time?
SonarQube with C# plugin with MSBuild Runner takes a lot of time
If you only want one subdirectory scanned, then simply setsonar.sourcesto that path.
Hi I want to exclude sonar scans everything except a sub directory in Js how can I achieve thisI tried the following but it is excluding everythingsonar.exclusions>/js//*
Exclude everything from the sonar scan except one of its subdirectories
Sorry, metrics are not stored at that level.
I am exporting the Java data from Sonar via the Web Service /api/resources as described inhttp://docs.sonarqube.org/pages/viewpage.action?pageId=2752802.Can I obtain the metrics at the method level?For example, the complexity is also available as "function_complexity", but this is the average per class of the complexity of all methods. This average is rather meaningless as typically the few high values of the really complex methods are combined with the many low values of all getters and setters. Therefore, I want to obtain the complexity of each method, or at least all methods with a complexity that exceeds a certain limit.I had expected some qualifier related to methods, like "MTH", but I cannot find anything similar.
Metric values at method level
That was a temporary production issue. It's fixed now. Sorry for the inconvenience.
I cannot access the "InstallingSonarQube" link in the docs.sonarqube.org page, and the url is:http://docs.sonarqube.org/pages/viewpage.action?pageId=6951188i tried to sign up, after login with this account, the docs server tips Not Permmited.anybody knows why?
sonarqube cannot access the online help and tips log in
try putting //NOSONARFor example : public partial class MyClass//NOSONARSimilar thing to skip the rule isheretoo
We using SonarQube 5.2, the RuleRedundant modifiers should be removeddoes not working correctly.The class is defined in multiple files, therefore it be has declared aspartial, but SonarQube mark this as bug.Has anyone an idea to fix this?
"partial" is gratuitous in this context using SonarQube 5.2
Try to filter jacoco coverage reportas explained in this post.In your first report (java coverage), you'll have to exclude groovy packages, in the second (groovy coverage), java packages.As far as I know there is no better way to do it.
I need to execute the Gradle cobertura plugin twice with different settings for one execution of the sonarqube plugin. The reason for needing to execute twice is that the coverage analysis for Groovy and Java need to be in separate report files. Java and Groovy have separate properties for Sonar to say where the report file is for the respective language (sonar.cobertura.reportPathandsonar.groovy.cobertura.reportPath). The reason I cannot leave the analysis in the same file is because the upload to Sonar fails complaining about duplicate metrics. Which I imagine is because of the same file getting read once by the Java plugin and once by the Groovy plugin.Therefore, from what I can see, I need acoverageGroovy.xmland acoverageJava.xml. So far, I have not found a way to do this in Gradle.Any ideas are appreciated.(One idea I had was to use JaCoCo for only the Java tests, but I did not see a way to limit JaCoCo to only the Java files.)
Gradle - Need to execute Cobertura twice w/ diff settings back-to-back for Sonar reporting
IID 8.5.5 runs on Eclipse Helios 3.6.3 .. you need to find a plugin version which is compatible with this Eclipse version.You can also install Eclipse Market Place into IBM Integration Designerhttp://www.eclipse.org/downloads/download.php?file=/mpc/releases/1.0.1/mpc-1.0.1.zip
I am trying to configure SonarQube Plugin with IBM IID 8 as its based on Eclipse I thought i will be able to configure it easily with SonarQube, but its not working. I try to find out on IBM website but not have any luck.Can somebody tell me if there is anyway to do this?
IBM Integration Desinger 8.x has a plugin for SonarQube
Afaik you can't force SonarQube to reload the page after each job. You have to do this by yourself.Prior to 5.2 you could use the BuildBreaker Plugin, to handle quality gate violations. Unfortunately I don't know a solution for this in 5.2+ :(
I have some continious Integration running with Jenkins and some quality analysis with Sonar and Checkstyle.I want to display them in real time in my open space.My problem is when Jenkins run a new job, it update the Sonar analysis, but the sonar dashboard does not move. and we have to refresh the page (F5) in order to display the new analysis.How can I force the sonar web page to refresh after each job ?(using sonar 5.2)And how can I set the Jenkins build instable when the quality is below a gate ?(or when I have more than x mjor issues ?)For Jenkins, no problem : we will use the monitor view plugin
Auto-refresh for SonarQube Dashboard
I was able to solve it with the answerhere, but the person who asked that question didn't accept it and is not responding.
When trying to deactivatecommon-java:InsufficientBranchCoverageI'm getting an error:Quality profile not found: java-sonar-way-03260Nothing appears in the logs.I can deactivate other rules without problem but this one just gives an error.Possibly duplicate of:SonarQube: Cannot deactivate rule with missing quality profile
Unable to deactivate a particular rule -- Quality profile not found
As of today there are no way to configure the rule about method naming convention for native methods and classics java methods.So your best course of action would be either to improve the regexp of the naming convention rule to accept the native methods naming convention or mark issues on native methods aswon't fix
I have used JNA to call functions from a C library. But the class names in the C library start with simple letters and some of the structure names as well. These are causing sonar qube to report naming convention issues which are "major". Is there any way I can handle this naming issues without deleting the rule from sonar qube? Are there any way to map the native methods without using the same name as in the C library?
How to adjust jna native classes and functions to adhere to java naming conevntions?
TheJIRA Pluginis not compatible with JIRA 7 or newer (does not support REST).FromSonarQube Wiki:Jira 3.x supported by 1.0, 1.1, 1.2Jira 4.x supported by 1.0, 1.1, 1.2Jira 5.x supported by 1.0, 1.1, 1.2Jira 6.x supported by 1.2There is an issue about support REST API intracking system.
I am trying to connect my SonarQube installation to JIRA 7.0.2 for issue linking. I have filled the configuration fields (Files attached), but I get the error, impossible to connect to JIRA server. Both JIRA and SonarQube are on the same server.
SonarQube cannot connect to JIRA 7 with REST API
i've asked a similar question about the technical debt pyramid, that show debt by charasteristic and here is the answer:sonarqube how to access to default technical debt pyramid values from web service api?i think that the only way to access to these information its using the payed plugin (sqale).
Is there a way to retrieve the characteristic of a metric of a project over time? For instance TESTABILITY is a characteristic of the metric "squale_index". Squale Index can be retrieved for each project using the /api/timemachine interface. However I could not find a reference to filter it in the api documentation. Is there another way?
Sonarqube timemachine API and metrics characteristics
Cloning or duplicating a project is not supported.You can use theTime machine functionalityof SQ to "recreate" the past analyses of the project under another name but it won't recreate the history of changes on issues.
I have one Project in SonarQube with some history and some Confirmed Issues and I need split this project, because of two versions of source code, but I need the history and Issue changes in both projects. How to do this? It is possible somehow clone, duplicate existing Project to another one with different name?
How clone duplicate existing project in SonarQube
The 1.5.1 update fixed this issue for me.https://jira.sonarsource.com/browse/LDAP-49
I've been trying to configure Sonar with Active Directory for a while with no luck so I was really excited to see the new LDAP 1.5 plug-in. Unfortunately it's still not working for me but it's so close! The lookup is successful but then something fails:DEBUG web[w.s.NegotiateSecurityFilter] logged in user: CORP\My.UserName (S-1-5-21-1305660829-1405082133-723345943-15257) DEBUG web[w.s.NegotiateSecurityFilter] roles: CORP\My.UserName, CORP\Domain Users, Everyone, BUILTIN\Administrators, BUILTIN\Users, NT AUTHORITY\NETWORK, NT AUTHORITY\Authenticated Users, NT AUTHORITY\This Organization, [etc.] INFO web[w.s.NegotiateSecurityFilter] successfully logged in user: CORP\My.UserName DEBUG web[o.s.p.l.w.s.s.SsoAuthenticationFilter] Validating authenticated user DEBUG web[http] GET /sessions/new?return_to=%2F | time=1527ms ERROR web[rails] Error from external users provider: exception Java::Com4j::ComException: 80040e37 (Unknown error) : A referral was returned from the server. DEBUG web[http] GET /ldap/validate | time=1738msThis was with the Negotiate protocol but I got the same error using the default NTLM protocol as well. Running Sonar 5.2.
Error using Active Directory in SonarQube
By default the SonarQube Maven plugin will only index what Maven consider as source folders (iesrc/main/javaandsrc/test/javafor a JAR project).If you want to have files insrc/test/resourcesindexed you have to override default configuration either on command line or in yourpom.xml.Try:mvn sonar:sonar -Dsonar.tests=src/testOr add:<properties> <sonar.tests>src/test</sonar.tests> </properties>in yourpom.xml
I have a fewMavenprojects with packaging equal toJAR(example:EasyBundle). Unfortunately I cannot seeJava Properties PluginQuality Profile at project dashboard after analysis:My project contains*.propertiesfiles insrc/test/resources(seesources). How can I activateJava Properties Pluginduring the MavenJARproject analysis?
How to activate Java Properties Plugin during the Maven JAR project analysis?
This is being enabled by GitLab version 8.13.8-ee via UI, found in Project settings.Seehttps://git.dev.eon.com/help/user/project/merge_requests/merge_when_build_succeeds#only-allow-merge-requests-to-be-merged-if-the-build-succeedsfor more information.
I am using GitLab, Jenkins and SonarQube. All tools are withFreelicences.Currently we are having a need to implement more strict control over Git(Labs) Merge Request functionality based on "external" tools / plugins.I am now trying to figure out how to implement the behaviour that would do the following:listen to Jenkins Job build resultwhile GitLab has no result from Jenkisn Job, button "Accept Merge Request" is disabled.once the result is recieved and it is Positive ( Thumbs Up icon ), button gets enabled.
Disable "Accept Merge Request" button based on GitLab CI status and/or SonarQube results
The log is telling you that the user the SonarQube platform is running as doesn't have the permissions it needs to update sonar.log. This can happen ifYou've got some wacky "security" or encryption program "helpfully" closing down perms on files/directories on the box (I've experienced this one)The SonarQube platform is running as a different user than the one you expect, i.e. some default "services" user, and that user doesn't have permissions on the file (experienced this one too).You need to:Check the SonarQube service user to make sure it's the account you expectedEdit the permissions on the log directory to make sure perms are granted recursively to the service userNote that this manual permissions granting isn't a long-term fix since when you upgrade, it will be by expanding the zip for the new platform version into a new directory. The safest thing to do long-term is make sure the service runs as a user that has adequate permissions on the box - either by swapping the service to a new user or by updating the service user's groups.
I downloaded sonarqube-5.1.2 and tried to run StartSonar.bat, then I got this error message:C:\>Startsonar.bat wrapper | --> Wrapper Started as Console Unable to open logfile ..\..\logs\sonar.log: Access is denied. (0x5) wrapper | Launching a JVM... Unable to open logfile ..\..\logs\sonar.log: Access is denied. (0x5) jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org Unable to open logfile ..\..\logs\sonar.log: Access is denied. (0x5) jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. Unable to open logfile ..\..\logs\sonar.log: Access is denied. (0x5) jvm 1 | Unable to open logfile ..\..\logs\sonar.log: Access is denied. (0x5) wrapper | <-- Wrapper Stopped Unable to open logfile ..\..\logs\sonar.log: Access is denied. (0x5)I checked logs file in sonarqube-5.1.2 and this file is empty. Anyone download sonarqube-5.1.2 and has an empty logs file? Could this be the reason that I got the error message? How to solve this problem?
why running sonarqube-5.1.2 Startsonar.bat give error messages?
You don't provide any information about which version of SonarQube nor Jenkins you are using.Still, I can answer your question regarding how Jenkins CI and SonarQube work together.The basic idea is the following:Jenkin's Job checks out your project from Version controlit then runs a local process (either a Sonar Runner task or a maven task, which uses Sonar Runner under the hood) which will analyse the projectdepending of the version of SonarQube you are using, the local process communicates either only with the SonarQube instance over HTTP(s) (in version SQ 5.2+) or also with the database used by the SonarQube instanceproject configuration, plugins and other meta stuffs are exchanged from SQ to the process local to Jenkinsthe result of the analysis (ie. issues, unit tests coverage, ...) and source code are exchanged from the local process to the SQ instance (and the Database)So if your project is 1Gb big, then it will be a problem regarding SonarQube only if you have 1Gb of source code. If it was really the case, I doubt the SQ-Jenkins integration would be your first concern.
I have a SonarQube server running in a different machine than Jenkins CI, my question is, Does SonarQube import the complete projects from Jenkins server or just use the reference? Because I could have a project of 1GB and it could makes low the connection, Can someone explain me? Thanks!
SonarQube and Jenkins implementation
According tothread from 2012it should be available. However that link is dead.The sonar issuesSONARS-46andSONARJS-182tell us that JSDocs from JavaScript are analyzed by SonarQube, but may still be a bit buggy.There are abunch of bugsreferring to comment-handling that are currently being worked on and should go live with 2.8 ofsonarjs.
Can Sonarqube take into account JSdoc from Javascript files ?We have many javascript source files analyzed by Sonarqube but the "Documentation" metric remains at 0.The "comment" metric shows the right value but it's not the case for the Documentation metric.
Is JSDoc supported by sonarqube?
Do you refer to the Camel routes as you want some kind of analysis of those? As Apache Camel is just regular Java code, then any regular SCA tools you can useThere is a good list on wikipediahttps://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysisThat said we are working on a "code/route coverage" tool that you run as part of unit tests, and then it can report which parts of your Java or XML routes have been covered or not. That work is still ongoing, you can follow the ticket:https://issues.apache.org/jira/browse/CAMEL-8657
Iam trying to implement static code analysis for Apache Camel not only for java but also XML based DSL.Is there any SCA Tool available?
Static code analysis apache camel Spring dsl
Try to set an absolute path to your .trx file to start with, then make it relative, then use wildcards.I suspect that no .trx file is matching the pattern you are giving, which is why nothing is shown in the logs.Once the .trx file is successfully located, you will seeParsing the Visual Studio Test Results file ...appear in the logs.
I’m trying to import trx test result files into SonarQube, therefore I have added the linesonar.cs.vstest.reportsPaths=../../TestResults/*.trxto the properties file. Unfortunately I cannot see any test results in Sonar. I have executed sonar-runner with the “-X -e” option but I cannot see any useful information in the log. I have searched for "trx" and "vstest". Nothing. Can someone tell me where I can find some more information on what’s going wrong?Here is my setup:sonar runner 2.4sonar server 5.1C# plugin 4.0Analysis Bootstrapper for Visual Studio Projects 1.2Thanks for your help!
Sonar runner does not import trx test result files
This is a known limitation of the current architecture. It should be addressedin a near future.Note that direct manipulation of the database is not recommended, this will introduce inconsistencies and make your instance unusable (especially due to the use of ElasticSearch for issues since SonarQube 5.0).
We are using SonarQube 5.1.1 and are analyzing some old legacy projects.The problem is that we get a huge number of issues and would like to bulk change all of them as False/Positive and start from zero issues so we only get new issues and old ones that pop up again.Is there a way to bulk change more then the basic 500 issues? If not in the web UI which tables in the database do we need to modify except the issues table?
How to bulk change more then 500 issues at the time in SonarQube
The rule "Sections of code should not be commented out" could be simply disabled in the quality profile related to your project.
Our organization is using SonarQube for managing code quality as well as Docco for handling production of documentation from code comments.We're running into a conflict between including things like method names in comments for Docco and the 'Sections of Code should not be "commented out"' rule in SonarQube.Are there any known best practices to get SonarQube to ignore code in comments that are for documentation (even better if for Docco in particular) while still catching old code that has been commented out instead of being removed?
Hiding Commented code for Docco from SonarQube review
I solved the problem by updating the java plugin to 3.5
I want to use SonarQube to analyse my project which is built on Jenkins. In my project I have some literals written in binary system (e.g. 0b00001111).When I'm trying to do an analysis, I am obtaining fallowingerror:[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project org: SonarQube is unable to analyze file : 'whatever': For input string: "b00001111" -> [Help 1] [...] Caused by: java.lang.NumberFormatException: For input string: "b00001111" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Long.parseLong(Long.java:589) at java.lang.Long.valueOf(Long.java:776) at java.lang.Long.decode(Long.java:928) at org.sonar.java.checks.SillyBitOperationCheck.evaluateExpression(SillyBitOperationCheck.java:101) ....Versioning informations:SonarQube Jenkins plugin version: 2.2.1SonarQube version: 5.1SonarQube maven Plugin version: 2.5/2.6 (I've tried both of them)In project I am using JDK 1.8. I don't know how to check if SonarQube is using also 1.8, but I've choosen "Inherit from Project" in SonarQube configuration panel in Jenkins.
SonarQube error while analyzing code with binary literals
I would recommend you to learn a bit about developing plugins for SonarQube because the question you asked is very generic and so extense to answer. Here are some links to get some information about the development:http://docs.sonarqube.orghttps://deors.wordpress.com (sweet intro tutorial)The plugin you want to seems pretty simple so easy to implement. The main class that you should have to work on is theSensor, where you would like to create issues referring the code-files and the lines on it.
I am trying to develop a plugin for Sonar which can get input from some third party API and get some results, Third party API will give me details such as Line number and file name, I want to put a link to that file and line on sonar widget, Can anyone help me, how can I create a link to particular file and line on Sonar widget
Sonarqube Plugin development
You can try to mark it as a false positive. Here is a description of how to do this:http://docs.codehaus.org/display/SONAR/Reviewing+Issues#ReviewingIssues-Markinganissueasfalsepositive
In my class I have logger likeprivate static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(Myclass.class);While running sonar qube I am getting error like:Malicious code vulnerability - Field should be package protected- A mutable static field could be changed by malicious code or by accident. The field could be made package protected to avoid this vulnerability.How to fix this?
Malicious code vulnerability - Field should be package protected. How to fix this sonar issue?
it is not supported for your version of Bamboo. Its a open source plugin so you can pick it up, work on it and make it compatible with your Bamboo verison
I have Bamboo version 5.2 configured on my local system.I want to install a sonarqube plugin in my bamboo instance. I found a plugin for version 5.1, but was unable to find a plugin for version 5.2.From where do I get the appropriate plugin and how to configure the sonar runner task with it?
SonarQube Plugin for Bamboo
Some more information could be useful. E.g.: what SonarQube and SonarRunner versions are you running.Findbugs is one of the few analyzing plugins that need .class data for analyzing the project. So if you have not changed the directory within your build.xml the ant task may search within the default output folder location.Please make sure your .class files are located here. To make them appear here you have to compile them before of course
I am doing a Sonar analysis of my project on a Jenkins Server using SonarRunner within an ant build. Unfortunately, the Analysis crashes with the following lines:[sonar:sonar] 11:29:57.008 INFO - Execute Findbugs 2.0.3... [sonar:sonar] 11:29:58.217 DEBUG - Release semaphore on project : org.sonar.api.resources.Project@5c1f0a26[id=3998,key=<key>,qualifier=TRK], with key batch-<key-batch> [sonar:sonar] 11:29:58.247 DEBUG - To prevent a memory leak, the JDBC Driver [com.mysql.jdbc.Driver] has been forcibly deregistered BUILD FAILED <Path>: The following error occurred while executing this line: <Path>: org.sonar.runner.impl.RunnerException: Unable to execute SonarI have other projects running on the same server, which have no problem performing this analysis (and where the analysis is triggered exactly the same way). As you can see, I changed the log level to DEBUG, but, nevertheless, I get no stack trace and I am not able to find useful information in the logs of Jenkins or Sonar. One other thing, I tried, was to increase the Heap space (with -Xmx) for this ant task in Jenkins but that didn't help either.Are there any other settings I can take to get useful information or does somebody know about this problem?Thanks!
SonarRunner crashes due to Findbugs
Have a look to the following "/api/resources" web service documentation :http://docs.codehaus.org/pages/viewpage.action?pageId=229743280
I'm using the (deprecated) CSV Plugin in SonarQube to create some analysis. Is there a way to get the same information by using the web api ?"same information" means in my case:FullClasspath | Metric 1 | Metric 2 | ... | Metric n----------------------------------------------------------org.myClass1 | Value 1 | Value 2 | ... | Value norg.myClass2 | Value 1 | Value 2 | ... | Value norg.myClass3 | Value 1 | Value 2 | ... | Value nWhat I need is a combination ofgetting all Metricsandreceiving all "Classes"instead of Issues.I'd like to use SonarQube now and in the future. This is why I'd prefer to alter my setup to use the Web Api.Best RegardsEDIT: Solution The request I have to send at my sonar server has this structure:SERVER/api/resources?resource=COMPANY:PROJECT&depth=-1&metrics=ALLNEEDEDMETRICSfor example:http://nemo.sonarqube.org/api/resources?resource=org.codehaus.sonar:sonar&depth=-1&metrics=ncloc,complexity,class_complexity,violations_density,duplicated_blocks,ca
How to use webapi to get similar results like CSV Plugin
The answer has been posted in this Question. Please change the network settings for eclipse for SOCKS proxy in manual connectionHow do I have to configure the proxy settings so Eclipse can download new plugins?
I can not set up the sonar qube plguin in eclipse. i have installed it via the eclipse marketplace. After this, in the eclipse settings there are config options for the server, default ishttp://localhost:9000but if i click "Test Connection" then i get an error "Unable to connect."after this i change the address to the ip address like this:http://192.169.172.30:9000but i get the same error. so i search on so and try some of the suggestion, i change the network settings in eclipse like in the answer here:https://stackoverflow.com/a/4596181/1809221but this doesn't work. Any other suggestions?My Settings: OS: Mac OSX Eclipse: Kepler Sonar Version: 3.3.0Thank's in advance.
Eclipse Plugin Sonar Unable to connect
TheIssues Report Plugincan give you such kind of report.But such report is static and you'll completely miss the ability to drilldown and navigate through the sources.
How can I get a sonar report of all issues by severity and description, e.g.:Critical wtf 11 wtff?? 3 Major foonly 12 Minor silliness 17 ...So far I have come up with using the Sonar web services to get a list of issues and then processing that with JQ. It seems that there should be an easier way.==== Further description ===I have legacy code with 6000+ sonar issues, I don't want to navigate to the individual files. I want a summary so I can decide out what to fix and what to leave. What I really want is a query language that will produce a custom report, or a simple description of the DB schema so I can use SQL and get a flat table that I can further process as needed, not PDF or HTML or XML or JSON.
sonar issue count by description (message) and severity
Apparently you need to reduce the amount of loops (or general complexity) in your static method. Checkthis pull requestfor what I did: move lots of stuff from the static initializer into methods; after that, findbugs runs perfectly.
I am getting following error during analyzing our code by findbugs in sonar:> Iterative jump info converged after 24 iterations in > static <methodName>, size 4535When I run findbugs analysis locally or in Jenkins there is no error and also findbugs report 0 violations. However if I run findbugs analysis of the code in sonar, it reports violations which are excluded by findbugs-exclude.xml.Could anybody advice what can causing this error or what it really means? I was able to find the relevant piece of findbugs code producing itherehowever it is getting no sense to me.Thanks in advance
Iterative jump info converged error during findbugs analysis in sonar
I copy my root-pom to the directory containing the source-directories. You could also try copying the pom from maven-build to the directory containing "src". In that way, "[...]/src/x/y/Z.java" would be within basedir.pom.xml src/ maven-build/
I have a (big) maven project with many modules which looks like this at the topsrc/ maven-build/src contains the tree with all the Java sources. maven-build contains the tree with all the pomsI can build everything fine with Jenkins, but when I add a Sonar analysis triggered through maven, Sonar complains that[...]/src/x/y/Z.java is not in basedir [...]/maven-buildI already tried copying the Java files to the maven-build directory, but this doesn't help...Is there a way to change the basedir on Sonar? Or can I solve this in a different way?
Jenkins + Sonar + Maven with poms in extra directory structure
The objective of SonarQube is not to run your unit tests, especially when the configuration is not standard. For you information, our long-term goal is to remove such a feature and only allow one mode: reuseReports.Therefore you should run your unit tests first and reuse those generated reports while running the SonarQube analysis. Seehttp://docs.codehaus.org/display/SONAR/Code+Coverage+by+Unit+Tests+for+Java+Project#CodeCoveragebyUnitTestsforJavaProject-ReusingExistingReports.
My Maven project has multiple surefire executions configured to make sure different test groups get rund with slight modifications to the classpath etc. (see thepom.xml). When running the build job, the tests are executed as expected.The build job running the Maven Sonar plugin only runs the default test execution and skips the other test configurations which effectively leads to Sonar reporting 0% test coverage. How can I tweak the Maven Sonar plugin to not skip the additional test executions. The relevant section from the log ishere, the full loghere.I'd be interested in why the additional executions are skipped as well.
How to prevent SonarQube from skipping additional surefire executions?
Definition of complexity on wikipediahere.Complexity basically means how many actions your program performs proportional to the input. Usually it's calculated from your loops or the depth of your recursive functions.Examples:This has a complexity of O(n) because the actions in the for-loop are executed n times.for (int i = 0 ; i < n ; ++i)This has a complexity of O(n^2)for (int i = 0 ; i < n ; ++i) for (int j = 0 ; j < n ; ++j)This also has a complexity of O(n):void recursion (int level, int n) { if (level < n) recursion(level + 1, n); }Update:Reading your comment, I think you're referring to Cyclomatic complexity, you can read about ithere.There's a fairly good explanation in the Description section, but to be honest, I've never used / heard of this kind of complexity.
This question already has answers here:What is a plain English explanation of "Big O" notation?(43 answers)Closed10 years ago.As the title say: I don't know the meaning of "complexity"When I visit a web page of sonar result I would very much want to know how to calculate it.
What's the meaning of "complexity" - how do I calculate it? [duplicate]
I saw this error when the database is empty (no tables are created). Usually tables are created during first start of sonar.Can you reach sonar by web interface?Make sure that settings in yourconf/sonar.propertiesfile inSonardirectory are correct, these lines should be uncommented.sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true sonar.jdbc.username: mysqlusername sonar.jdbc.password: mysqlpasswordThen check if yourconf/sonar-runner.propertiesfile insonar-runerdirectory has the same settings.#----- MySQL sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8 #----- Global database settings sonar.jdbc.username=mysqlusername sonar.jdbc.password=mysqlpasswordAlso make sure that the line for default embeded database is commented.#sonar.jdbc.url: jdbc:h2:tcp://localhost:9092/sonar
I need helpFirst , it throw exceptioncannot load class 'com.mysql.xxx.JDBC'",so I copy the sonarqube-4.0/extensions/jdbc-driver/mysql/mysql-connector-java-5.1.26.jar to the /usr/lib/jvm/java-7-sun/jre/lib/ext/Then I runsonar-runneragain, it throws this exception:Unknown database status: FRESH_INSTALLMy heart is broken , plz help me
When run "sonar-runer" throw exception :"Caused by: Unknown database status: FRESH_INSTALL"
Your issue here is that all your tests are in error. Therefore, it is normal that the coverage is 0% because nothing is properly covered. Check the log to understand why all your tests are in error.
I configure sonar with jenkins,i build the maven project in jenkins it builds successfully but in sonar always shows code coverage blank.what can be problem please help me....this is sonar dashboard. code coverage
sonar doesn't show up code coverage
In the web UI (while logged in as an admin user), go to Settings -> General and make sure the URL listed under Server Base URL starts with "https". This can also be set in the server's sonar.properties file using sonar.core.serverBaseURL
I have configured Sonar webserver to have all of the requests to go through Microsoft IIS server. It was confirmed to work fine with requests via http protocol.However, once the https was enabled, after successful login, Sonar webapp is trying to redirect to non-https url, causing it to timeout. If I then go and change the url to go to https, it shows as authenticated and continues to work as normal.The same issue happens when you trying to logout - instead of redirecting to https page, it goes out to http.What needs to be done to make Sonar post-login action to use the same protocol via which the login page was requested originally?sonar.properties has:sonar.web.host: 127.0.0.1 sonar.web.port: 9000 sonar.web.context: /sonarIIS plugin has:<VirtualHostGroup Name="default_host"> <VirtualHost Name="*:80"/> <VirtualHost Name="*:9443"/> <VirtualHost Name="*:443"/> <VirtualHost Name="*:9000"/> </VirtualHostGroup> <ServerGroup Name="sonar_group"> <Server Name="sonar_server"> <Transport Hostname="127.0.0.1" Port="9000" Protocol="http"/> </Server> </ServerGroup> <UriGroup Name="sonar_host_URIs"> <Uri Name="/sonar*"/> </UriGroup> <Route ServerGroup="sonar_group" UriGroup="sonar_host_URIs" VirtualHostGroup="default_host"/>Thanks.
Running Sonar behind Microsoft IIS with SSL enabled fails to redirect to https after successfull login
Never mind found the JDK option under Advanced in the Jenkins configuration for the job.
We have a server that runs Sonar and previously only had Java 6 installed and everything worked fine. We now have a Java 7 project and are encountering the "Unsupported major.minor version 51.0" version when the Maven surefire plugin tries to analyze the project.Is there a way to specify the Java version sonar should use for a specific project?Java 7 is already installed on the server.Thanks in advance!
Can sonar build java 6 and java 7 projects on a single server?
About the first warning message this is not an error but a warning : since Sonar 3.5 this is possible to get the code coverage relating to each unit test. Here the message just says that this feature is not activated which is expected by default. Nevertheless I do agree that this warning message can be misleading.About the second error message, I don't know the doxygen plugin but the message seems to be pretty clear : the sonar.doxygen.deploymentPath property has not be defined. See the plugin documentation :http://docs.codehaus.org/display/SONAR/Doxygen+Plugin.
Maybe, this question is silly but I'm very new. I try to search without luck.I got two errors when building maven project with sonar:No information about coverage per test.Although I had test code and these testing classes cover the code.The global property 'sonar.doxygen.deploymentPath' is not set. Set it in SONAR and run another analysis.I dont know it should be set where in sonar server. I set in web.xml or sonar-server.properties but it does not work.Thanks.
set configuration properties in sonar
No, this can be achieved the way you're doing it. And you would advise you not to continue in this direction, as creating an "aggregator POM" is a just a workaround which has many side effects in Sonar.The correct way to achieve what you want is to analyse each project independently and to create views & sub-views to aggregate all the information the way you want. For this, you need theViews Plugin.
I have a question regarding sonar analysis with maven.I have a group of projects built by maven, and a handy pom files to aggregate the projects together, so that I can run one maven build for all projects.I also would like to run sonar analysis against the aggregated pom. The analysis is done without errors, the only problem is the aggregated result: even though I run the analysis against the aggregated pom, I would like to get individual analysis result for each projects instead an aggregated report. Is there any configuration/argument to achieve this?Thanks a lot.
SONAR analysis against multi module projects
The problem is that FindBugs treats unannotated items as if they were annotated with@Nullablewhich causes it to ignore nullness checks against them. You can create an emptyjava.utilpackage annotated with a custom@ReturnValuesAreCheckForNullByDefaultannotation (modify@ReturnValuesAreNonnullByDefault), but it will apply toeverymethod ineveryclass in that package.@ReturnValuesAreCheckForNullByDefault package java.util; import edu.umd.cs.findbugs.annotations.ReturnValuesAreCheckForNullByDefault;Another option is to createMapfacade that has uses [email protected] class AnnotatedMap<K, E> implements Map<K, E> { private final Map<K, E> wrapped; @CheckForNull public E get(K key) { return wrapped.get(key); } ... }Update:See myprevious answerto a similar question for complete details on implementing this advice.
Let's say I have a block of code like this:Map<String, Object> mappy = (Map<String, Object>)pExtraParameters.get(ServiceClientConstants.EXTRA_PARAMETERS); if (pSSResponseBean!=null) { mappy.put(AddressResearchContext.CSI_RESPONSE_BEAN, (AddressNotFoundResponseBean)pSSResponseBean); // this line may throw null pointer }Is there a Sonar, Findbugs, or PMD rule that will flag "mappy" as potentially null? Apparently CodePro flags this, and I need to provide something similar, if possible.
Is there a Sonar, Findbugs, or PMD rule that detects this possible NPE that CodePro detects?
This happens when you have 2 or more projects with same name. Rename your projects to have distinct names will help.In your case, Sonar specifically indicates that the project nameNet:DistanceConverteris confusing.
ello, I am doing my code analysis through sonar runner previously I am getting the following error.when I run teh command ofsonar-runnerAny help???SonarException: Can not add twice the same measure on org.sonar.api.resources.Project Exception in thread "main" org.sonar.runner.RunnerException: org.sonar.api.utils.SonarException: Can not add twice the same measure on org.sonar.api.resources.Project@549154f9[id=22,key=DistanceConver ter-Net:DistanceConverter,qualifier=BRC]: org.sonar.api.measures.Measure@70d1a353[id=<null>,metricKey=profile,metric=Metric[id=144,formula=<null>,key=profile,description=Selected quality profile,type= DATA,direction=0,domain=General,name=Profile,qualitative=false,userManaged=false,enabled=true,origin=JAV,worstValue=<null>,bestValue=<null>,optimizedBestValue=false,hidden=false,deleteHistoricalData=f alse],value=5.0,data=Sonar way,description=<null>,alertStatus=<null>,alertText=<null>,tendency=<null>,date=<null>,variation1=<null>,variation2=<null>,variation3=<null>,variation4=<null>,variation5=<nu ll>,url=<null>,characteristic=<null>,personId=<null>,persistenceMode=FULL] at org.sonar.runner.Runner.delegateExecution(Runner.java:288) at org.sonar.runner.Runner.execute(Runner.java:151)
sonar runner cannot add the same measure
I had a similar problem, for me it was caused by a bug in the sonar-jacoco-plugin. Version 1.2 had a bug so that it only included the first binary directory.This is fixed in version 1.3 of the sonar-jacoco-plugin.Seehttp://jira.codehaus.org/browse/SONARJAVA-164for details.
I am using Sonar 3.2 + Java 1.6 + Ant 1.7 0 JBoss 1.5. We have many Java projects and Ant compiles them into one build project which also contains the .ear file, java classes, etc. I have started JBoss server by giving the JaCoCo agent as a parameter to the JBoss JVM. Looking at the jacoco.exec file with a text editor, it contains traces from all our Java projects (as expected).However, when importing the jacoco.exec file into Sonar, it only displays IT code coverage for one of our java projects. In the Sonar Ant configuration I include all our project java source and class files. These seem to be imported fine since violations are displayed for all java sources.What could be wrong? Btw. what files does Sonar compare the jacoco.exec coverage file against, java source files or compiled class files? I have included both though...
JaCoCo successfully profiles all Java projects, Sonar only finds coverage in one
Window -> Show View -> Maven Repositories. Selectglobal repositories->central. Use the context menu to force an update of the index for that repository (it might even start updating automatically, just when you open that view).
Failure to find org.apache.maven.plugins:maven-resources-plugin:pom:2.5 inhttp://repo.maven.apache.org/maven2was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
Failure to find resource plugin in m2eclipse?
You have to activate theSonar C# Gallio Pluginin order to get those metrics. This plugin will launch the projects that contain unit tests and will report the metrics in Sonar. You can take a look at this example application to see how it works:https://github.com/SonarCommunity/sonar-dotnet/tree/master/tools/dotnet-tools-commons/src/test/resources/solution/ExampleAs for the metric meaning, you can check the following page to know more:http://docs.codehaus.org/display/SONAR/Java+Metric+Definitions#JavaMetricDefinitions-Tests
We have no following metrics into History table in sonar:New CoverageNew line coverageNew lines to coverOther metrics are collected, as Code coverage, Coverage on new code, etc.Could you please suggest:What should be add to configuration to enable with metrics? and if it is possible, is it described anywhere how exactly with metrics (New Coverage, New line coverage, New lines to cover) collected and calculated?thank you,
sonar new line coverage metric for C#