npm-groovy-lint 11.1.1 → 11.1.2-beta202310250645.0

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.
package/README.md CHANGED
@@ -16,14 +16,14 @@
16
16
 
17
17
  ## Groovy & Jenkinsfile Linter, Formatter and Auto-fixer
18
18
 
19
- _**New: The [article about the story of npm-groovy-lint](https://nicolas.vuillamy.fr/a-groovy-journey-to-open-source-during-covid-19-npm-groovy-lint-8d88c7eecebc), and why you should dive in open-source community !**_
19
+ ***New: The [article about the story of npm-groovy-lint](https://nicolas.vuillamy.fr/a-groovy-journey-to-open-source-during-covid-19-npm-groovy-lint-8d88c7eecebc), and why you should dive in open-source community !***
20
20
 
21
21
  Based on [CodeNarc](http://codenarc.github.io/CodeNarc/) , this out of the box package allows to **track groovy errors** and **correct a part of them**
22
22
 
23
23
  - Use option **--format** to format & prettify source code
24
24
  - Use option **--fix** to activate autofixing of fixable rules
25
25
 
26
- Easy to integrate in a CD/CI process (Jenkins Pipeline,CircleCI...) to lint your groovy or Jenkinsfile at each build :)
26
+ Easy to integrate in a CI/CD process (Jenkins Pipeline,CircleCI...) to lint your groovy or Jenkinsfile at each build :)
27
27
 
28
28
  You can also use this package in :
29
29
 
@@ -45,14 +45,14 @@ Any **question**, **problem** or **enhancement request** ? Ask [**here**](https:
45
45
 
46
46
  | Parameter | Type | Description |
47
47
  |-------------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
48
- | -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"` |
48
+ | -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"`<br/>Note: HTML and XML are directly from CodeNarc so using these formats will disable many npm-groovy-lint features |
49
49
  | -l<br/> --loglevel | String | Log level (error,warning or info)<br/>Default: info |
50
50
  | --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. |
51
- | -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 |
51
+ | -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 |
52
52
  | --parse | Boolean | Try to compile the source code and return parse errors (since v5.7.0, default to true, use --no-parse to deactivate) |
53
53
  | --format | Boolean | Format source code |
54
- | --fix | Boolean | Automatically fix problems when possible<br/> See [Autofixable rules](#Autofixable-rules) |
55
- | -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/> |
54
+ | --fix | Boolean | Automatically fix problems when possible<br/> See [Auto-fixable rules](#auto-fixable-rules) |
55
+ | -x<br/> --fixrules | String | Option for --fix argument: List of rule identifiers to fix (if not specified, all available fixes will be applied). See [Auto-fixable rules](#auto-fixable-rules) <br/> Examples:<br/> - `"SpaceBeforeClosingBrace,SpaceAfterClosingBrace,UnusedImport"`<br/> - `"Indentation"`<br/> |
56
56
  | --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 |
57
57
  | -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` |
58
58
  | --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` |
@@ -137,6 +137,7 @@ Any **question**, **problem** or **enhancement request** ? Ask [**here**](https:
137
137
  ```shell
138
138
  npm install -g npm-groovy-lint
139
139
  ```
140
+
140
141
  - If you have issues with v9, install previous version with `npm install -g npm-groovy-lint@8.2.0`
141
142
  - Node.js >= 12 is required to run this package. If you can't upgrade, you can use [nvm](https://github.com/nvm-sh/nvm) to have [different node versions on your computer](https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/)
142
143
  - If you do not have java (from 8 to 14) installed on your computer npm-groovy-lint will install them for you, so the first run may be long.
@@ -152,16 +153,16 @@ Create a file named **.groovylintrc.json** in the current or any parent director
152
153
  - groovy
153
154
  - mygroovyfile.groovy
154
155
  - Jenkinsfile
155
- - **.groovylintrc.json** _(do not forget the dot at the beginning of the file name)_
156
+ - **.groovylintrc.json** *(do not forget the dot at the beginning of the file name)*
156
157
 
157
- *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_
158
+ *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.*
158
159
 
159
160
  ### Format
160
161
 
161
162
  - **extends**: Name of a base configuration ([`recommended`](https://github.com/nvuillam/npm-groovy-lint/blob/master/lib/.groovylintrc-recommended.json), [`recommended-jenkinsfile`](https://github.com/nvuillam/npm-groovy-lint/blob/master/lib/.groovylintrc-recommended-jenkinsfile.json), [`all`](https://github.com/nvuillam/npm-groovy-lint/blob/master/lib/.groovylintrc-all.json))
162
163
  - **rules**: List of rules definition, following format `"RuleSection.RuleName": ruleParameters` or `"RuleName": ruleParameters`
163
- - _RuleName_: any of the **[CodeNarc rules](https://codenarc.github.io/CodeNarc/codenarc-rule-index.html)**
164
- - _ruleParameters_: can be just a severity override ( `"off"`, `"error"`, `"warning"`, `"info"` ) , or a property list :
164
+ - *RuleName*: any of the **[CodeNarc rules](https://codenarc.github.io/CodeNarc/codenarc-rule-index.html)**
165
+ - *ruleParameters*: can be just a severity override ( `"off"`, `"error"`, `"warning"`, `"info"` ) , or a property list :
165
166
  - severity : off,error,warning,info
166
167
  - enabled : true (default) or false
167
168
  - any of the [rule advanced properties](https://codenarc.github.io/CodeNarc/codenarc-rule-index.html)
@@ -341,9 +342,9 @@ def variable = 1;
341
342
  - UnnecessaryToString
342
343
  - UnusedImport
343
344
 
344
- [Contribute](#Contribute) to add more [rules](http://codenarc.github.io/CodeNarc/codenarc-rule-index.html) fixes :)
345
+ [Contribute](#contribute) to add more [rules](http://codenarc.github.io/CodeNarc/codenarc-rule-index.html) fixes :)
345
346
 
346
- ## CD/CI
347
+ ## CI/CD
347
348
 
348
349
  ### Mega-Linter
349
350
 
@@ -445,9 +446,9 @@ Please follow [Contribution instructions](https://github.com/nvuillam/npm-groovy
445
446
 
446
447
  ### Contributors
447
448
 
448
- [<img alt="nvuillam" src="https://avatars1.githubusercontent.com/u/17500430?v=4&s=50 width=50">](https://github.com/nvuillam) | [<img alt="Dave Gallant" src="https://avatars2.githubusercontent.com/u/4519234?v=4&s=50 width=50">](https://github.com/davegallant) | [<img alt="warhod" src="https://avatars1.githubusercontent.com/u/1305176?v=4&s=50 width=50">](https://github.com/warhod) | [<img alt="pawelkopka" src="https://avatars1.githubusercontent.com/u/17784034?v=4&s=50 width=50">](https://github.com/pawelkopka) | [<img alt="docwhat" src="https://avatars1.githubusercontent.com/u/40799?v=4&s=50 width=50">](https://github.com/docwhat) | [<img alt="CatSue" src="https://avatars3.githubusercontent.com/u/26134618?v=4&s=50 width=50">](https://github.com/CatSue)
449
- :----------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------:
450
- [Nicolas Vuillamy](https://github.com/nvuillam) | [Dave Gallant](https://github.com/davegallant) | [Howard Lo](https://github.com/warhod) | [Pawel Kopka](https://github.com/pawelkopka) | [docwhat](https://github.com/docwhat) | [CatSue](https://github.com/CatSue)
449
+ | [<img alt="nvuillam" src="https://avatars1.githubusercontent.com/u/17500430?v=4&s=50 width=50">](https://github.com/nvuillam) | [<img alt="Dave Gallant" src="https://avatars2.githubusercontent.com/u/4519234?v=4&s=50 width=50">](https://github.com/davegallant) | [<img alt="warhod" src="https://avatars1.githubusercontent.com/u/1305176?v=4&s=50 width=50">](https://github.com/warhod) | [<img alt="pawelkopka" src="https://avatars1.githubusercontent.com/u/17784034?v=4&s=50 width=50">](https://github.com/pawelkopka) | [<img alt="docwhat" src="https://avatars1.githubusercontent.com/u/40799?v=4&s=50 width=50">](https://github.com/docwhat) | [<img alt="CatSue" src="https://avatars3.githubusercontent.com/u/26134618?v=4&s=50 width=50">](https://github.com/CatSue) |
450
+ |:-----------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------:|
451
+ | [Nicolas Vuillamy](https://github.com/nvuillam) | [Dave Gallant](https://github.com/davegallant) | [Howard Lo](https://github.com/warhod) | [Pawel Kopka](https://github.com/pawelkopka) | [docwhat](https://github.com/docwhat) | [CatSue](https://github.com/CatSue) |
451
452
 
452
453
  ## Release notes
453
454
 
@@ -2,12 +2,17 @@
2
2
  const axios = require("axios").default;
3
3
  const cliProgress = require("cli-progress");
4
4
  const debug = require("debug")("npm-groovy-lint");
5
+ const trace = require("debug")("npm-groovy-lint-trace");
5
6
  const { JavaCaller } = require("java-caller");
6
7
  const optionsDefinition = require("./options");
7
8
  const { performance } = require("perf_hooks");
8
9
  const { getSourceLines } = require("./utils");
9
10
  const c = require("chalk");
10
11
 
12
+ // Request over IPv4 because Java typically prefers it.
13
+ const http = require("http");
14
+ axios.defaults.httpAgent = new http.Agent({ family: 4, keepAlive: true });
15
+
11
16
  class CodeNarcCaller {
12
17
  "use strict";
13
18
 
@@ -85,16 +90,17 @@ class CodeNarcCaller {
85
90
  },
86
91
  timeout: 600000
87
92
  };
88
- debug(`CALL CodeNarcServer with ${JSON.stringify(axiosConfig, null, 2)}`);
93
+ trace(`CALL CodeNarcServer with ${JSON.stringify(axiosConfig, null, 2)}`);
89
94
  let response;
90
95
  try {
91
96
  const startCodeNarc = performance.now();
92
97
  response = await axios.request(axiosConfig);
93
98
  this.serverStatus = "running";
94
99
  const elapsed = parseInt(performance.now() - startCodeNarc, 10);
95
- debug(`CodeNarcServer call result: (${response.status}) ${elapsed}ms ${JSON.stringify(response.data || {})}`);
100
+ debug(`CodeNarcServer call result: (${response.status}) ${elapsed}ms`);
96
101
  } catch (e) {
97
102
  // If server not started , start it and try again
103
+ debug(`callCodeNarcServer code: ${e.code} error: ${e.message}`);
98
104
  if (
99
105
  (startServerTried === false,
100
106
  e.code && ["ECONNREFUSED", "ETIMEDOUT"].includes(e.code) && ["unknown", "running"].includes(this.serverStatus)) // running is here in case the Server auto-killed itself at its expiration time
@@ -178,7 +184,7 @@ class CodeNarcCaller {
178
184
  const scriptArgs = this.codenarcArgs;
179
185
 
180
186
  // Start progress bar
181
- debug(`CALL CodeNarcJava with ${scriptArgs.join(" ")}`);
187
+ trace(`CALL CodeNarcJava with ${scriptArgs.join(" ")}`);
182
188
  this.bar = new cliProgress.SingleBar(
183
189
  {
184
190
  format: "[{bar}] Running CodeNarc for {duration_formatted}",
@@ -208,7 +214,7 @@ class CodeNarcCaller {
208
214
  if ([666, 1].includes(javaResult.status)) {
209
215
  if (!secondAttempt) {
210
216
  // If failure (missing class com.nvuillam.CodeNarcServer for example, it can happen on Linux, let's try the original org.codenarc.CodeNarc class)
211
- debug(`Error calling CodeNarcServer via java: ${JSON.stringify(javaResult)}`);
217
+ trace(`Error calling CodeNarcServer via java: ${JSON.stringify(javaResult)}`);
212
218
  return await this.callCodeNarcJava(true);
213
219
  } else {
214
220
  let reason = "Reason: unknown";
@@ -272,12 +278,20 @@ class CodeNarcCaller {
272
278
  return false;
273
279
  }
274
280
 
281
+ // Store the process so we can stop it later.
282
+ this.codeNarcProcess = javaCallRes.childJavaProcess;
283
+
275
284
  // Poll it until it is ready
276
285
  const start = performance.now();
277
286
  let notified = false;
278
287
  let interval;
279
288
  await new Promise(resolve => {
280
289
  interval = setInterval(() => {
290
+ debug(
291
+ `pinging CodeNarcServer at ${serverPingUri} notified: ${notified}, serverStatus: ${
292
+ this.serverStatus
293
+ }, since: ${performance.now() - start}, maxAttemptTimeMs: ${maxAttemptTimeMs}`
294
+ );
281
295
  axios
282
296
  .get(serverPingUri)
283
297
  .then(response => {
@@ -291,18 +305,22 @@ class CodeNarcCaller {
291
305
  resolve();
292
306
  }
293
307
  } else if (notified === false && this.serverStatus === "unknown" && performance.now() - start > maxAttemptTimeMs) {
294
- // Timeout has been reached
295
- this.declareServerError(
296
- {
297
- message: "Timeout after " + maxAttemptTimeMs + "\nResponse: " + JSON.stringify(response.toJSON())
298
- },
299
- interval
300
- );
308
+ // Timeout has been reached.
309
+ let since = performance.now() - start;
310
+ debug(`Ping timeout after ${since}ms status: ${response.status}`);
311
+ this.declareServerError({ message: `Timeout after ${since}ms} status: ${response.status}` }, interval);
301
312
  resolve();
302
313
  }
303
314
  })
304
- .catch(() => {
305
- // Just do nothing
315
+ .catch(e => {
316
+ debug(`Ping code: ${e.code} message: ${e.message}`);
317
+ let since = performance.now() - start;
318
+ if (notified === false && this.serverStatus === "unknown" && since > maxAttemptTimeMs) {
319
+ // Timeout has been reached
320
+ debug(`Ping timeout after ${maxAttemptTimeMs}ms`);
321
+ this.declareServerError({ message: `Timeout after ${since}ms error: ${e}` }, interval);
322
+ resolve();
323
+ }
306
324
  });
307
325
  }, 400);
308
326
  });
@@ -315,8 +333,21 @@ class CodeNarcCaller {
315
333
  }
316
334
  }
317
335
 
336
+ // Kill CodeNarc process if running.
337
+ killCodeNarcProcess() {
338
+ if (this.codeNarcProcess) {
339
+ this.codeNarcProcess.kill("SIGKILL");
340
+ delete this.codeNarcProcess;
341
+ return "CodeNarcServer killed";
342
+ }
343
+ return "";
344
+ }
345
+
318
346
  // Stop polling and log error
319
347
  declareServerError(e, interval) {
348
+ // Kill off the process as it is not responding.
349
+ this.killCodeNarcProcess();
350
+
320
351
  this.serverStatus = "error";
321
352
  if (interval) {
322
353
  clearInterval(interval);
@@ -327,10 +358,16 @@ class CodeNarcCaller {
327
358
  console.error(c.grey(errMsg));
328
359
  }
329
360
 
330
- // Kill CodeNarc server by telling it to do so
361
+ // Kill CodeNarc server.
331
362
  async killCodeNarcServer() {
363
+ // Try by process first as it's more reliable.
364
+ let outputString = this.killCodeNarcProcess();
365
+ if (outputString) {
366
+ return outputString;
367
+ }
368
+
369
+ // Process kill wasn't possible, so try sending a kill http request.
332
370
  const serverUri = this.getCodeNarcServerUri() + "/kill";
333
- let outputString = "";
334
371
  try {
335
372
  const response = await axios.post(serverUri, { timeout: 5000 });
336
373
  if (response.data.status === "killed") {
@@ -339,10 +376,12 @@ class CodeNarcCaller {
339
376
  outputString = "Error killing CodeNarcServer";
340
377
  }
341
378
  } catch (e) {
342
- if (e.stack.includes("connResetException")) {
379
+ if (e.stack.includes("connResetException") || e.message.includes("socket hang up")) {
343
380
  outputString = "CodeNarcServer terminated";
344
381
  } else {
345
- outputString = "CodeNarcServer was not running";
382
+ // This should be ECONNREFUSED.
383
+ debug(`CodeNarcServer kill request failed: ${e}`);
384
+ outputString = `CodeNarcServer was not running`;
346
385
  }
347
386
  }
348
387
  return outputString;
@@ -56,10 +56,12 @@ async function prepareCodeNarcCall(options) {
56
56
 
57
57
  // Define base directory
58
58
  const baseBefore = (cnPath !== "." && cnPath.startsWith("/")) || cnPath.includes(":/") || cnPath.includes(":\\") ? "" : process.cwd() + "/";
59
- const codeNarcBaseDir = positionalArgs.length > 0 ?
60
- (await getCodeNarcBaseDirFromFiles(positionalArgs)) :
61
- cnPath !== "." ? baseBefore + cnPath.replace(/^"(.*)"$/, "$1") :
62
- process.cwd();
59
+ const codeNarcBaseDir =
60
+ positionalArgs.length > 0
61
+ ? await getCodeNarcBaseDirFromFiles(positionalArgs)
62
+ : cnPath !== "."
63
+ ? baseBefore + cnPath.replace(/^"(.*)"$/, "$1")
64
+ : process.cwd();
63
65
  result.codeNarcBaseDir = path.resolve(codeNarcBaseDir);
64
66
  result.codenarcArgs.push(`-basedir=${result.codeNarcBaseDir}`);
65
67
 
@@ -144,10 +146,10 @@ async function prepareCodeNarcCall(options) {
144
146
  result.outputType = result.output.endsWith(".txt")
145
147
  ? "txt"
146
148
  : result.output.endsWith(".json")
147
- ? "json"
148
- : result.output.endsWith(".sarif")
149
- ? "sarif"
150
- : result.output;
149
+ ? "json"
150
+ : result.output.endsWith(".sarif")
151
+ ? "sarif"
152
+ : result.output;
151
153
  result.codenarcArgs.push(`-report=json:stdout`);
152
154
  } else if (["html", "xml"].includes(result.output.split(".").pop())) {
153
155
  result.outputType = result.output
@@ -156,11 +158,11 @@ async function prepareCodeNarcCall(options) {
156
158
  .endsWith("html")
157
159
  ? "html"
158
160
  : result.output
159
- .split(".")
160
- .pop()
161
- .endsWith("xml")
162
- ? "xml"
163
- : "";
161
+ .split(".")
162
+ .pop()
163
+ .endsWith("xml")
164
+ ? "xml"
165
+ : "";
164
166
  const ext = result.output.split(".").pop();
165
167
  result.codenarcArgs.push(`-report=${ext}:${result.output}`);
166
168
 
@@ -183,9 +185,9 @@ async function prepareCodeNarcCall(options) {
183
185
  async function getCodeNarcBaseDirFromFiles(positionalArgs) {
184
186
  // All arguments are not files
185
187
  if (!positionalArgs.every(fileOrDirOrPattern => fs.existsSync(fileOrDirOrPattern) || directoryExists(fileOrDirOrPattern))) {
186
- return process.cwd()
188
+ return process.cwd();
187
189
  }
188
- const folders = positionalArgs.map((fileOrDir) => {
190
+ const folders = positionalArgs.map(fileOrDir => {
189
191
  // Dir
190
192
  if (directoryExists(fileOrDir)) {
191
193
  return path.resolve(fileOrDir);
@@ -195,7 +197,7 @@ async function getCodeNarcBaseDirFromFiles(positionalArgs) {
195
197
  return path.dirname(fileAbsolute);
196
198
  });
197
199
  const baseDirFromFiles = commondir(folders);
198
- return baseDirFromFiles
200
+ return baseDirFromFiles;
199
201
  }
200
202
 
201
203
  // Parse XML result file as js object
@@ -327,7 +329,7 @@ async function parseCodeNarcResult(options, codeNarcBaseDir, codeNarcJsonResult,
327
329
  }
328
330
  // Add unprecise range based on line when range function has not been defined on rule
329
331
  else if (errItem.line > 0) {
330
- const range = evaluateRangeFromLine(errItem, allLines);
332
+ const range = evaluateRangeFromLine(errItem, allLines);
331
333
  if (range && range.start.character > -1) {
332
334
  errItem.range = range;
333
335
  }
@@ -419,8 +421,8 @@ async function buildRuleSets(options) {
419
421
  typeof ruleFromConfig === "object"
420
422
  ? Object.assign(ruleFromConfig, ruleOptions)
421
423
  : Object.keys(ruleOptions).length > 0
422
- ? ruleOptions
423
- : ruleFromConfig;
424
+ ? ruleOptions
425
+ : ruleFromConfig;
424
426
  const ruleDef = buildCodeNarcRule(ruleName, mergedRuleConfig);
425
427
  // If rule has been sent as argument, enable it by default
426
428
  if (ruleDef.enabled === false) {
@@ -441,8 +443,8 @@ async function buildRuleSets(options) {
441
443
  typeof ruleDef === "object"
442
444
  ? Object.assign(ruleDef, ruleFromRuleSetsArg)
443
445
  : Object.keys(ruleFromRuleSetsArg).length > 0
444
- ? ruleFromRuleSetsArg
445
- : ruleDef;
446
+ ? ruleFromRuleSetsArg
447
+ : ruleDef;
446
448
  }
447
449
  // Add in the list of rules to test , except if it is disabled
448
450
  if (!(ruleDef === "off" || ruleDef.disabled === true || ruleDef.enabled === false)) {
@@ -2,6 +2,7 @@
2
2
  const fse = require("fs-extra");
3
3
  const cliProgress = require("cli-progress");
4
4
  const debug = require("debug")("npm-groovy-lint");
5
+ const trace = require("debug")("npm-groovy-lint-trace");
5
6
  const os = require("os");
6
7
  const { getNpmGroovyLintRules, getFormattingRulesToAlwaysRun } = require("./groovy-lint-rules.js");
7
8
  const { evaluateVariables, getSourceLines } = require("./utils.js");
@@ -135,7 +136,7 @@ class NpmGroovyLintFix {
135
136
  return a.rule.priority > b.rule.priority ? 1 : a.rule.priority < b.rule.priority ? -1 : 0;
136
137
  });
137
138
  }
138
- debug(`Parsed fixable errors: ${JSON.stringify(this.fixableErrors)}`);
139
+ trace(`Parsed fixable errors: ${JSON.stringify(this.fixableErrors)}`);
139
140
  }
140
141
 
141
142
  // Add fixable error but do not add twice if scope if the full file
@@ -256,7 +257,7 @@ class NpmGroovyLintFix {
256
257
  if (strBefore instanceof RegExp || (!strBefore.includes("{{") && !strAfter.includes("{{"))) {
257
258
  newLine = newLine.replace(strBefore, strAfter);
258
259
  } else {
259
- debug("GroovyLint: missing replacement variable(s):\n" + strBefore + "\n" + strAfter + "\n" + JSON.stringify(fixableError));
260
+ trace(`GroovyLint: missing replacement variable(s):\n${strBefore}\n${strAfter}\n${JSON.stringify(fixableError)}`);
260
261
  }
261
262
  }
262
263
  // Function defined in rule
@@ -267,7 +268,7 @@ class NpmGroovyLintFix {
267
268
  }
268
269
  newLine = fix.func(newLine, evaluatedVars, fixableError);
269
270
  } catch (e) {
270
- debug("ERROR: Fix function error: " + e.message + " / " + JSON.stringify(fixableError));
271
+ trace(`ERROR: Fix function error: ${e.message} / ${JSON.stringify(fixableError)}`);
271
272
  throw e;
272
273
  }
273
274
  }
@@ -1,5 +1,6 @@
1
1
  // Imports
2
2
  const debug = require("debug")("npm-groovy-lint");
3
+ const trace = require("debug")("npm-groovy-lint-trace");
3
4
  const fs = require("fs-extra");
4
5
  const os = require("os");
5
6
  const performance = require("perf_hooks").performance;
@@ -139,16 +140,15 @@ class NpmGroovyLint {
139
140
  }
140
141
  }
141
142
  // Try to catch input from stdin. if found, use it as groovy source
142
- if (this.options._ && this.options._[0] === '-') {
143
- const stdInData = fs.readFileSync(0, 'utf-8');
143
+ if (this.options._ && this.options._[0] === "-") {
144
+ const stdInData = fs.readFileSync(0, "utf-8");
144
145
  this.options.source = stdInData;
145
146
  this.options._ = [];
146
147
  this.options.sourcefilepath = this.options.sourcefilepath || process.cwd();
147
148
  if (this.options.format || this.options.fix) {
148
- this.options.output = 'stdout';
149
+ this.options.output = "stdout";
149
150
  }
150
151
  }
151
-
152
152
  } catch (err) {
153
153
  this.status = 2;
154
154
  this.error = {
@@ -231,7 +231,7 @@ class NpmGroovyLint {
231
231
  - Call CodeNarcServer via Http (except if --noserver)
232
232
  - Launch CodeNarcServer using com.nvuillam.CodeNarcServer, then call CodeNarcServer via Http (except if --noserver)
233
233
  - Call CodeNarc java using com.nvuillam.CodeNarcServer (without launching server)
234
- - Call CodeNarc java using org.codenarc.CodeNarc
234
+ - Call CodeNarc java using org.codenarc.CodeNarc
235
235
  */
236
236
  async callCodeNarc() {
237
237
  const startPerf = performance.now();
@@ -358,7 +358,7 @@ class NpmGroovyLint {
358
358
  }
359
359
  lintAgainOptions.fix = false;
360
360
  lintAgainOptions.output = "none";
361
- debug(`Fix is done, lint again with options ${JSON.stringify(lintAgainOptions)}`);
361
+ trace(`Fix is done, lint again with options ${JSON.stringify(lintAgainOptions)}`);
362
362
  const newLinter = new NpmGroovyLint(lintAgainOptions, {
363
363
  parseOptions: false,
364
364
  origin: "lintAgainAfterFix"
@@ -469,18 +469,18 @@ class NpmGroovyLint {
469
469
  manageReturnCode() {
470
470
  if (this.status > 1) {
471
471
  // There has been a fatal error before, so there are no results
472
- return ;
472
+ return;
473
473
  }
474
474
  const failureLevel =
475
475
  this.options.failon && this.options.failon !== "none"
476
476
  ? this.options.failon
477
477
  : this.options.failonerror
478
- ? "error"
479
- : this.options.failonwarning
480
- ? "warning"
481
- : this.options.failoninfo
482
- ? "info"
483
- : "none";
478
+ ? "error"
479
+ : this.options.failonwarning
480
+ ? "warning"
481
+ : this.options.failoninfo
482
+ ? "info"
483
+ : "none";
484
484
  if (failureLevel === "none") {
485
485
  return;
486
486
  }
package/lib/index.js CHANGED
File without changes
Binary file
Binary file
Binary file
package/lib/options.js CHANGED
@@ -177,7 +177,7 @@ module.exports = optionator({
177
177
  {
178
178
  option: "serverhost",
179
179
  type: "String",
180
- default: "http://localhost", //"http://" + require("ip").address(),
180
+ default: "http://localhost",
181
181
  description: "If use of CodeNarc server, host where is the CodeNarc server (default: localhost)"
182
182
  },
183
183
  {
package/lib/output.js CHANGED
@@ -109,12 +109,12 @@ async function processOutput(outputType, output, lintResult, options, fixer = nu
109
109
  for (const fileNm of Object.keys(lintResult.files)) {
110
110
  const fileErrors = lintResult.files[fileNm].errors;
111
111
  let fileOutputString = c.underline(fileNm) + "\n";
112
- let showFileInOutput = false ;
112
+ let showFileInOutput = false;
113
113
  for (const err of fileErrors) {
114
114
  if (!isErrorInLogLevelScope(err.severity, options.loglevel)) {
115
115
  continue;
116
116
  }
117
- showFileInOutput = true ;
117
+ showFileInOutput = true;
118
118
  let color = "grey";
119
119
  switch (err.severity) {
120
120
  case "error":
@@ -150,7 +150,7 @@ async function processOutput(outputType, output, lintResult, options, fixer = nu
150
150
  }
151
151
  fileOutputString += "\n";
152
152
  if (showFileInOutput || options.verbose) {
153
- outputString += fileOutputString ;
153
+ outputString += fileOutputString;
154
154
  }
155
155
  }
156
156
  outputString += "\nnpm-groovy-lint results in " + c.bold(lintResult.summary.totalFilesLinted) + " linted files:";
package/lib/utils.js CHANGED
@@ -2,6 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  const debug = require("debug")("npm-groovy-lint");
5
+ const trace = require("debug")("npm-groovy-lint-trace");
5
6
  const decodeHtml = require("decode-html");
6
7
  const fse = require("fs-extra");
7
8
  const os = require("os");
@@ -124,7 +125,7 @@ function evaluateRange(errItem, rule, evaluatedVars, errLine, allLines) {
124
125
 
125
126
  // Get position to highlight in sources
126
127
  function evaluateRangeFromLine(errItem, allLines) {
127
- return getDefaultRange(allLines, errItem)
128
+ return getDefaultRange(allLines, errItem);
128
129
  }
129
130
 
130
131
  // Evaluate variables from messages
@@ -142,14 +143,14 @@ function evaluateVariables(variableDefs, msg) {
142
143
  varDef.type && varDef.type === "number"
143
144
  ? parseInt(value, 10)
144
145
  : varDef.type && varDef.type === "array"
145
- ? JSON.parse(value)
146
- : value;
146
+ ? JSON.parse(value)
147
+ : value;
147
148
  evaluatedVars.push({
148
149
  name: varDef.name,
149
150
  value: varValue
150
151
  });
151
152
  } else {
152
- debug("GroovyLint: Unable to match " + varDef.regex + " in " + msg);
153
+ trace(`GroovyLint: Unable to match ${varDef.regex} in ${msg}`);
153
154
  }
154
155
  }
155
156
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "npm-groovy-lint",
3
- "version": "11.1.1",
3
+ "version": "11.1.2-beta202310250645.0",
4
4
  "description": "Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "lint:fix": "eslint **/*.js --fix && prettier --write \"./lib/**/*.{js,jsx}\" --tab-width 4 --print-width 150",
8
- "groovy:run-server-from-source": "npm run dev:kill-server && groovy -cp \"lib/java/CodeNarc-3.1.0.jar;lib/java/groovy/lib/groovy-3.0.9.jar;lib/java/groovy/lib/groovy-templates-3.0.9.jar;lib/java/groovy/lib/groovy-xml-3.0.9.jar;lib/java/groovy/lib/groovy-json-3.0.9.jar;lib/java/groovy/lib/groovy-ant-3.0.9.jar;lib/java/groovy/lib/ant-1.10.11.jar;lib/java/groovy/lib/ant-launcher-1.10.11.jar;lib/java/slf4j-api-1.7.9.jar;lib/java/log4j-slf4j-impl-2.18.0.jar;lib/java/log4j-api-2.18.0.jar;lib/java/log4j-core-2.18.0.jar;lib/java/GMetrics-2.1.0.jar\" groovy/src/main/com/nvuillam/CodeNarcServer.groovy --server",
9
- "groovy:build": "npm run dev:kill-server && groovyc -cp \"./lib/java*\" --encoding utf-8 ./groovy/src/main/com/nvuillam/CodeNarcServer.groovy -d ./tmp && cd ./tmp && jar -cvfm ./../lib/java/CodeNarcServer.jar ./../MANIFEST.txt ./com/nvuillam/*.class && cd ..",
8
+ "groovy:run-server-from-source": "npm run dev:kill-server && groovy -cp \"lib/java/*\" groovy/src/main/com/nvuillam/CodeNarcServer.groovy --server",
9
+ "groovy:build": "npm run dev:kill-server && groovyc -cp \"lib/java/*\" --encoding utf-8 ./groovy/src/main/com/nvuillam/CodeNarcServer.groovy -d ./tmp && cd ./tmp && jar -cvfm ./../lib/java/CodeNarcServer.jar ./../MANIFEST.txt ./com/nvuillam/*.class && cd ..",
10
10
  "test": "npm run dev:kill-server && mocha \"test/**/*.test.js\"",
11
11
  "test:coverage": "nyc npm run test",
12
12
  "test:debug": "npm run dev:kill-server && mocha --reporter spec --inspect-brk \"test/**/*.test.js\"",
@@ -48,7 +48,7 @@
48
48
  "ansi-colors": "^4.1.1",
49
49
  "axios": "^0.21.1",
50
50
  "chalk": "^4.1.2",
51
- "cli-progress": "^3.10.0",
51
+ "cli-progress": "^3.12.0",
52
52
  "commondir": "^1.0.1",
53
53
  "debug": "^4.1.1",
54
54
  "decode-html": "^2.0.0",
@@ -60,25 +60,25 @@
60
60
  "ip": "^1.1.5",
61
61
  "java-caller": "^2.2.4",
62
62
  "js-yaml": "^4.1.0",
63
- "node-sarif-builder": "^2.0.1",
63
+ "node-sarif-builder": "^2.0.3",
64
64
  "optionator": "^0.8.3",
65
65
  "semver": "^7.1.3",
66
66
  "strip-json-comments": "^3.0.1",
67
67
  "uuid": "^8.2.0"
68
68
  },
69
69
  "devDependencies": {
70
- "@babel/core": "^7.16.0",
71
- "@babel/eslint-parser": "^7.16.3",
70
+ "@babel/core": "^7.23.2",
71
+ "@babel/eslint-parser": "^7.22.15",
72
72
  "diff": "^4.0.2",
73
- "eslint": "^8.2.0",
74
- "mocha": "^10.1.0",
73
+ "eslint": "^8.52.0",
74
+ "mocha": "^10.2.0",
75
75
  "nyc": "^15.1.0",
76
76
  "prettier": "^1.19.1",
77
77
  "rimraf": "^3.0.2",
78
78
  "which": "^2.0.2"
79
79
  },
80
80
  "engines": {
81
- "node": ">=12.0.0"
81
+ "node": ">=18.0.0"
82
82
  },
83
83
  "mocha": {
84
84
  "require": [
package/CHANGELOG.md DELETED
@@ -1,623 +0,0 @@
1
- # Changelog
2
-
3
- ## UNRELEASED
4
-
5
- ## [11.1.1] 2022-10-31
6
-
7
- - Fix npm dependency minimatch
8
-
9
- ## [11.1.0] 2022-10-31
10
-
11
- - Provide default range when only information available is a line number ([#248](https://github.com/nvuillam/npm-groovy-lint/issues/248))
12
- - New CodeNarc issues definition to calculate range in file
13
- - GStringExpressionWithinString
14
- - VariableName
15
-
16
- ## [11.0.0] 2022-10-07
17
-
18
- - **BREAKING CHANGE**:`--failon` is now `ìnfo` by default, meaning exit code will be `1` if there is at least an info issue found. To have previous behaviour, use `--failon none`.
19
- - Display all files in console log only if `--verbose` is used ([#243](https://github.com/nvuillam/npm-groovy-lint/issues/243))
20
-
21
- ## [10.1.0] 2022-08-15
22
-
23
- - Allow to send groovy sources as input from stdin
24
- - If `--format` or `--fix` option is used when source is sent as stdin, the result is output as stdout
25
-
26
- Example: `cat path/to/my/Jenkinsfile | npm-groovy-lint --format -`
27
-
28
- ## [10.0.3] 2022-08-15
29
-
30
- - Do not output results summary in console logs when output is json or sarif
31
- - Add test methods for SARIF called by CLI
32
-
33
- ## [10.0.2] 2022-08-15
34
-
35
- - Fix error when absolute files sent as positional arguments on a linux system ([#232](https://github.com/nvuillam/npm-groovy-lint/issues/232))
36
- - Improve performances by calculating the longest command directory to send as base path to CodeNarc
37
-
38
- ## [10.0.1] 2022-08-14
39
-
40
- - Fix error when files sent as positional arguments ([#232](https://github.com/nvuillam/npm-groovy-lint/issues/232))
41
-
42
- ## [10.0.0] 2022-08-13
43
-
44
- - Core
45
- - Upgrade to [CodeNarc v3.1.0](https://github.com/CodeNarc/CodeNarc/blob/master/CHANGELOG.md#version-310----jun-2022)
46
- - Accept list of directories / files as arguments (`--path` and `--files` become deprecated but are still usable)
47
- - Examples
48
- - Multiple files: `npm-groovy-lint path/to/file1.groovy path/to/file2.groovy`
49
- - Directory: `npm groovy-lint path/to`
50
- - Single file: `npm-groovy-lint Jenkinsfile`
51
- - Ant pattern(s): `npm-groovy-lint path/to/**/*.groovy`
52
- - Upgrade npm dependencies
53
- - CI: Upgrade [MegaLinter](https://oxsecurity.github.io/megalinter/latest/) to v6
54
- - Test classes for collecting error ranges
55
-
56
- - New error ranges rules
57
- - DuplicateNumberLiteral
58
- - DuplicateStringLiteral
59
- - MethodParameterTypeRequired
60
- - NoDef
61
- - SimpleDateFormatMissingLocale
62
- - SpaceInsideParenthesis
63
- - UnnecessaryPublicModifier
64
- - VariableTypeRequired
65
-
66
- - New fix rules
67
- - SpaceAfterMethodCallName
68
- - SpaceInsideParentheses
69
-
70
- - Bug Fixes
71
- - Wrongly calculated ranges are no more returned
72
-
73
- ## [9.5.0] 2022-04-12
74
-
75
- - Disable Amplitude anonymous stats by default (use `--insight` to enable them)
76
-
77
- ## [9.4.1] 2022-01-12
78
-
79
- - Upgrade node-sarif-builder to 2.0.1 and send npm-groovy-lint version in SARIF logs
80
- - New range detection for rules:
81
- - MethodReturnTypeRequired
82
- - UnusedImport
83
-
84
- ## [9.4.0] 2022-01-11
85
-
86
- - Add [SARIF](https://sarifweb.azurewebsites.net/) output format using [node-sarif-builder](https://github.com/nvuillam/node-sarif-builder)
87
-
88
- ## [9.3.2] 2022-01-09
89
-
90
- - Upgrade cli-progress to avoid [colors lib boring but harmless hack](https://github.com/Marak/colors.js/issues/285)
91
-
92
- ## [9.3.1] 2022-01-06
93
-
94
- - Fix issue when used as module and with file containing spaces ([VsCodeGroovyLint #137](https://github.com/nvuillam/vscode-groovy-lint/issues/137))
95
-
96
- ## [9.3.0] 2021-12-29
97
-
98
- - Upgrade log4j dependencies because of [security issue](https://nvd.nist.gov/vuln/detail/CVE-2021-44832).
99
-
100
- ## [9.2.0] 2021-12-23
101
-
102
- - Upgrade log4j dependencies because of (another) [security issue](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-45105) (#196)
103
-
104
- ## [9.1.0] 2021-12-14
105
-
106
- - Upgrade log4j dependencies because of [security issue](https://unit42.paloaltonetworks.com/apache-log4j-vulnerability-cve-2021-44228/) (#194)
107
-
108
- ## [9.0.0] 2021-09-30
109
-
110
- - Upgrade to [CodeNarc v2.2.0](https://github.com/CodeNarc/CodeNarc/releases/tag/v2.2.0)
111
- - Upgrade to [Groovy v3.0.9](https://groovy-lang.org/)
112
- - Reorganize sources test folder
113
- - Use java from 8 to 14 (install it if a later version is found)
114
- - Add timeouts in CI jobs
115
- - Add colors in error logs
116
-
117
- ## [8.2.0] 2021-06-11
118
-
119
- - Upgrade dependencies advised by dependabot
120
- - Fix Mega-Linter errors found
121
-
122
- ## [8.1.0] 2020-12-14
123
-
124
- - Exclude `UnnecessaryGetter`, `FactoryMethodName`, `MethodReturnTypeRequired`, and `GStringExpressionWithinString` in `recommended-jenkinsfile` ([#140](https://github.com/nvuillam/npm-groovy-lint/pull/140)) ([Felipe Santos](https://github.com/felipecrs))
125
-
126
- ## [8.0.2] 2020-11-26
127
-
128
- - Fix documentation about --verbose and --version options
129
- - Use GitHub action to deploy to NPM
130
-
131
- ## [8.0.1] 2020-11-19
132
-
133
- - Add a test case where variable includes if in its name for fix of rule SpaceAfterIf ([Behlül Uçar](https://github.com/ucarbehlul))
134
-
135
- ## [8.0.0] 2020-11-15
136
-
137
- - Upgrade to CodeNarc 2.0.0
138
- - Upgrade jars
139
- - Adapt Indentation rule to new behaviour
140
- - Use codenarc --ruleset argument instead of temp ruleset file
141
- - Replace super-linter by [Mega-Linter](https://nvuillam.github.io/mega-linter/)
142
- - Fixes
143
- - [(#127)](https://github.com/nvuillam/npm-groovy-lint/issues/127) Formatting breaks code, converting `else if` into `elseif` in some cases
144
- - Apply formatting rules also for --fix mode
145
- - Fix Markdown dead links
146
- - CI
147
- - Migrate from CircleCI to GitHub Actions: now tests are on Linux, Windows & MacOs
148
- - Activate spelling linter of Mega-Linter (+ `.cspell.json` file)
149
- - Add test cases for format and fix using CLI
150
-
151
- ## [7.6.2] 2020-09-09
152
-
153
- - Disable TrailingComma rule by default until crash is solved in [CodeNarc](https://codenarc.github.io/CodeNarc) ([#75@vscode-groovy-lint](https://github.com/nvuillam/vscode-groovy-lint/issues/75))
154
-
155
- ## [7.6.0] 2020-09-08
156
-
157
- - Add GitHub Action [GitHub Super-Linter](https://github.com/marketplace/actions/super-linter) to the repository
158
- - Update Dockerfile to pass Docker lint rules
159
-
160
- ## [7.5.5] 2020-09-05
161
-
162
- - Upgrade [java-caller](https://github.com/nvuillam/node-java-caller) to v2.2.3
163
- - Fix Java 8 detection ([#101](https://github.com/nvuillam/npm-groovy-lint/issues/101))
164
-
165
- ## [7.5.4] 2020-09-04
166
-
167
- - Update frameworks detection
168
-
169
- ## [7.5.1] 2020-09-02
170
-
171
- - Fix [(#96)](https://github.com/nvuillam/npm-groovy-lint/issues/96) --fix adds redundant space into `${VARIABLE}` (SpaceBeforeOpeningBrace fix rule error)
172
- - Fix grails framework detection
173
- - Fix Groovy parsing parsing when multiple files
174
- - Add `.gvy` and `.nf` in default browsed files extensions
175
-
176
- ## [7.5.0] 2020-09-02
177
-
178
- - Add anonymous framework usage stats for Groovy core Team
179
-
180
- ## [7.4.3] 2020-08-29
181
-
182
- - Upgrade [java-caller](https://github.com/nvuillam/node-java-caller) to v2.2.0
183
- - Fix CLASSPATH on windows in case there are spaces in paths
184
-
185
- ## [7.4.2] 2020-08-26
186
-
187
- - Fix [(#90)](https://github.com/nvuillam/npm-groovy-lint/issues/90) When log level is specified number of linted files appear to be off
188
-
189
- ## [7.4.1] 2020-08-23
190
-
191
- - [(#88)](https://github.com/nvuillam/npm-groovy-lint/pull/88) Fix Docker image to allow to use extra parameters (by [Howard Lo](https://github.com/warhod))
192
-
193
- ## [7.4.0] 2020-08-17
194
-
195
- - [(#87)](https://github.com/nvuillam/npm-groovy-lint/pull/87) update to openjdk 11 in [official Docker image](https://hub.docker.com/r/nvuillam/npm-groovy-lint) (by [Pawel Kopka](https://github.com/pawelkopka))
196
-
197
- ## [7.3.1] 2020-08-16
198
-
199
- - Add number of lines & reorganize anonymous statistics
200
- - Fix error type counters in anonymous statistics
201
-
202
- ## [7.3.0] 2020-08-15
203
-
204
- - Allow to link to [CodeNarc RuleSet files](https://codenarc.github.io/CodeNarc/codenarc-creating-ruleset.html) from `.groovylintrc.json`, using property `"codenarcRulesets"`. Warning: doing so means that all other properties of config file will be ignored.
205
-
206
- ## [7.1.1] 2020-08-11
207
-
208
- - Upgrade [java-caller](https://www.npmjs.com/package/java-caller) to v2.0.0
209
-
210
- ## [7.1.0] 2020-08-10
211
-
212
- - Externalize JavaCaller class into a separate package [java-caller](https://www.npmjs.com/package/java-caller) and use it
213
-
214
- ## [7.0.0] 2020-08-07
215
-
216
- - New default recommended rules (activate/deactivate/change severity)
217
- - Allow to call `--config recommended-jenkinsfile` to use delivered .groovylintrc-recommended-jenkinsfile.json
218
-
219
- ## [6.1.1] 2020-08-04
220
-
221
- - Fix SpaceAfterComma auto-fixing rule
222
-
223
- ## [6.1.0] 2020-08-04
224
-
225
- - Java 14 compatibility (Closes [#77](https://github.com/nvuillam/npm-groovy-lint/issues/7))
226
-
227
- ## [6.0.0] 2020-08-03
228
-
229
- - Upgrade to [CodeNarc v1.6.1](https://github.com/CodeNarc/CodeNarc/blob/v1.6-patch-releases/CHANGELOG.md#version-161----aug-2020)
230
- - Update list of rules
231
- - Use new CodeNarc JSON console Output instead of temporary XML files
232
- - Call CodeNarc to get its version instead of using npm-groovy-lint hardcoded value
233
- - Upgrade to [GMetrics v1.1](https://github.com/dx42/gmetrics/blob/master/CHANGELOG.md#version-11-may-2020)
234
- - Upgrade to [Groovy v3.0.5](https://groovy-lang.org/)
235
- - Add anonymous usage stats on types of errors found and fixed
236
-
237
- ## [5.8.0] 2020-08-01
238
-
239
- - Fix & enhance anonymous statistics
240
-
241
- ## [5.7.0] 2020-07-23
242
-
243
- - [(#62)](https://github.com/nvuillam/npm-groovy-lint/pull/74) Check parse error in all files when called via CLI . Closes [#69](https://github.com/nvuillam/npm-groovy-lint/issues/69)
244
-
245
- ## [5.6.1] 2020-07-20
246
-
247
- Fixes:
248
-
249
- - [(#62)](https://github.com/nvuillam/npm-groovy-lint/issues/62) using a codenarc ruleset file seems to fail / groovylintrc is not codenarc compatible
250
-
251
- ## [5.6.0] 2020-07-20
252
-
253
- - [(#68)](https://github.com/nvuillam/npm-groovy-lint/pull/68) Generate a [ready-to-use docker image](https://hub.docker.com/r/nvuillam/npm-groovy-lint) when publishing new npm-groovy-lint version (by [Dave Gallant](https://github.com/davegallant))
254
-
255
- ## [5.5.1] 2020-07-15
256
-
257
- - Fixes
258
- - [(#64)](https://github.com/nvuillam/vscode-groovy-lint/issues/64) The contents of a string gets formatted unexpectedly
259
-
260
- ## [5.5.0] 2020-07-09
261
-
262
- - Allow to override java executable and options [(#54)](https://github.com/nvuillam/vscode-groovy-lint/issues/54)
263
-
264
- ## [5.4.2] 2020-07-09
265
-
266
- - Use os.EOL [(#65)](https://github.com/nvuillam/npm-groovy-lint/pull/65) solving [(#63)](https://github.com/nvuillam/npm-groovy-lint/issues/63) --fix for indentation adds CRLF line-endings to all files it touches
267
-
268
- ## [5.4.1] 2020-07-01
269
-
270
- - CodeNarcServer listens to localhost only [(#59)](https://github.com/nvuillam/npm-groovy-lint/pull/59) solving [(#56)](https://github.com/nvuillam/npm-groovy-lint/issues/56)
271
- - Replace @analytics/segment with @amplitude/node for anonymous stats
272
-
273
- ## [5.3.0] 2020-06-29
274
-
275
- - New option **--failon** , replacing `--failonerror`,`--failonwarning` and `--failoninfo`. It can take error, warning or info values (default: none). Previous options remain working but are deprecated and will be removed in a future major version
276
- - Update help for `--fixrules` option
277
-
278
- ## [5.1.0] 2020-06-04
279
-
280
- - Install Java 8 using node-jre in case java version found is higher than Java 11 (CodeNarc compatibility is Java 8 to 11)
281
-
282
- ## [5.0.3] 2020-05-30
283
-
284
- - Updated fix rules
285
- - Indentation
286
- - IndentationClosingBrace
287
-
288
- ## [5.0.2] 2020-05-27
289
-
290
- - Avoid to apply wrong fix in case of CodeNarc false positive
291
- - New fix rules
292
- - BlankLineBeforePackage
293
- - Updated fix rules
294
- - BracesForIfElse
295
- - BracesForMethod
296
- - BracesForTryCatchFinally
297
- - ClassEndsWithBlankLine
298
- - ClassStartsWithBlankLine
299
- - MissingBlankLineAfterImports
300
- - MissingBlankLineAfterPackage
301
- - UnnecessaryGroovyImport
302
- - UnusedImport
303
-
304
- ## [5.0.0] 2020-05-25
305
-
306
- - **BIG BANG**: Improve performances, compatibility, architecture and delivery
307
- - Get rid of [jDeploy](https://github.com/shannah/jdeploy) dependency
308
- - Use own **java-caller.js** for java commands
309
- - Update CircleCI config to use `npm link`instead of `jdeploy install`
310
- - Get rid of [request](https://github.com/request/request) dependency
311
- - Use [axios](https://github.com/axios/axios) for promisified http calls
312
-
313
- ## [4.14.0] 2020-05-22
314
-
315
- - Send rule configuration to fix functions
316
- - Add `.gradle` files in default linted files
317
- - Fixes:
318
- - Missing number of linted files returned in summary
319
- - Try to call CodeNarcJava in case there is an error with CodeNarcServer call
320
-
321
- ## [4.13.0] 2020-05-20
322
-
323
- - Manage to send options for rules sent in `rulesets`: Ex: `Indentation{"spacesPerIndentLevel":2,"severity":"warning"},UnnecessarySemicolon`
324
- - New parameter `--rulesetsoverridetype` : If list of rules sent in rulesets option, defines if they replace rules defined in .groovylintrc.json, or if they are appended
325
-
326
- ## [4.12.0] 2020-05-18
327
-
328
- - Improve performances and avoid `Unknown command: node` error by using childProcess.fork to call CodeNarcServer
329
-
330
- ## [4.11.1] 2020-05-16
331
-
332
- - Detect when crash is related to "node" or "java" command not found and return a human readable error message
333
-
334
- ## [4.11.0] 2020-05-13
335
-
336
- - Add CI , rule overrides and crashes in anonymous insights for debugging investigation
337
- - When used as a module, **never crash intentionally with throw**, so when called by module, check linter.status and linter.error instead of try/catch
338
- - 0: ok
339
- - 1: expected error
340
- - 2: unexpected error
341
- - 9: if cancelled request
342
-
343
- ## [4.10.0] 2020-05-12
344
-
345
- - Update analytics to use [analytics](https://www.npmjs.com/package/analytics) & [@analytics-segment](https://github.com/DavidWells/analytics/tree/master/packages/analytics-plugin-segment) instead of [insight](https://www.npmjs.com/package/insight). If you want to disable anonymous usage stats, you can still use `--no-insight` option.
346
-
347
- ## [4.9.0] 2020-05-10
348
-
349
- - Add anonymous usage statistics using [insight](https://www.npmjs.com/package/insight), in order to make new improvements based on how users use this package.
350
- - Note: 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). If you want to disable anonymous usage stats, use `--no-insight` option.
351
-
352
- ## [4.8.0] 2020-05-08
353
-
354
- - New fix rules
355
- - AssignmentInConditional
356
- - DuplicateImport
357
- - ExplicitLinkedListInstantiation
358
- - InsecureRandom
359
- - UnnecessaryDefInVariableDeclaration
360
- - UnnecessaryDotClass
361
- - UnnecessaryFinalOnPrivateMethod
362
- - UnnecessaryInstantiationToGetClass
363
-
364
- - Updated fix rules
365
- - BracesForForLoop: False positive triggering messy code after fixing
366
- - UnnecessaryGString: Fix multiline replacements ( `"""` by `'''` )
367
-
368
- - Fixes :
369
- - Launch JVM with high memory (`-Xms256m -Xmx2048m`) to improve performances on big files
370
- - Increase CodeNarcServ call timeout (+ Manage ETIMEOUT as result, not only ECONNREFUSED )
371
-
372
- - Utils
373
- - Allow regex in range functions
374
-
375
- ## [4.7.0] 2020-05-06
376
-
377
- - New fix rules
378
- - BracesForClass
379
- - BracesForForLoop
380
- - BracesForIfElse
381
- - BracesForMethod
382
- - BracesForTryCatchFinally
383
- - ExplicitArrayListInstantiation
384
- - MissingBlankLineAfterImports
385
- - MissingBlankLineAfterPackage
386
-
387
- - Updated fix rules
388
- - UnnecessaryGString: Fix replacements containing `\n` and `\r`
389
-
390
- ## [4.6.0] 2020-05-01
391
-
392
- - New fix rules
393
- - SpaceBeforeClosingBrace
394
- - UnnecessaryDefInMethodDeclaration
395
- - UnnecessaryPackageReference
396
- - UnnecessaryParenthesesForMethodCallWithClosure
397
-
398
- - Updated fix rules
399
- - MisorderedStaticImports: Fix `@Grapes` killer fixing rule
400
- - ElseBlockBrace :issue when instruction is on the same line than `else`
401
-
402
- ## [4.5.5] 2020-04-30
403
-
404
- - Fixes
405
- - ignorepattern option not working [#34](https://github.com/nvuillam/npm-groovy-lint/issues/34)
406
-
407
- ## [4.5.2] 2020-04-29
408
-
409
- - Expose `loadConfig()` method to load rules when npm-groovy-lint is used as a library
410
- - Fixes
411
- - Missing temporary rulesets file missing
412
- - Handle better CodeNarcServer concurrent calls
413
-
414
- ## [4.5.1] 2020-04-28
415
-
416
- - Fixes
417
- - Take in account user overridden indentation space (and other rules) when using --format option [#31](https://github.com/nvuillam/npm-groovy-lint/issues/31)
418
-
419
- ## [4.5.0] 2020-04-24
420
-
421
- - Configuration updates ([#29](https://github.com/nvuillam/npm-groovy-lint/issues/29)):
422
- - New default config "recommended-jenkinsfile". Use it with argument `--config recommended-jenkinsfile`
423
- - Allow to directly target a config file name. Use it with argument `--config /my/custom/path/.groovylintrc-custom-name.json`
424
- - Allow to send a string key that will be used to find config file `--config custom-name`
425
- - Updated fix rules:
426
- - IfStatementBraces
427
- - ElseStatementBraces
428
-
429
- ## [4.4.1] 2020-04-16
430
-
431
- - Fixes:
432
- - CodeNarcServer: Use cachedThreadPool instead of fixedThreadPool
433
-
434
- ## [4.4.0] 2020-04-16
435
-
436
- - Cancel a CodeNarc Lint when a similar CodeNarcServer request is received (allowing onType mode for language servers)
437
-
438
- ## [4.3.0] 2020-04-14
439
-
440
- - Allow to disable rules using comments in source in [eslint style](https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments)
441
-
442
- ## [4.2.0] 2020-04-13
443
-
444
- - New option **--parse**: Capability to parse source code and return compilation errors
445
- - New fix rules (thanks [CatSue](https://github.com/CatSue) !):
446
- - SpaceAfterSemicolon
447
- - SpaceAfterWhile
448
-
449
- ## [4.1.0] 2020-04-12
450
-
451
- - Upgrade to [Groovy 3.0.3](https://dl.bintray.com/groovy/maven/apache-groovy-binary-3.0.3.zip)
452
- - Automatic generation of fixable rules list for README
453
- - Refactor CodeNarcServer.groovy
454
-
455
- ## [4.0.0] 2020-04-09
456
-
457
- - Fix [issue](https://github.com/nvuillam/vscode-groovy-lint/issues/16) affecting performances on Linux and MacOs
458
-
459
- ## [3.3.0] 2020-04-06
460
-
461
- - When formatting, always run some custom npm-groovy-lint fix rules not corresponding to CodeNarc violations
462
- - Return CodeNarc and Groovy versions when --version options is called
463
- - Fixes
464
- - Lost indentation when applying some fix rules
465
- - Updated fix rules:
466
- - IndentationClosingBraces
467
- - IndentationComments
468
- - SpaceAfterCatch
469
- - SpaceAfterIf
470
- - New fix rules:
471
- - ClassEndsWithBlankLine
472
- - ClassStartsWithNewLine
473
- - SpaceAfterFor
474
- - SpaceAfterSwitch
475
-
476
- ## [3.2.4] 2020-04-03
477
-
478
- - Error message in postinstall if env Node.js is lower than the minimal required (12)
479
-
480
- ## [3.2.3] 2020-04-02
481
-
482
- - When If or Else brackets are fixed,trigger another rule lint & fix only with Indentation rules so CodeNarc recalculate them correctly
483
- - New option `nolintafter`: When format or fix is called, a new lint is performed after the fixes to update the error list. If you just want the updated source code and do not care about the error logs, use this parameter to improve performances
484
- - Fixes
485
- - Manage correctly options `failonerror`, `failonwarning` and `failoninfo`
486
- - `npm-groovy-lint -version` now returns version from package.json
487
- - Mocha tests updates:
488
- - Add stats on calls to CodeNarc (`globalThis.codeNarcCallsCounter` and `globalThis.codeNarcCalls`, activated if `globalThis.codeNarcCallsCounter` is set to 0 before calling NmpGroovyLint)
489
- - Factorize test classes common code in module helper/common.js
490
- - Use a smaller groovy file for test classes when not impacting the tests quality
491
-
492
- ## [3.2.2] 2020-03-31
493
-
494
- - New option **returnrules** if you want to return rules descriptions and documentation url in results
495
- - Use npm ci instead of npm install in CircleCI build
496
-
497
- ## [3.2.1] 2020-03-29
498
-
499
- - Return rules descriptions in results
500
- - New option **nolintafter**: do not lint again a format or a fix, as the client prefers to request it
501
- - Fixes
502
- - [Issue #13](https://github.com/nvuillam/npm-groovy-lint/issues/13): False positive error ClassNameSameAsFileName
503
- - Sometimes returning wrong .groovylint.json config file
504
-
505
- ## [3.2.0] 2020-03-26
506
-
507
- - New option "--format", allowing to reformat source code (using .groovylintrc-format.json)
508
- - Update default recommended rules
509
-
510
- ## [3.1.3] 2020-03-22
511
-
512
- - README: Link to [Visual Studio Code Groovy Lint extension](https://marketplace.visualstudio.com/items?itemName=NicolasVuillamy.vscode-groovy-lint)
513
-
514
- ## [3.1.2] 2020-03-22
515
-
516
- - New Fix rules:
517
- - BlockEndsWithBlankLine
518
- - BlockStartsWithBlankLine
519
- - MisorderedStaticImports
520
- - SpaceAfterIf
521
- - Fix: Update correctly the lineNb & ranges of next errors after an error has been fixed
522
- - Do not return rules tests if call is not from a test file
523
- - Fix rules:
524
- - ElseBlockBraces
525
- - IfStatementBraces
526
- - SpaceAroundOperator
527
- - UnusedImport
528
-
529
- ## [3.1.1] 2020-03-20
530
-
531
- - New Fix rules:
532
- - BlockEndsWithBlankLine
533
- - BlockStartsWithBlankLine
534
- - MisorderedStaticImports
535
- - SpaceAfterIf
536
- - Updated Fix rules:
537
- - SpaceAroundOperator
538
-
539
- ## [3.1.0] 2020-03-18
540
-
541
- - Test suites: Improve reliability & logs for rule fixes tests (detected numerous bugs, now corrected)
542
- - Send computed range to fix functions
543
- - Updated Fix rules:
544
- - ClosingBraceNotAlone
545
- - ElseBlockBraces
546
- - IfStatementBraces
547
- - NoTabCharacter
548
- - SpaceAfterComma
549
- - SystemExit
550
- - TrailingWhitespace
551
- - UnnecessaryGroovyImport
552
- - UnusedImport
553
-
554
- ## [3.0.1] 2020-03-17
555
-
556
- - Add new test suites: errors.test.js and miscellaneous.test.js
557
- - Use JSON as default GroovyLint configuration file type
558
- - Order of fixable rules must be defined in groovy-lint-rules.js
559
- - Do not load rules test data except during tests
560
- - Do not lint again after a call to fixErrors on an existing NpmGroovyLint instance (except if lintAgainAfterFix : true is sent in options)
561
- - Fix: Deletion of temp RuleSite file
562
- - Fix: UnnecessarySemiColon rule
563
- - Fix: ClosingBraceNotAlone rule
564
-
565
- ## [3.0.0] 2020-03-15
566
-
567
- - Local microservice "CodeNarcServer" called via Http by npm-groovy-lint, to avoid loading all groovy/java classes at each lint request. This microservice auto-kills itself after one hour idle.
568
- - Capability to define RuleSets in argument or js/json/yml config file formats instead of groovy/xml RuleSet format
569
- - Test classes for rules fix (before / after fix defined in rule definitions)
570
- - Add debug logs (use it by setting DEBUG env variable , ex: `DEBUG=npm-groovy-lint npm-groovy-lint args...`)
571
- - Update lines and ranges of other errors after a fix updated the number of lines
572
- - Generate automatically .groovylintrc-all.js during build
573
- - Split rules definition into files instead of all in a huge single file
574
- - Reorganize groovy-lint.js code, using codenarc-factory.js and codenarc-caller.js
575
- - New lib utils.js that can be used by rules definition
576
- - Fix: Crash when there was no error found in a file
577
- - Fix: Remove Promise error display in log after launching CodeNarcServer
578
- - Fix: Add more options exclusivity arguments rules
579
- - Removed "Groovy", "Jenkinsfile" and "All" identifiers for --rulesets arguments. Please now use .groovylintrc.js configuration
580
-
581
- ## [2.2.0] 2020-02-28
582
-
583
- - Capability to call NpmGroovyLint with options as object, not only command line arguments
584
- - New option "source", allowing to call NpmGroovyLint with the groovy code as a string , not only path & files pattern
585
- - Run lint again after fix all errors, to get updated lintResult
586
- - Add gitattributes to normalized line-endings (thanks [docwhat](https://github.com/docwhat))
587
- - API: fix only some errors after an initial lint (better performances)
588
- - Return error range in files for some rules in JSON or API result (will be useful for the VsCode extension currently developed)
589
- - Define range function for existing rules, new fixable rules
590
-
591
- ## [2.0.1] - 2020-02-21
592
-
593
- - Capability to fix errors
594
- - ConsecutiveBlankLines
595
- - Indentation (IfStatementBraces and ElseIfStatementBraces must be manually fixed to have correct indentation)
596
- - IndentationComments (custom npm-groovy-rule triggered by Indentation rule)
597
- - IndentationClosingBrace (custom npm-groovy-rule triggered by Indentation rule)
598
- - NoTabCharacter
599
- - SpaceAfterCatch
600
- - SpaceAfterOpeningBrace
601
- - SpaceAroundOperator
602
- - SpaceAfterComma
603
- - SpaceBeforeOpeningBrace
604
- - UnnecessaryDefInFieldDeclaration
605
- - UnnecessaryGString
606
- - UnnecessaryPublicModifier
607
- - UnnecessarySemicolon
608
- - TrailingWhitespace
609
- - Log formatting with severity colors and summary table
610
- - Default recommended RuleSets for Groovy and Jenkins
611
- - Progress bar in console
612
- - More code coverage with test campaigns
613
- - New Capability to call NpmGroovyLint from another package (VsCode extension development in progress ^^)
614
- - Refactored command line arguments ( simpler, but different from CodeNarc ones : retro-compatibility with CodeNarc arguments assured if you add --codenarcargs)
615
- - Upgrade to CodeNarc v1.5
616
- - Upgrade to Groovy v3.0.1
617
- - Refactored documentation with detailed arguments description & examples
618
-
619
- ___
620
-
621
- ## Before
622
-
623
- - I wasn't serious enough to keep a changelog, sorry !
Binary file
Binary file
Binary file