Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect indentation in blocks and braces #367

Closed
cdebergh opened this issue Mar 30, 2024 · 2 comments
Closed

Incorrect indentation in blocks and braces #367

cdebergh opened this issue Mar 30, 2024 · 2 comments

Comments

@cdebergh
Copy link

cdebergh commented Mar 30, 2024

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.

@nvuillam
Copy link
Owner

@cdebergh npm-groovy-lint formatting is based on CodeNarc rule, which is sometimes not accurate , so this is a know problem :(

Copy link

github-actions bot commented May 1, 2024

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.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants