npm-groovy-lint 10.1.0 → 11.0.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/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## UNRELEASED
4
4
 
5
+ ## [11.0.0] 2022-10-07
6
+
7
+ - **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`.
8
+ - Display all files in console log only if `--verbose` is used ([#243](https://github.com/nvuillam/npm-groovy-lint/issues/243))
9
+
5
10
  ## [10.1.0] 2022-08-15
6
11
 
7
12
  - Allow to send groovy sources as input from stdin
package/lib/config.js CHANGED
@@ -239,7 +239,7 @@ async function loadYAMLConfigFile(filePath) {
239
239
  try {
240
240
  // empty YAML file can be null, so always use
241
241
  const fileContent = await readFile(filePath);
242
- return yaml.safeLoad(fileContent) || {};
242
+ return yaml.load(fileContent) || {};
243
243
  } catch (e) {
244
244
  debug(`Error reading YAML file: ${filePath}`);
245
245
  e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
@@ -467,6 +467,10 @@ class NpmGroovyLint {
467
467
 
468
468
  // Exit with code 1 if failon, failonerror, failonwarning or failoninfo is set
469
469
  manageReturnCode() {
470
+ if (this.status > 1) {
471
+ // There has been a fatal error before, so there are no results
472
+ return ;
473
+ }
470
474
  const failureLevel =
471
475
  this.options.failon && this.options.failon !== "none"
472
476
  ? this.options.failon
@@ -480,6 +484,10 @@ class NpmGroovyLint {
480
484
  if (failureLevel === "none") {
481
485
  return;
482
486
  }
487
+ if (this.lintResult.summary == null) {
488
+ // Special case like --codenarcargs (should not be used in thee future)
489
+ return;
490
+ }
483
491
 
484
492
  const errorNb = this.lintResult.summary.totalFoundErrorNumber;
485
493
  const warningNb = this.lintResult.summary.totalFoundWarningNumber;
package/lib/options.js CHANGED
@@ -139,7 +139,7 @@ module.exports = optionator({
139
139
  option: "failon",
140
140
  type: "String",
141
141
  enum: ["error", "warning", "info", "none"],
142
- default: "none",
142
+ default: "info",
143
143
  description:
144
144
  "Defines the error level where CLI will fail (return code = 1). error,warning,info or none. Every failure level includes the more critical ones.",
145
145
  example: ["error", "warning", "info", "none"]
package/lib/output.js CHANGED
@@ -108,11 +108,13 @@ async function processOutput(outputType, output, lintResult, options, fixer = nu
108
108
  // Errors
109
109
  for (const fileNm of Object.keys(lintResult.files)) {
110
110
  const fileErrors = lintResult.files[fileNm].errors;
111
- outputString += c.underline(fileNm) + "\n";
111
+ let fileOutputString = c.underline(fileNm) + "\n";
112
+ let showFileInOutput = false ;
112
113
  for (const err of fileErrors) {
113
114
  if (!isErrorInLogLevelScope(err.severity, options.loglevel)) {
114
115
  continue;
115
116
  }
117
+ showFileInOutput = true ;
116
118
  let color = "grey";
117
119
  switch (err.severity) {
118
120
  case "error":
@@ -135,7 +137,7 @@ async function processOutput(outputType, output, lintResult, options, fixer = nu
135
137
  }
136
138
  }
137
139
  // Build error output line
138
- outputString +=
140
+ fileOutputString +=
139
141
  " " +
140
142
  err.line.toString().padEnd(4, " ") +
141
143
  " " +
@@ -146,7 +148,10 @@ async function processOutput(outputType, output, lintResult, options, fixer = nu
146
148
  err.rule.padEnd(24, " ") +
147
149
  "\n";
148
150
  }
149
- outputString += "\n";
151
+ fileOutputString += "\n";
152
+ if (showFileInOutput || options.verbose) {
153
+ outputString += fileOutputString ;
154
+ }
150
155
  }
151
156
  outputString += "\nnpm-groovy-lint results in " + c.bold(lintResult.summary.totalFilesLinted) + " linted files:";
152
157
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-groovy-lint",
3
- "version": "10.1.0",
3
+ "version": "11.0.0",
4
4
  "description": "Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files",
5
5
  "main": "index.js",
6
6
  "scripts": {