Language | Linter | Formatter |
CodeNarc | IntelliJ | |
![]() |
pylint * | PyCharm * |
![]() |
Shellcheck * | shfmt / IntelliJ? * |
![]() |
😞 | terraform fmt |
![]() |
yamllint | 😞 |
![]() |
kubeval * | 😞 |
Example: jenkins-job-dsl-seed-jobs
make fmt
make lint
CODENARC='docker.io/abletonag/groovylint:0.7.1'
.PHONY: lint
lint:
@docker run --rm -v `pwd`:/ws -u `id -u`:`id -g` \
$(CODENARC) python3 /opt/run_codenarc.py -- \
-includes='**/Jenkinsfile,**/*.groovy,**/*.dsl' \
-rulesetfiles=file\:ruleset.groovy
stage('Lint') {
steps {
container('docker') { runCodeChecks() }
}
post {
always { postCodeChecks() }
failure { archiveArtifacts '*.log' }
}
}
CodeNarc analyzes Groovy code for defects, bad practices, inconsistencies, style issues and more. A flexible framework for rules, rulesets and custom rules means it's easy to configure CodeNarc to fit into your project.
make lint
...
INFO Scanned 613 files
ERROR src/main/groovy/util/Versions.groovy:33:
SpaceAfterOpeningBrace: [empty message]
ERROR src/main/groovy/util/Versions.groovy:33:
SpaceBeforeClosingBrace: [empty message]
ERROR Found 2 violation(s)
make: *** [lint] Error 1
def myMethod() {
try {
doSomething()
} catch(MyException e) { ❌
}
}
if (!x) { ❌
return false
} else {
return true
}
[1, 2, 3].each({ println it }) ❌
[1, 2, 3].each { println it } ✅
def a = "key1" ❌
def b = 'key1' ✅
def c = "key${keyNum}" ✅