1.0.6 • Published 2 years ago
sonarqube-compare v1.0.6
sonarqube-compare
With sonarqube-compare, you can compare your new branch against the target branch's coverage and issues in detail.
Note: sonarqube-compare doesn't generate test coverage reports; it uses the sonarqube server API to obtain them.
Installation
sonarqube-compare runs on Node.js and is available as a NPM package.
npm install sonarqube-compareor
npm install sonarqube-compare -gUsage
To generate the comparison of your code coverage between two branchs, you need to provide these parameters for the sonarqubeCompare function: sourceBranch, targetBranch, component, token, host and metrics. The metrics parameter is optional, it would be set to ['uncovered_lines', 'uncovered_conditions'] if you don't provide it.
const {sonarqubeCompare} = require('sonarqube-compare');
sonarqubeCompare({
sourceBranch: 'develop',
targetBranch: 'master',
metrics: ['uncovered_lines', 'uncovered_conditions'],
component: 'your_project_key',
token: 'token',
host: 'https://sonarqube.example.com',
}).then(s => console.log(s));Command line support is also available. For command line use, we recommend installing it globally.
sonarqube-compare -s develop -t master -c your_project_key -k token -h https://sonarqube.example.com -m uncovered_lines uncovered_conditionsOutput
╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ Test Coverage Report ║
╟──────────────────────┬───────┬────────────────────────────────────────────────────┬────────────┬─────────────────┬──────────────────────────────╢
║ Key │ Line │ Code │ New code │ Uncovered Lines │ Uncovered Conditions (Fully) ║
╟──────────────────────┼───────┼────────────────────────────────────────────────────┼────────────┼─────────────────┼──────────────────────────────╢
║ │ 362 │ if (NotCoveredThisConditionFully) { │ false │ │ true ║
║ ├───────┼────────────────────────────────────────────────────┼────────────┼─────────────────┼──────────────────────────────╢
║ your_project_key:src │ 366 │ if (NotCoveredThisLine == true) { │ false │ true │ ║
║ /common/fileName.ts ├───────┼────────────────────────────────────────────────────┼────────────┼─────────────────┼──────────────────────────────╢
║ │ 371 │ return defaultMessage; │ false │ true │ ║
╚══════════════════════╧═══════╧════════════════════════════════════════════════════╧════════════╧═════════════════╧══════════════════════════════╝