nvuillam / npm-groovy-lint

Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files using command line
https://nvuillam.github.io/npm-groovy-lint/
MIT License
203 stars 63 forks source link

Unable to disable indentation formatting #378

Open logicbomb421 opened 1 month ago

logicbomb421 commented 1 month ago

It seems indentation is a common issue among users of CodeNarc, which I am aware this tool uses under the hood.

Our team has elected to disable the indentation rules entirely sine they are currently producing some odd results. However, when setting enabled: false for this rule, indentation is still modified on a call using --fix or --format.

For example, consider the following .groovylintrc.json file:

{
  "extends": "recommended",
  "rules": {
    "Indentation": {
      "enabled": false
    }
  }
}

and the following Groovy snippet:

int example(int arg) {
  if (arg == 1
      || arg == 2
      || arg == 3) {
      print(arg)
  } else {
        print(-1)
  }
}

When running the linter with npm-groovy-lint example.groovy --fix (or --format), the closing brace under else is still reformatted even though indentation should be disabled:

if (arg == 1
    || arg == 2
    || arg == 3) {
    print(arg)
} else {
      print(-1)
    }

I have tried formatting.Indentation in the config file, though that also does not change anything.

How can I disable indentation linting and formatting using this tool?

Thank you!


GroovyLint: Successfully processed CodeNarc: 
CodeNarc version 3.3.0
npm-groovy-lint version 14.6.0

Embeds:
CodeNarc version 3.3.0
- Groovy version 3.0.9 (superlite)
github-actions[bot] commented 4 weeks ago

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.

nvuillam commented 3 weeks ago

@logicbomb421 please can you run DEBUG=npm-groovy-lint npm-groovy-lint ... and share the log ? It will tell use which rule has played with Indentation (there are other rules that can impact it)