npm-groovy-lint 9.4.1 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +39 -2
  2. package/README.md +54 -28
  3. package/lib/.groovylintrc-all.json +393 -394
  4. package/lib/.groovylintrc-format.json +2 -0
  5. package/lib/codenarc-caller.js +7 -3
  6. package/lib/codenarc-factory.js +77 -14
  7. package/lib/example/RuleSet-All.groovy +413 -417
  8. package/lib/example/SampleFileSmall.groovy +3 -3
  9. package/lib/example/SampleFileSmallFixed.txt +4 -4
  10. package/lib/example/SampleFileSmallFormatted.txt +4 -4
  11. package/lib/groovy-lint-rules.js +2 -0
  12. package/lib/groovy-lint.js +5 -3
  13. package/lib/index.js +5 -1
  14. package/lib/java/CodeNarc-3.1.0.jar +0 -0
  15. package/lib/java/CodeNarcServer.jar +0 -0
  16. package/lib/java/GMetrics-2.1.0.jar +0 -0
  17. package/lib/java/{log4j-api-2.17.1.jar → log4j-api-2.18.0.jar} +0 -0
  18. package/lib/java/{log4j-core-2.17.1.jar → log4j-core-2.18.0.jar} +0 -0
  19. package/lib/java/{log4j-slf4j-impl-2.17.1.jar → log4j-slf4j-impl-2.18.0.jar} +0 -0
  20. package/lib/options.js +30 -15
  21. package/lib/output.js +1 -3
  22. package/lib/rules/DuplicateNumberLiteral.js +21 -0
  23. package/lib/rules/DuplicateStringLiteral.js +21 -0
  24. package/lib/rules/MethodParameterTypeRequired.js +21 -0
  25. package/lib/rules/MisorderedStaticImports.js +2 -2
  26. package/lib/rules/NoDef.js +14 -0
  27. package/lib/rules/SimpleDateFormatMissingLocale.js +14 -0
  28. package/lib/rules/SpaceAfterMethodCallName.js +30 -0
  29. package/lib/rules/SpaceInsideParentheses.js +73 -0
  30. package/lib/rules/UnnecessaryPublicModifier.js +13 -0
  31. package/lib/rules/VariableTypeRequired.js +36 -0
  32. package/lib/utils.js +2 -2
  33. package/package.json +4 -8
  34. package/lib/java/CodeNarc-2.2.0.jar +0 -0
  35. package/lib/java/gmetrics-1.1.jar +0 -0
package/CHANGELOG.md CHANGED
@@ -2,9 +2,46 @@
2
2
 
3
3
  ## UNRELEASED
4
4
 
