# sonarqube-compare

> With sonarqube-compare, you can compare your new branch against the target branch's coverage and issues in detail.

Latest version **1.0.6** (published 2023-12-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install sonarqube-compare
pnpm add sonarqube-compare
yarn add sonarqube-compare
bun add sonarqube-compare
```

Provides the command `sonarqube-compare`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2023-12-22 |
| First published | 2023-12-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 57.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | AlvinLaiPro |
| Maintainers | alvinlai |
| Keywords | sonarqube, compare, coverage, line coverage |

## Links

- npm: https://www.npmjs.com/package/sonarqube-compare
- Repository: https://github.com/AlvinLaiPro/sonarqube-compare
- Homepage: https://github.com/AlvinLaiPro/sonarqube-compare#readme
- Issues: https://github.com/AlvinLaiPro/sonarqube-compare/issues
- npm.io page: https://npm.io/package/sonarqube-compare

## Dependencies (5)

- [jsdom](https://npm.io/package/jsdom.md) 23.0.0
- [table](https://npm.io/package/table.md) 6.8.1
- [yargs](https://npm.io/package/yargs.md) 17.7.2
- [ts-node](https://npm.io/package/ts-node.md) 10.9.1
- [node-fetch](https://npm.io/package/node-fetch.md) 2.7.0

## Recent versions

- 1.0.6 (latest) — 2023-12-22

## README

# 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. So it needs to wait until your branches have the coverage reports in the sonarqube server.**

## Installation

sonarqube-compare runs on Node.js and is available as a NPM package.

```bash
npm install sonarqube-compare
```
or 
```
npm install sonarqube-compare -g
```

## Usage

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.

```js
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.

```bash
sonarqube-compare -s develop -t master -c your_project_key -k token -h https://sonarqube.example.com -m uncovered_lines uncovered_conditions
```
## Output
```
╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║                                                              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       │                              ║
╚══════════════════════╧═══════╧════════════════════════════════════════════════════╧════════════╧═════════════════╧══════════════════════════════╝
```

---
_Source: https://npm.io/package/sonarqube-compare · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
