Sonar Config
-
.Jenkinsfile config
stage('SonarQube analysis') { steps { script { scannerHome = tool 'SonarScanner4'; } withSonarQubeEnv('SonarQube') { sh "${scannerHome}/bin/sonar-scanner" } } }
-
sonar-project.properties
sonar.projectBaseDir=test-app // app dir sonar.projectName=test-app sonar.projectKey=test-app sonar.projectVersion=1.0 sonar.sourceEncoding=UTF-8 sonar.language=js sonar.sources=src sonar.tests=test sonar.exclusions=test/**,node_modules/**,build/**,**/less/**,**/config/**,**/config.js,**/imgs/** // files not to test sonar.test.inclusions=test/shared/*.js,test/components/**/*.js // files to test sonar.javascript.lcov.reportPaths=coverage/lcov.info //coverage path sonar.testExecutionReportPaths=coverage/test-report.xml //unit test path
-
package.json
"eslint-plugin-sonarjs": "^0.3.0", "jest-sonar-reporter": "^2.0.0", "jestSonar": { "reportPath": "coverage", // same with path in sonar-project.properties file "reportFile": "test-report.xml", // same with path in sonar-project.properties file "sonar56x": true // to get coverage data for sonarQ 5.6.*
}
-
jest.config.js
module.exports = Object.assign(jestConfig, { coverageThreshold: { global: { branches: 95, functions: 95, lines: 95, statements: 95, }, }, testResultsProcessor: 'jest-sonar-reporter', });
-
.eslintrc
{ "parser": "babel-eslint", "extends": [ "plugin:sonarjs/recommended"], "plugins": ["sonarjs"], "rules": { "eol-last": ["error", "always"], "sonarjs/cognitive-complexity": ["error", 25], "sonarjs/no-duplicate-string": "off", "sonarjs/no-identical-functions": "off" } }
fiels:
来源:oschina
链接:https://my.oschina.net/u/4400254/blog/3453613