nongrata081 / devkit

development kit for dev workflow optimisation
0 stars 0 forks source link

Add schematics for sonarqube #33

Open nongrata081 opened 5 years ago

nongrata081 commented 5 years ago

Sonar

Use sonar-scanner-npm

Examples

sonar modules & languages example config

nongrata081 commented 5 years ago

https://www.npmjs.com/search?q=keywords:sonarqube

https://www.npmjs.com/package/sonarqube-scanner https://www.npmjs.com/package/sonar-scanner

https://docs.sonarqube.org/latest/analysis/languages/javascript/ https://arjunphp.com/how-to-integrate-sonar-for-a-node-js-project/ https://www.ryandoll.com/post/2018/3/25/sonarqube-docker https://stackoverflow.com/questions/45237660/error-while-execute-npm-run-sonarqube-scanner-node-command

nongrata081 commented 5 years ago

Angular code coverage with Sonarqube

https://yuriburger.net/2018/09/24/getting-coverage-reports-with-angular/ https://community.sonarsource.com/t/is-sonarqube-server-6-7-3-supporting-npm-angular-jenkins/4789 https://github.com/yuriburger/ng-sonar-demo https://thecodebuzz.com/continuous-code-quality-in-angular-7-applications-using-sonar/ https://www.sparkbit.pl/sonarqube-full-stack-project/ https://www.youtube.com/watch?v=z7ipHJvEs6o

nongrata081 commented 5 years ago

Instructions (mac)

(according to medium article "Angular code coverage with Sonarqube")

  1. Install latest java

You should get something like:

java: 12.0.1,69cfe15208a647278a19ef0990eea691
https://www.oracle.com/technetwork/java/javase/
/usr/local/Caskroom/java/12.0.1,69cfe15208a647278a19ef0990eea691 (64B)
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/java.rb
==> Name
OpenJDK Java Development Kit
==> Artifacts
jdk-12.0.1.jdk -> /Library/Java/JavaVirtualMachines/openjdk-12.0.1.jdk (Generic Artifact)
  1. Download, install and run sonarqube (stackoverflow)

  2. Add npm script to run sonar scanner to your package.json. For direct usage of sonar globally:

"scripts": {
    "sonar": "sonar-scanner"
}

or in case of using npm-package wrapper for sonar locally:

{
  "scripts": {
    "sonar-scanner": "node_modules/sonar-scanner/bin/sonar-scanner"
  }
}
  1. Add sonar configuration file sonar-project.properties to root of your project
    sonar.host.url=http://localhost:9000
    sonar.login=admin
    sonar.password=admin
    sonar.projectKey=test-app
    sonar.projectName=test-app
    sonar.projectVersion=1.0
    sonar.sourceEncoding=UTF-8
    sonar.sources=src
    sonar.exclusions=**/node_modules/**
    sonar.tests=src
    sonar.test.inclusions=**/*.spec.ts
    sonar.typescript.lcov.reportPaths=coverage/lcov.info