5
- - Add your updates here :)
5
+ ## [10.0.1] 2022-08-14
6
+
7
+ - Fix error when files sent as positional arguments ([#232](https://github.com/nvuillam/npm-groovy-lint/issues/232))
8
+
9
+ ## [10.0.0] 2022-08-13
10
+
11
+ - Core
12
+ - Upgrade to [CodeNarc v3.1.0](https://github.com/CodeNarc/CodeNarc/blob/master/CHANGELOG.md#version-310----jun-2022)
13
+ - Accept list of directories / files as arguments (`--path` and `--files` become deprecated but are still usable)
14
+ - Examples
15
+ - Multiple files: `npm-groovy-lint path/to/file1.groovy path/to/file2.groovy`
16
+ - Directory: `npm groovy-lint path/to`
17
+ - Single file: `npm-groovy-lint Jenkinsfile`
18
+ - Ant pattern(s): `npm-groovy-lint path/to/**/*.groovy`
19
+ - Upgrade npm dependencies
20
+ - CI: Upgrade [MegaLinter](https://oxsecurity.github.io/megalinter/latest/) to v6
21
+ - Test classes for collecting error ranges
22
+
23
+ - New error ranges rules
24
+ - DuplicateNumberLiteral
25
+ - DuplicateStringLiteral
26
+ - MethodParameterTypeRequired
27
+ - NoDef
28
+ - SimpleDateFormatMissingLocale
29
+ - SpaceInsideParenthesis
30
+ - UnnecessaryPublicModifier
31
+ - VariableTypeRequired
6
32
 
7
- ## [9.4.1] 2022-01-22
33
+ - New fix rules
34
+ - SpaceAfterMethodCallName
35
+ - SpaceInsideParentheses
36
+
37
+ - Bug Fixes
38
+ - Wrongly calculated ranges are no more returned
39
+
40
+ ## [9.5.0] 2022-04-12
41
+
42
+ - Disable Amplitude anonymous stats by default (use `--insight` to enable them)
43
+
44
+ ## [9.4.1] 2022-01-12
8
45
 
9
46
  - Upgrade node-sarif-builder to 2.0.1 and send npm-groovy-lint version in SARIF logs
10
47
  - New range detection for rules:
package/README.md CHANGED
@@ -40,35 +40,37 @@ Any **question**, **problem** or **enhancement request** ? Ask [**here**](https:
40
40
  ## Usage
41
41
 
42
42
  ```shell
43
- npm-groovy-lint OPTIONS
43
+ npm-groovy-lint [OPTIONS] [FILES|PATH|PATTERN]
44
44
  ```
45
45
 
46
- | Parameter | Type | Description |
47
- |-------------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
48
- | -p<br/> --path | String | Directory containing the files to lint<br/> Example: `./path/to/my/groovy/files` |
49
- | -f<br/> --files | String | Comma-separated list of Ant-style file patterns specifying files that must be included.<br/> Default: `"**/*.groovy,**/Jenkinsfile,**/*.gradle"`<br/>Examples:<br/> - `"**/Jenkinsfile"`<br/> - `"**/*.groovy"`<br/> - `"**/*.gradle"`<br/> - `"**/mySingleFile.groovy"` |
50
- | -o<br/> --output | String | Output format (txt,json,sarif,html,xml), or path to a file with one of these extensions<br/> Default: `txt`<br/> Examples:<br/> - `"txt"`<br/> - `"json"`<br/> - `"./logs/myLintResults.txt"`<br/> - `"./logs/myLintResults.sarif"`<br/> - `"./logs/myLintResults.html"`<br/> - `"./logs/myLintResults.xml"` |
51
- | -l<br/> --loglevel | String | Log level (error,warning or info)<br/>Default: info |
52
- | --failon | String | Defines the error level where CLI will fail (return code = 1). error,warning,info or none. Each failure level includes the more critical ones. |
53
- | -c<br/> --config | String | Custom path to [GroovyLint config file](#Configuration), or preset config `recommended|recommended-jenkinsfile|all`<br/> Default: Browse current directory to find `.groovylintrc.json|js|yml|package.json` config file, or default npm-groovy-lint config if not defined.<br/>Note: command-line arguments have priority on config file properties |
54
- | --parse | Boolean | Try to compile the source code and return parse errors (since v5.7.0, default to true, use --no-parse to deactivate) |
55
- | --format | Boolean | Format source code |
56
- | --fix | Boolean | Automatically fix problems when possible<br/> See [Autofixable rules](#Autofixable-rules) |
57
- | -x<br/> --fixrules | String | Option for --fix argument: List of rule identifiers to fix (if not specified, all available fixes will be applied). See [Autofixable rules](#Autofixable-rules) <br/> Examples:<br/> - `"SpaceBeforeClosingBrace,SpaceAfterClosingBrace,UnusedImport"`<br/> - `"Indentation"`<br/> |
58
- | --nolintafter | Boolean | When format or fix is called, a new lint is performed after the fixes to update the returned error list. If you just want the updated source code and do not care about the error logs, use this parameter to improve performances |
59
- | -r<br/> --rulesets | String | [RuleSet file(s)](http://codenarc.github.io/CodeNarc/codenarc-creating-ruleset.html) to use for linting, if you do not want to use recommended rules or .groovylintrc.js defined rules.<br/>If list of comma separated strings corresponding to CodeNarc rules, a RuleSet file will be dynamically generated </br> Examples:<br/> - `"./config/codenarc/RuleSet-Custom.groovy"`<br/> - `"./path/to/my/ruleset/files"`<br/>- `Indentation{"spacesPerIndentLevel":2,"severity":"warning"},UnnecessarySemicolon,UnnecessaryGString` |
60
- | --rulesetsoverridetype | String | If list of rules sent in rulesets option, defines if they replace rules defined in .groovylintrc.json, or if they are appended<br/> Values: `replaceConfig` (default), `appendConfig` |
61
- | -s<br/> --source | String | If path and files are not set, you can directly send the source code string to analyze |
62
- | --verbose | Boolean | More outputs in console, including performed fixes |
63
- | -i<br/> --ignorepattern | String | Comma-separated list of Ant-style file patterns specifying files that must be ignored<br/> Default: none<br/> Example: `"**/test/*""` |
64
- | --noserver | Boolean | npm-groovy-lint launches a microservice to avoid performance issues caused by loading java/groovy each time,that auto kills itself after 1h idle. Use this argument if you do not want to use this feature |
65
- | --returnrules | Boolean | Return rules descriptions and URL if set |
66
- | --javaexecutable | String | Override java executable to use <br/>Default: java<br/>Example: C:\\Program Files\\Java\\jdk1.8.0_144\\bin\\java.exe |
67
- | --javaoptions | String | Override java options to use <br/>Default: "-Xms256m,-Xmx2048m" |
68
- | --no-insight | Boolean | npm-groovy-lint collects anonymous usage statistics using [amplitude](https://www.npmjs.com/package/amplitude), in order to make new improvements based on how users use this package. <br/> Summary charts are available at [https://tinyurl.com/groovy-stats](https://tinyurl.com/groovy-stats).<br/> Analytics obviously does not receive sensitive information like your code, as you can see in [analytics.js](https://github.com/nvuillam/npm-groovy-lint/blob/master/lib/analytics.js).<br/> If you want to disable anonymous usage statistics, use `--no-insight` option. |
69
- | --codenarcargs | String | Use core CodeNarc arguments (all npm-groovy-lint arguments will be ignored)<br/> Doc: <http://codenarc.github.io/CodeNarc/codenarc-command-line.html><br/> Example: `npm-groovy-lint --codenarcargs -basedir="lib/example" -rulesetfiles="file:lib/example/RuleSet-Groovy.groovy" -maxPriority1Violations=0 -report="xml:ReportTestCodenarc.xml` |
70
- | -h<br/> --help | Boolean | Show help (npm-groovy-lint -h OPTIONNAME to see option detail with examples) |
71
- | -v<br/> --version | Boolean | Show npm-groovy-lint version (with CodeNarc version) |
46
+ See [examples](#example-calls)
47
+
48
+ | Parameter | Type | Description |
49
+ |-------------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
50
+ | -o<br/> --output | String | Output format (txt,json,sarif,html,xml), or path to a file with one of these extensions<br/> Default: `txt`<br/> Examples:<br/> - `"txt"`<br/> - `"json"`<br/> - `"./logs/myLintResults.txt"`<br/> - `"./logs/myLintResults.sarif"`<br/> - `"./logs/myLintResults.html"`<br/> - `"./logs/myLintResults.xml"` |
51
+ | -l<br/> --loglevel | String | Log level (error,warning or info)<br/>Default: info |
52
+ | --failon | String | Defines the error level where CLI will fail (return code = 1). error,warning,info or none. Each failure level includes the more critical ones. |
53
+ | -c<br/> --config | String | Custom path to [GroovyLint config file](#Configuration), or preset config `recommended|recommended-jenkinsfile|all`<br/> Default: Browse current directory to find `.groovylintrc.json|js|yml|package.json` config file, or default npm-groovy-lint config if not defined.<br/>Note: command-line arguments have priority on config file properties |
54
+ | --parse | Boolean | Try to compile the source code and return parse errors (since v5.7.0, default to true, use --no-parse to deactivate) |
55
+ | --format | Boolean | Format source code |
56
+ | --fix | Boolean | Automatically fix problems when possible<br/> See [Autofixable rules](#Autofixable-rules) |
57
+ | -x<br/> --fixrules | String | Option for --fix argument: List of rule identifiers to fix (if not specified, all available fixes will be applied). See [Autofixable rules](#Autofixable-rules) <br/> Examples:<br/> - `"SpaceBeforeClosingBrace,SpaceAfterClosingBrace,UnusedImport"`<br/> - `"Indentation"`<br/> |
58
+ | --nolintafter | Boolean | When format or fix is called, a new lint is performed after the fixes to update the returned error list. If you just want the updated source code and do not care about the error logs, use this parameter to improve performances |
59
+ | -r<br/> --rulesets | String | [RuleSet file(s)](http://codenarc.github.io/CodeNarc/codenarc-creating-ruleset.html) to use for linting, if you do not want to use recommended rules or .groovylintrc.js defined rules.<br/>If list of comma separated strings corresponding to CodeNarc rules, a RuleSet file will be dynamically generated </br> Examples:<br/> - `"./config/codenarc/RuleSet-Custom.groovy"`<br/> - `"./path/to/my/ruleset/files"`<br/>- `Indentation{"spacesPerIndentLevel":2,"severity":"warning"},UnnecessarySemicolon,UnnecessaryGString` |
60
+ | --rulesetsoverridetype | String | If list of rules sent in rulesets option, defines if they replace rules defined in .groovylintrc.json, or if they are appended<br/> Values: `replaceConfig` (default), `appendConfig` |
61
+ | -s<br/> --source | String | If path and files are not set, you can directly send the source code string to analyze |
62
+ | --verbose | Boolean | More outputs in console, including performed fixes |
63
+ | -i<br/> --ignorepattern | String | Comma-separated list of Ant-style file patterns specifying files that must be ignored<br/> Default: none<br/> Example: `"**/test/*""` |
64
+ | --noserver | Boolean | npm-groovy-lint launches a microservice to avoid performance issues caused by loading java/groovy each time,that auto kills itself after 1h idle. Use this argument if you do not want to use this feature |
65
+ | --returnrules | Boolean | Return rules descriptions and URL if set |
66
+ | --javaexecutable | String | Override java executable to use <br/>Default: java<br/>Example: C:\\Program Files\\Java\\jdk1.8.0_144\\bin\\java.exe |
67
+ | --javaoptions | String | Override java options to use <br/>Default: "-Xms256m,-Xmx2048m" |
68
+ | --insight | Boolean | npm-groovy-lint collects anonymous usage statistics using [amplitude](https://www.npmjs.com/package/amplitude), in order to make new improvements based on how users use this package. <br/> Summary charts are available at [https://tinyurl.com/groovy-stats](https://tinyurl.com/groovy-stats).<br/> Analytics obviously does not receive sensitive information like your code, as you can see in [analytics.js](https://github.com/nvuillam/npm-groovy-lint/blob/master/lib/analytics.js).<br/> If you want to enable anonymous usage statistics, use `--insight` option. |
69
+ | --codenarcargs | String | Use core CodeNarc arguments (all npm-groovy-lint arguments will be ignored)<br/> Doc: <http://codenarc.github.io/CodeNarc/codenarc-command-line.html><br/> Example: `npm-groovy-lint --codenarcargs -basedir="lib/example" -rulesetfiles="file:lib/example/RuleSet-Groovy.groovy" -maxPriority1Violations=0 -report="xml:ReportTestCodenarc.xml` |
70
+ | -h<br/> --help | Boolean | Show help (npm-groovy-lint -h OPTIONNAME to see option detail with examples) |
71
+ | -v<br/> --version | Boolean | Show npm-groovy-lint version (with CodeNarc version) |
72
+ | -p<br/> --path | String | (DEPRECATED) Directory containing the files to lint<br/> Example: `./path/to/my/groovy/files` |
73
+ | -f<br/> --files | String | (DEPRECATED) Comma-separated list of Ant-style file patterns specifying files that must be included.<br/> Default: `"**/*.groovy,**/Jenkinsfile,**/*.gradle"`<br/>Examples:<br/> - `"**/Jenkinsfile"`<br/> - `"**/*.groovy"`<br/> - `"**/*.gradle"`<br/> - `"**/mySingleFile.groovy"` |
72
74
 
73
75
  ## Installation
74
76
 
@@ -92,7 +94,7 @@ Create a file named **.groovylintrc.json** in the current or any parent director
92
94
  - Jenkinsfile
93
95
  - **.groovylintrc.json** _(do not forget the dot at the beginning of the file name)_
94
96
 
95
- *If you are using [VsCode Groovy Lint extension](https://marketplace.visualstudio.com/items?itemName=NicolasVuillamy.vscode-groovy-lint), just use QuickFix* ***Ignore in all files*** *and it will generate groovylintrc.json file*
97
+ *If you are using [VsCode Groovy Lint extension](https://marketplace.visualstudio.com/items?itemName=NicolasVuillamy.vscode-groovy-lint), just use QuickFix* ***Ignore in all files*** _and it will generate groovylintrc.json file_
96
98
 
97
99
  ### Format
98
100
 
@@ -145,6 +147,30 @@ OR
145
147
 
146
148
  ## Example calls
147
149
 
150
+ - Lint a file
151
+
152
+ ```shell
153
+ npm-groovy-lint path/to/my/groovy/file.groovy
154
+ ```
155
+
156
+ - Lint multiple files
157
+
158
+ ```shell
159
+ npm-groovy-lint path/to/my/groovy/file.groovy path/to/my/groovy/file2.groovy path/to/my/groovy/file3.groovy
160
+ ```
161
+
162
+ - Lint directory
163
+
164
+ ```shell
165
+ npm-groovy-lint path/to/my/groovy
166
+ ```
167
+
168
+ - Lint pattern
169
+
170
+ ```shell
171
+ npm-groovy-lint path/to/my/groovy/*.groovy
172
+ ```
173
+
148
174
  - Lint groovy with JSON output
149
175
 
150
176
  ```shell