# bitbucket-codeinsights-reporter

> [![NPM](https://img.shields.io/npm/v/bitbucket-codeinsights-reporter.svg?label=bitbucket-codeinsights-reporter)](https://www.npmjs.com/package/bitbucket-codeinsights-reporter) [![Downloads/week](https://img.shields.io/npm/dw/bitbucket-codeinsights-reporte

Latest version **0.5.0** (published 2023-05-17) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install bitbucket-codeinsights-reporter
pnpm add bitbucket-codeinsights-reporter
yarn add bitbucket-codeinsights-reporter
bun add bitbucket-codeinsights-reporter
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2023-05-17 |
| First published | 2023-05-11 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14.0.0 |
| Dependencies | 6 |
| Unpacked size | 58.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ivo Rocha |
| Maintainers | ivorocha |
| Keywords | force, salesforce, sfdx, salesforcedx, sfdx-plugin, sf-plugin, sf |

## Links

- npm: https://www.npmjs.com/package/bitbucket-codeinsights-reporter
- Repository: https://github.com/ivorocha90/bitbucket-codeinsights-reporter
- Homepage: https://github.com/ivorocha90/bitbucket-codeinsights-reporter#readme
- Issues: https://github.com/ivorocha90/bitbucket-codeinsights-reporter/issues
- npm.io page: https://npm.io/package/bitbucket-codeinsights-reporter

## Dependencies (6)

- [axios](https://npm.io/package/axios.md) ^1.4.0
- [tslib](https://npm.io/package/tslib.md) ^2
- [@oclif/core](https://npm.io/package/@oclif/core.md) ^2.8.2
- [@salesforce/kit](https://npm.io/package/@salesforce/kit.md) ^1.9.2
- [@salesforce/core](https://npm.io/package/@salesforce/core.md) ^3.34.8
- [@salesforce/sf-plugins-core](https://npm.io/package/@salesforce/sf-plugins-core.md) ^2.2.10

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.5.0 (latest) — 2023-05-17
- 0.4.0 — 2023-05-16
- 0.3.1 — 2023-05-16
- 0.3.0 — 2023-05-16
- 0.2.2 — 2023-05-12
- 0.2.1 — 2023-05-12
- 0.2.0 — 2023-05-11
- 0.1.7 — 2023-05-11
- 0.1.6 — 2023-05-11
- 0.1.5 — 2023-05-11
- 0.1.4 — 2023-05-11
- 0.1.3 — 2023-05-11
- 0.1.2 — 2023-05-11

## README

# bitbucket-codeinsights-reporter

[![NPM](https://img.shields.io/npm/v/bitbucket-codeinsights-reporter.svg?label=bitbucket-codeinsights-reporter)](https://www.npmjs.com/package/bitbucket-codeinsights-reporter) [![Downloads/week](https://img.shields.io/npm/dw/bitbucket-codeinsights-reporter.svg)](https://npmjs.org/package/bitbucket-codeinsights-reporter) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/salesforcecli/bitbucket-codeinsights-reporter/main/LICENSE.txt)

## Install

```bash
sf plugins install bitbucket-codeinsights-reporter
```

# What is bitbucket-codeinsights-reporter?

bitbucket-codeinsights-reporter uses the static code analysis results from the [Salesforce Code Analyser](https://forcedotcom.github.io/sfdx-scanner/) plugin and then uploads those results as Annotations to a given commit in Bitbucket Server. Those annotations can then be seen in the Diff view of a Pull Request of that commit.

## How to use?

First run the scanner, making sure to provide the `--normalize-severity` flag. Only JSON output is supported. [Check source for reference](https://forcedotcom.github.io/sfdx-scanner/en/v3.x/scanner-commands/run/). Example:

```bash
sfdx scanner:run --normalize-severity --json --target "classes/myclass.cls" --outfile results.json
```

Then pass the results.json file on the `report-file` parameter of the report command.

Note: do not evaluate all of your source files using the scanner, you should only evaluate modified/created components part of the commit. You can use [sfdx-git-delta](https://github.com/scolladon/sfdx-git-delta) for that in your pipeline for Pull-Requests validation.

## Commands

<!-- commands -->
* [`sf bcr codeinsights report`](#sf-bcr-codeinsights-report)

## `sf bcr codeinsights report`

Takes the static code analysis results of SFCA plugin and uploads them to a givem commit in Bitbucket, providing code reviewers additional insights into the code being reviewed.

```
USAGE
  $ sf bcr codeinsights report --report-file <value> --commit-id <value> --bitbucket-server-url <value>
    --bitbucket-auth-username <value> --bitbucket-auth-password <value> --bitbucket-project-key <value>
    --bitbucket-repository-slug <value> [--json] [--skip-engine-results pmd|eslint|cpd|retire-js]

FLAGS
  --bitbucket-auth-password=<value>    (required) Your Bitbucket Server password. Preferentially, create a new HTTP
                                       Access Token under your profile page and use it instead of your password.
  --bitbucket-auth-username=<value>    (required) Your Bitbucket Server username.
  --bitbucket-project-key=<value>      (required) The project key where the repository exists.
  --bitbucket-repository-slug=<value>  (required) The repository slug identifier.
  --bitbucket-server-url=<value>       (required) Bitbucket server url.
  --commit-id=<value>                  (required) Commit hash where the code insights will be uploaded to in Bitbucket
                                       Server.
  --report-file=<value>...             (required) The SFCA result JSON file with violations normalized. Accepts multiple
                                       files.
  --skip-engine-results=<option>...    [default: ] Engines to not parse from the results flag.
                                       <options: pmd|eslint|cpd|retire-js>

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  Takes the static code analysis results of SFCA plugin and uploads them to a givem commit in Bitbucket, providing code
  reviewers additional insights into the code being reviewed.

  SFCA ("Salesforce Code Analyzer") plugin performs static code analysis using popular tools such as PMD, ESLINT,
  RETIRE.Js, and more. This SFDX plugin takes the results of this analysis and uploads them to a specified commit in
  Bitbucket Server. This allows code reviewers to do a better analysis of the code, gaining valuable insights into the
  quality of the code being reviewed.

  Note: Please make sure when running the `sfdx scanner:run` to provide the flag `--normalize-severity`, otherwise
  reported severities in the code insights may not match to the actual severity level.

EXAMPLES
  $ sf bcr codeinsights report \
  --bitbucket-server-url "https://bitbucket.my-org-instance.org" \
  --bitbucket-auth-username "your@username.com" \
  --bitbucket-auth-password "http-access-token-password" \
  --bitbucket-project-key "PRJ" \
  --bitbucket-repository-slug "my-repo" \
  --commit-id "f1eb3eb5710d2396d68987dd571433151714b499" \
  --report-file report-output.json \
  --skip-engine-results "eslint-lwc" \
  --skip-engine-results "retire-js" \
```
<!-- commandsstop -->

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