npm-groovy-lint
npm-groovy-lint copied to clipboard
Incorrect indentation in blocks and braces
Hello,
I tried using your linter to format groovy files, specifically Jenkinsfile groovy, but I can't seem to get the indentation formatting to be correct. Is this a known issue and is there a fix or a workaround?
Version:
npm-groovy-lint -v
GroovyLint: Successfully processed CodeNarc:
CodeNarc version 3.3.0
npm-groovy-lint version 14.4.0
Embeds:
CodeNarc version 3.3.0
- Groovy version 3.0.9 (superlite)
Command:
npm-groovy-lint --format --noserver test.groovy
test.groovy
npm-groovy-lint results in linted files:
┌─────────┬───────────┬─────────────┬─────────────┬─────────────────┐
│ (index) │ Severity │ Total found │ Total fixed │ Total remaining │
├─────────┼───────────┼─────────────┼─────────────┼─────────────────┤
│ 0 │ 'Error' │ 0 │ 0 │ 0 │
│ 1 │ 'Warning' │ 0 │ 0 │ 0 │
│ 2 │ 'Info' │ 14 │ 14 │ 0 │
└─────────┴───────────┴─────────────┴─────────────┴─────────────────┘
Input File:
def afterBuild() {
stage('Run Tests')
{
try {
runResult = runTests()
}
catch(Exception e)
{
throw new Exception(e)
}
finally
{
if (runResult)
{
log.info(runResult.out)
try {
publish("Test Completed. Result" + runResult)
}
catch(Exception e)
{
log.warn("Unable to publish test results: " + e.toString())
}
}
}
}
}
Output File:
def afterBuild() {
stage('Run Tests')
{
try {
runResult = runTests()
}
catch (Exception e)
{
throw new Exception(e)
}
finally
{
if (runResult) {
log.info(runResult.out)
try {
publish('Test Completed. Result' + runResult)
}
catch (Exception e)
{
log.warn('Unable to publish test results: ' + e.toString())
}
}
}
}
}
I've also tried commands
npm-groovy-lint --format test.groovy
npm-groovy-lint --fix test.groovy
npm-groovy-lint --fix -x "Indentation,BracesForIfElse,BracesForTryCatchFinally,IndentationClosingBraces" test.groovy
with the same result.
@cdebergh npm-groovy-lint formatting is based on CodeNarc rule, which is sometimes not accurate , so this is a know problem :(
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
If you think this issue should stay open, please remove the O: stale 🤖
label or comment on the issue.