sonarqube

Solution for Magic Number issue…?

瘦欲@ 提交于 2021-02-08 02:59:20
问题 Consider the following code segment... public static UserStatus getEnum(int code) { switch (code) { case 0: return PENDING; case 1: return ACTIVE; case 2: return SUSPENDED; case 3: return DELETED; case 4: return LOGIN_DISABLED; default: return null; } } Now number 3 and 4 in cases(case 3 and case 4) are detected as magic numbers by SONAR. To avoid that issue I changed my code segment as follows... public static UserStatus getEnum(int code) { final int Pending=0; final int Active=1; final int

SonarQube cannot parse TEST-report.xml which contains any failures

萝らか妹 提交于 2021-02-05 10:40:01
问题 How to send the XML report to SonarQube? I mean, while the TEST-report.xml file contains any failures, the import operation fails. I got an error: Running SonarQube using SonarQube Runner.17:18:18.452 ERROR: Error during SonarScanner execution java.lang.NullPointerException at java.text.DecimalFormat.parse(DecimalFormat.java:2030) at java.text.NumberFormat.parse(NumberFormat.java:383) ... The TEST-report.xml file (JUnit) contains something like: <?xml version='1.0' encoding='UTF-8'?>

SonarQube cannot parse TEST-report.xml which contains any failures

你离开我真会死。 提交于 2021-02-05 10:39:24
问题 How to send the XML report to SonarQube? I mean, while the TEST-report.xml file contains any failures, the import operation fails. I got an error: Running SonarQube using SonarQube Runner.17:18:18.452 ERROR: Error during SonarScanner execution java.lang.NullPointerException at java.text.DecimalFormat.parse(DecimalFormat.java:2030) at java.text.NumberFormat.parse(NumberFormat.java:383) ... The TEST-report.xml file (JUnit) contains something like: <?xml version='1.0' encoding='UTF-8'?>

How can I mark this line in HTML file to be ignored by sonar rules?

隐身守侯 提交于 2021-02-05 08:37:30
问题 I have a scenario where there is an AEM template file and in this file, I have a single <li> element. In other words, I have a loop inside that generate a list of items. <template data-sly-template.step> <li data-sly-use.localStep="MyAdapter" data-sly-test="${(wcmmode.edit && localStep.start) || !wcmmode.edit}" But, the Sonar's rule RSPEC-1093 is complaining that: "<li>" and "<dt>" item tags should be in "<ul>" , "<ol>" or "<dl>" container tags. In this case, is not a bug, once that the <ul>

Sonarqube indicates violation of csharpsquid:S3649 - User-provided values should be sanitized before use in SQL statements

落花浮王杯 提交于 2021-01-29 18:45:15
问题 In a sonarqube scan of our code, I have a number of violations of csharpsquid:S3649 - User-provided values should be sanitized before use in SQL statements. I think that my code is compliant, can anyone else shed some light as to why this is flagged as non-compliant? string connectionString = DatabaseContext.GetiXDataConnectionString(); string sql = "SELECT UserID FROM SystemUsers " + "Where WindowsLogonName = @WindowsLogon and DomainName = @WindowsDomain and " + "[Disabled] = 0"; using

SonarQube + Jacoco Coverage Discrepancies

六月ゝ 毕业季﹏ 提交于 2021-01-29 17:57:06
问题 I have been using Jacoco to analyze the Code-Coverage of my team's maven project for almost 3 months now. It has been analyzing and increasing properly as we add more and more tests and everything has been working well. In the last few days we have begun trying to set up a SonarQube analysis of the project. The issue we are running into is that the coverage shown in SonarQube is drastically different from what Jacoco is displaying for us. I have looked into this already, and read about some

How to view the SonarQube full analysis report in the build summary in Azure DevOps?

喜夏-厌秋 提交于 2021-01-29 17:56:52
问题 Not able to view SonarQube results in the Azure DevOps build summary. I have added code coverage unit test task in the build.yml for my .netccore and framework component but when I try running the build its showing the code coverage for unit test tasks only.I am not sure how to check the full analysis including code smells and how many lines covered and quality gate result as well in the azure devops build summary itself.Due to some challenges I couldn't able to loginto my SonarQube machine

Jenkins: org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube

爱⌒轻易说出口 提交于 2021-01-29 17:35:17
问题 Using sonar-scanner failed with an ERROR, although the Get bootstrap completed step ran successfully before. Seeing org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube More details: /opt/sonar-scanner/bin/sonar-scanner -X -Djavax.net.debug="ssl,handshake" -Dsonar.projectKey=project-header-forwarding -Dsonar.projectName=project-header-forwarding -Dsonar.projectVersion=0.0.80 -Dsonar.sourceEncoding=UTF-8 -Dsonar.host.url=http://my-sonarsystem:9000 -Dsonar

Sonarqube quality gate status check fail in Jenkins pipeline

假装没事ソ 提交于 2021-01-29 15:53:13
问题 Im new to jenkins pipeline scripting and sonarqube. it would be great if I can get some help with the question below. I want to fail the Jenkins declarative pipeline job when quality gate check fails. As per sonar documentation (https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-jenkins/#header-6), I tried with below two scenrions but both are seems not working and failing with errors. sonarqube analysis is working fine but it failing at QualityGate check. I created webhook in

Selecting Quality Gate for SonarQube Analysis in Jenkinsfile

只愿长相守 提交于 2021-01-29 10:58:12
问题 I have a Jenkinsfile that, among other things, performs SonarQube analysis on my build and passes it through 'Quality Gate' stage. The analysis is placed on the SonarQube server where I can see all the details. The relevant pieces of code for the analysis and Quality gate are below (not mine, it is from documentation): stage('SonarCloud') { steps { withSonarQubeEnv('SonarQube') { sh 'mvn clean package sonar:sonar ' } } } stage("Quality Gate") { steps { timeout(time: 15, unit: 'MINUTES') { //