Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0x6675636b796f75676974687562/diktat-demo-gradle
A template Gradle project (Groovy DSL flavour) which uses DiKTat to check the style of your code
https://github.com/0x6675636b796f75676974687562/diktat-demo-gradle
diktat gradle
Last synced: 17 days ago
JSON representation
A template Gradle project (Groovy DSL flavour) which uses DiKTat to check the style of your code
- Host: GitHub
- URL: https://github.com/0x6675636b796f75676974687562/diktat-demo-gradle
- Owner: 0x6675636b796f75676974687562
- License: mit
- Created: 2022-07-04T16:01:06.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-04T13:13:23.000Z (over 1 year ago)
- Last Synced: 2024-10-04T13:21:59.449Z (3 months ago)
- Topics: diktat, gradle
- Language: Kotlin
- Homepage:
- Size: 82 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
This is a template _Gradle_ project (_Groovy_ DSL flavour) which uses
https://github.com/saveourtool/diktat[_DiKTat_] to check the style of your code.If your project has multiple modules, be sure to pass the
https://docs.gradle.org/current/userguide/command_line_interface.html#sec:continue_build_on_failure[`--continue`]
flag to _Gradle_:[source,shell]
----
./gradlew --continue diktatCheck
----Here's a sample _DiKTat_ configuration. Depending on whether you pass the
`-Pdiktat.githubActions=true` property to _Gradle_, the output will be written
either in plain text format to the standard output, or in the
https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning#about-sarif-support[SARIF]
format to a report file:[source,groovy]
----
buildscript {
repositories {
mavenCentral()
}dependencies {
classpath group: 'org.cqfn.diktat', name: 'diktat-gradle-plugin', version: 1.2.3
}
}apply plugin: 'org.cqfn.diktat.diktat-gradle-plugin'
diktat {
inputs {
it.include("src/**/*.kt", "*.kts", "src/**/*.kts")
it.exclude("build/**")
}def sarifOutput = Boolean.parseBoolean(project.findProperty("diktat.githubActions"))
reporter = sarifOutput ? "sarif" : "plain"
output = sarifOutput ? "build/reports/diktat/diktat.sarif" : ""
debug = false
}
----`reporter` can be one of:
* `html`,
* `json`,
* `plain` (the default), and
* `sarif`.If the `output` field is empty, reports will be written to the standard output.
While it's possible to configure `reporter` and `output` independently, you may
consider using the `githubActions` flag instead. This configuration is
effectively equivalent to the one above:[source,groovy]
----
buildscript {
repositories {
mavenCentral()
}dependencies {
classpath group: 'org.cqfn.diktat', name: 'diktat-gradle-plugin', version: 1.2.3
}
}apply plugin: 'org.cqfn.diktat.diktat-gradle-plugin'
diktat {
inputs {
it.include("src/**/*.kt", "*.kts", "src/**/*.kts")
it.exclude("build/**")
}githubActions = Boolean.parseBoolean(project.findProperty("diktat.githubActions"))
debug = false
}
----You can integrate with https://docs.github.com/en/actions[_GitHub Actions_] and
make code scanning results (e.g.: after a pull request) immediately available by
adding a YAML file of the following content under `.github/workflows` (uses
https://github.com/github/codeql-action[github/codeql-action/upload-sarif@v2]):[source,yaml]
----
name: Run diKTaton:
push:
branches: [ master ]
pull_request:
branches: [ master ]env:
GRADLE_OPTS: -Dorg.gradle.daemon=falsejobs:
diktat_check:
runs-on: ubuntu-20.04permissions:
security-events: writesteps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'zulu'
java-package: jdk+fx
cache: gradle
- uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
arguments: |
--continue
diktatCheck
-Pdiktat.githubActions=true
- name: Copy SARIF reports into a single directory
if: ${{ always() }}
run: |
mkdir -p build/diktat-sarif-reports
i=0
find -path '*/build/reports/diktat/*.sarif' | while read -r f; do cp "$f" "build/diktat-sarif-reports/diktat-$((i++)).sarif"; done
- name: Upload SARIF reports to GitHub
if: ${{ always() }}
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: build/diktat-sarif-reports
----The shell script fragment:
[source,shell]
----
mkdir -p build/diktat-sarif-reports
i=0
find -path '*/build/reports/diktat/*.sarif' | while read -r f; \
do \
cp "$f" "build/diktat-sarif-reports/diktat-$((i++)).sarif"; \
done
------ merely copies all the generated SARIF reports into a single directory, so
that they can be read by _GitHub_.