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

Can this be changed to support "global" .groovylintrc.json files? #29

Closed
deiga opened this issue Apr 23, 2020 · 4 comments · Fixed by #30
Closed

Can this be changed to support "global" .groovylintrc.json files? #29

deiga opened this issue Apr 23, 2020 · 4 comments · Fixed by #30
Assignees

Comments

@deiga
Copy link
Contributor

deiga commented Apr 23, 2020

I would like to have a set of default rules at ~/.groovylintrc.json as there are certain rules which don't work with Jenkinsfiles too well in their default format, but I don't want to modify each repo with the same rules either.

@nvuillam
Copy link
Owner

nvuillam commented Apr 23, 2020

I'm not sure that it's a good idea to use a root file at an upper level than the repo, especially if u use CI / docker, but as it's supposed to be possible to directly target a config file in --config argument, so i'll solve this bug in the next patch :)
Maybe you would be interested if npm-groovy-lint provides a default recommended-groovy.json and a recommended-jenkinsfile.json in the package ? If yes would you like to propose a list of rules ? :)

@deiga
Copy link
Contributor Author

deiga commented Apr 24, 2020

A lot of tools use a root config and a local config option, where they either get merged or you can disable from including the root one. A good example would be editorconfig. I do understand that if we'd use this package for CI then it would make sense to have the rules in the repo but in my use-case, I just started using the package on my own.

A default Jenkinsfile ruleset would be great! :)

There are a few rules currently causing problems at least for my use-case:

  • "SpaceAroundMapEntryColon" has to be turned off, as I couldn't find the right regex to give it to allow spaces around colons and in Jenkinsfiles some "keys" like "checkout scm: [...]" have a space in the key itself.
  • "CompileStatic" should be turned off, as it interferes with @Library(foo) _ annotation
    • The @Library(foo) _ annotation triggers a few other rules, which shouldn't be turned off but ignored specifically for that:
      • "VariableName"
      • "UnusedVariable"
      • "NoDef"
      • "VariableTypeRequired"

Some rules that I had to disable or modify locally were also NestedBlockDepth, DuplicateStringLiteral and LineLength, but that's just because I didn't want to start a refactor, they are good indicators that one should extract things out of the pipeline into functions. Although NestedBlockDepth might better be at 8 or so as 5 is quite quickly reached with a pipeline (pipeline -> stages -> stage -> steps -> script)

@nvuillam
Copy link
Owner

Thanks for the suggestions, I'll manage all that :)

@nvuillam
Copy link
Owner

Published 4.5.0 managing :

  • Configuration updates (#29):
    • New default config "recommended-jenkinsfile". Use it with argument --config recommended-jenkinsfile
    • Allow to directly target a config file name. Use it with argument --config /my/custom/path/.groovylintrc-custom-name.json
    • Allow to send a string key that will be used to find config file --config custom-name
  • Updated fix rules:
    • IfStatementBraces
    • ElseStatementBraces

If you wants more rules for Jenkinsfiles, you can

Please reopen the issue if you still see problems :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants