Lint (code quality), Format and Auto-fix your groovy files and Jenkinsfile
Visual Studio Code extension embedding npm-groovy-lint, itself embedding CodeNarc
.groovylintrc.json
fileCommand | Description | Access |
---|---|---|
Analyze code | Lint the code of the current file | Ctrl+Shift+F9 ContextualStatus bar Commands |
Format | Format the code of the current file | Shift+Alt+F ContextualCommands |
Fix all auto-fixable problems | Fix the code of the current file | ContextualCommands |
Lint folder | Lint all applicable files of a folder | Contextual |
Fix single error | Apply quick fix for a single problem | Quick Fix Diagnostic |
Fix rule in entire file | Apply quick fix for all problems related to the same rule in the current file | Quick Fix Diagnostic |
Disable rule for this line | Disable rule only for current line | Quick Fix Diagnostic |
Disable rule for this entire file | Disable rule in the entire file | Quick Fix Diagnostic |
Disable rule for this entire project | Updates configuration file (usually .groovylintrc.js in root folder) to disable this rule |
Quick Fix Diagnostic |
Parameter | Description | Default |
---|---|---|
groovyLint.enable |
Controls whether GroovyLint is enabled or not | true |
groovyLint.lint.trigger |
Run the linter on save (onSave), on type (onType) , or on user request | onSave |
groovyLint.format.enable |
Controls whether the groovy formatter is enabled or not | true |
groovyLint.fix.enable |
Run the auto-fixer on save (onSave), on type (onType) , or on user request | true |
groovyLint.fix.trigger |
Run the fixer on save (onSave), or on user request | user |
groovyLint.basic.loglevel |
Linting error level (error, warning,info) | info |
groovyLint.basic.verbose |
Turn on to have verbose logs | false |
groovyLint.basic.config |
NPM groovy lint configuration file | .groovylintrc.json |
groovyLint.debug.enable |
Display more logs in VsCode Output panel (select "GroovyLint") for issue investigation | false |
groovyLint.java.executable |
Override java executable to use Example: C:\Program Files\Java\jdk1.8.0_144\bin\java.exe |
java |
groovyLint.java.options |
Override java options to use | "-Xms256m,-Xmx2048m" |
groovyLint.insight.enable |
Allow to send anonymous usage statistics used only to improve the tool (we will of course never send your code) | false |
groovyLint.showProblemsView |
Show Problems View once after start | false |
Node.js version 18 or higher is required to run this extension. If you can't upgrade, you can use nvm to have different node versions on your computer
Java version 17 or higher is required to run this extension
As CodeNarc is run in background with java/groovy, performances could be improved on large files (do not hesitate to provide advices !) But do not worry, as the groovy linting is provided by a background local server, your VsCode won't be slowed.
Contributions are very welcome on :
Please follow Contribution instructions
stevenh, for his huge refactoring of npm-groovy-lint and vscode-groovy-lint, saving them from deprecation :)
yuvmel, for his great support on #18 that allowed VsCode Groovy Lint to work much better on Mac, Linux, and with other diagnostic extensions
showProblemsView
that controls if Problems View should open after initial lint passUpgrade to npm-groovy-lint v10.0.0
UI
Fixes
GroovyLint is analyzing code...
(#157)UnnecessaryGetter
, FactoryMethodName
, MethodReturnTypeRequired
, and GStringExpressionWithinString
in recommended-jenkinsfile
(#140) (Felipe Santos)Never
for tabs auto-replacement by spaces.groovylintrc.json
, using property "codenarcRulesets"
. Warning: doing so means that all other properties of config file will be ignored.See complete CHANGELOG