Skip to content

Commit

Permalink
Detekt 1.21.0-RC2 (#40)
Browse files Browse the repository at this point in the history
* Add --build-upon-default-config and --all-rules arguments

* Update detekt version

Co-authored-by: Alexey Egin <[email protected]>
  • Loading branch information
alaegin and alaegin authored Jul 15, 2022
1 parent 04bbe92 commit 8fce67f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM alpine:3.13.1

# https://github.com/detekt/detekt/releases
ARG DETEKT_VERSION="1.20.0"
ARG DETEKT_VERSION="1.21.0-RC2"
# https://github.com/reviewdog/reviewdog/releases
ARG REVIEWDOG_VERSION="0.14.0"
ARG REVIEWDOG_VERSION="0.14.1"

ARG DETEKT_FILE_NAME="detekt-cli-${DETEKT_VERSION}-all.jar"
ARG DETEKT_URL="https://github.com/detekt/detekt/releases/download/v${DETEKT_VERSION}/${DETEKT_FILE_NAME}"
Expand Down
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@

![GitHub release (latest by date)](https://img.shields.io/github/v/release/alaegin/Detekt-Action)

This action allows running [detekt](https://github.com/detekt/detekt) with [reviewdog](https://github.com/reviewdog/reviewdog) on pull requests
This action allows running [detekt](https://github.com/detekt/detekt)
with [reviewdog](https://github.com/reviewdog/reviewdog) on pull requests

## Examples

### `github-pr-check` - used by default

`reviewdog_reporter: github-pr-check`
`github-pr-check` reporter reports results to [GitHub Checks](https://github.com/reviewdog/reviewdog#reporter-github-checks--reportergithub-pr-check)
`github-pr-check` reporter reports results
to [GitHub Checks](https://github.com/reviewdog/reviewdog#reporter-github-checks--reportergithub-pr-check)

![Example comment made by the action with github-pr-check](./assets/screenshot_pr_check.png)

### `github-pr-review`

`reviewdog_reporter: github-pr-review`
`github-pr-review` reporter reports results to GitHub PullRequest review comments.

Expand Down Expand Up @@ -89,13 +93,31 @@ To enable declare `detekt_parallel: true`

[Read more](https://detekt.github.io/detekt/cli.html)

### `detekt_build_upon_default_config`

Optional. Preconfigures detekt with a bunch of rules and some opinionated defaults
for you.
Allows additional provided configurations to override the
defaults.
To enable declare `detekt_build_upon_default_config: true`

[Read more](https://detekt.github.io/detekt/cli.html)

### `detekt_all_rules`

Optional. Activates all available (even unstable) rules.
The default value is empty.
To enable declare `detekt_all_rules: true`

[Read more](https://detekt.github.io/detekt/cli.html)

## Usage

Following example runs detekt with

```yml
name: reviewdog
on: [pull_request]
on: [ pull_request ]

jobs:
detekt:
Expand All @@ -110,14 +132,16 @@ jobs:
ref: ${{ github.head_ref }}

- name: detekt
uses: alaegin/Detekt-Action@v1.20.0
uses: alaegin/Detekt-Action@v1.21.0-RC2
with:
github_token: ${{ secrets.github_token }}
detekt_config: detekt-config.yml # Change config path
```
## License
[MIT](LICENSE)
## Inspiration
* [action-ktlint](https://github.com/ScaCap/action-ktlint) - Action for running ktlint with reviewdog
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ inputs:
detekt_parallel:
description: 'Executes detekt in parallel'
required: false
detekt_build_upon_default_config:
description: 'Preconfigures detekt with a bunch of rules and some opinionated defaults
for you. Allows additional provided configurations to override the
defaults.'
required: false
detekt_all_rules:
description: 'Activates all available (even unstable) rules.'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
Expand All @@ -60,6 +68,8 @@ runs:
- ${{ inputs.detekt_plugins }}
- ${{ inputs.detekt_baseline }}
- ${{ inputs.detekt_parallel }}
- ${{ inputs.detekt_build_upon_default_config }}
- ${{ inputs.detekt_all_rules }}
branding:
icon: 'check-square'
color: 'orange'
9 changes: 8 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ fi
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

detekt_command="java -jar /opt/detekt.jar "
detekt_command+="--fail-fast "
detekt_command+="--config ${INPUT_DETEKT_CONFIG} "
detekt_command+="--report xml:detekt_report.xml "
detekt_command+="--excludes ${INPUT_DETEKT_EXCLUDES} "
Expand All @@ -33,6 +32,14 @@ if [ -n "$INPUT_DETEKT_PARALLEL" ]; then
detekt_command+="--parallel "
fi

if [ -n "$DETEKT_INPUT_BUILD_UPON_DEFAULT_CONFIG" ]; then
detekt_command+="--build-upon-default-config "
fi

if [ -n "$DETEKT_ALL_RULES" ]; then
detekt_command+="--all-rules "
fi

echo "$detekt_command"
eval "$detekt_command"

Expand Down

0 comments on commit 8fce67f

Please sign in to comment.