> For the complete CircleCI developer hub index, see [llms.txt](https://circleci.com/developer/llms.txt)

# iamanonymous419/sonar

A reusable CircleCI orb that simplifies static code analysis using SonarQube or SonarCloud.


## Jobs

### scan

Run a SonarCloud scan using npx sonar-scanner.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `exclusions` | string | **/node_modules/**,**/dist/**,**/build/** |  |
| `host_url` | string | https://sonarcloud.io |  |
| `organization` | string |  |  |
| `project_key` | string |  |  |
| `sonar_token` | env_var_name | SONAR_TOKEN |  |
| `sources` | string |  |  |

## Executors

### default

Executor for running SonarCloud scans

## Examples

### example

Example workflow using the Sonar orb job to install the SonarQube scanner and perform static code analysis. This example assumes SONAR_TOKEN is already set as an environment variable.


```yaml
version: '2.1'
orbs:
  sonar: iamanonymous419/sonar@1.0.0
workflows:
  sonar-analysis:
    jobs:
      - sonar/scan:
          exclusions: '**/node_modules/**,**/dist/**,**/build/**'
          host_url: https://sonarcloud.io
          organization: iamanonymous419
          project_key: iamanonymous419_test-project
          sonar_token: SONAR_TOKEN
          sources: .
```