• sonarqube-jenkins-config


    Sonar Config

    1. .Jenkinsfile config

       stage('SonarQube analysis') {
           steps {
             script {
               scannerHome = tool 'SonarScanner4';
             }
             withSonarQubeEnv('SonarQube') {
               sh "${scannerHome}/bin/sonar-scanner"
             }
           }
         }
      
    2. 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		
      
    3. 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.*
      

      }

    4. jest.config.js

       module.exports = Object.assign(jestConfig, {
        coverageThreshold: {
           global: {
             branches: 95,
             functions: 95,
             lines: 95,
             statements: 95,
           },
       },
         testResultsProcessor: 'jest-sonar-reporter',
       });
      
    5. .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:

    1. jest-sonar-reporter

    2. eslint-plugin-sonarjs

    3. sonarqube file

  • 相关阅读:
    Spring--之旅
    体验 Windows 系统 CVM
    基于 CentOS 搭建 WordPress 个人博客
    Codeforces Round #316 (Div. 2)
    BZOJ 1048 [HAOI2007]分割矩阵
    BZOJ 1047 [HAOI2007]理想的正方形
    BZOJ 1045 [HAOI2008] 糖果传递
    BZOJ 1042 [HAOI2008]硬币购物
    BZOJ 1030 [JSOI2007]文本生成器
    BZOJ 第二波刷题开始喽
  • 原文地址:https://www.cnblogs.com/weilantiankong/p/11231750.html
Copyright © 2020-2023  润新知