Skip to content

Commit

Permalink
🎉Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Heyns committed Aug 19, 2024
0 parents commit 48e74ca
Show file tree
Hide file tree
Showing 14 changed files with 3,538 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
31 changes: 31 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"env": {
"browser": true,
"node": true,
"es6": true,
"es2017": true
},
"extends": [
"eslint:recommended",
"plugin:sonarjs/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"tsconfigRootDir": "./packages/"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/interface-name-prefix": [
"off"
],
"@typescript-eslint/no-var-requires": [
"off"
]
}
}
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
node_modules
dist
results
.nyc_output
*.tsbuildinfo
coverage
.idea
report
.DS_Store
.eslintcache
.jscpd
docs
.cache
tmp
sandbox
tmp/
build/
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# jscpd-gitlab-reporter

## 1.0.0

### Initial Release

- Introduce GitLab Code Quality reporter (CodeClimate format)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2013-2024 Mike Heyns

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# `jscpd-gitlab-reporter`

A [GitLab Code Quality](https://docs.gitlab.com/ee/ci/testing/code_quality.html) reporter for [jscpd](https://github.com/kucherenko/jscpd).

This uses the [custom tool approach](https://docs.gitlab.com/ee/ci/testing/code_quality.html#implement-a-custom-tool)
which is a subset of the [Code Climate spec](https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#data-types).

## Getting started

### Install

```bash
npm install jscpd-gitlab-reporter
```

### Usage

```bash
jscpd [...options] --reporters gitlab /path/to/source
```

See the [jspcd CLI docs](https://github.com/kucherenko/jscpd/tree/master/apps/jscpd) for available options and configuration.

### CI/CD Definition

Add the following to your `.gitlab-ci.yml`

```yaml
check:duplicates:
image: node:20.14.0-alpine3.20
stage: codequality
script:
- npm ci
- npx jscpd --reporters gitlab src/**/*
artifacts:
reports:
codequality: report/gl-codequality.json
```
## Additional Configuration
### `CI_PROJECT_DIR`

[Predefined GitLab CI variable](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html) is used to determine
the relative file paths in the report. Defaults to the current working directory.

### `CODE_QUALITY_REPORT`
Specifies a custom report file path. Defaults to `gl-codequality.json` in the jscpd output directory, which itself
defaults to `report/`.

### `CODE_QUALITY_APPEND`
Merge the produced findings with an existing quality report if it already exists. Useful when utilising multiple tools
in the same GitLab job. Defaults to `false`.

---
[MIT](LICENSE) | Based on the [@jscpd/serif-reporter](https://github.com/kucherenko/jscpd/tree/master/packages/sarif-reporter) by Andrey Kucherenko
Loading

0 comments on commit 48e74ca

Please sign in to comment.