npm-groovy-lint
Advanced tools
Comparing version 3.0.0 to 3.0.1-beta.1
@@ -77,7 +77,19 @@ // Call CodeNarc by server or java | ||
} | ||
return { | ||
codeNarcStdOut: parsedBody.stdout, | ||
codeNarcStdErr: parsedBody.stderr, | ||
status: parsedBody.status === "success" ? 0 : 1 | ||
}; | ||
// Success result | ||
if (parsedBody.status === "success") { | ||
return { | ||
codeNarcStdOut: parsedBody.stdout, | ||
codeNarcStdErr: parsedBody.stderr, | ||
status: 0 | ||
}; | ||
} | ||
// Codenarc error | ||
else { | ||
return { | ||
codeNarcStdOut: parsedBody.stdout, | ||
codeNarcStdErr: parsedBody.stderr || parsedBody.errorDtl, | ||
status: 1 | ||
}; | ||
} | ||
} | ||
@@ -84,0 +96,0 @@ |
@@ -41,3 +41,3 @@ // Shared functions | ||
options.rulesets = ruleSetFileName; | ||
if (ruleSetFileName.includes()) { | ||
if (ruleSetFileName.includes("codeNarcTmpRs_")) { | ||
result.tmpRuleSetFileName = ruleSetFileName; | ||
@@ -194,3 +194,2 @@ } | ||
} | ||
// Rules from config file, only if rulesets has not been sent as argument | ||
@@ -239,3 +238,2 @@ if (ruleSetsDef.length === 0 && options.rules) { | ||
} | ||
return ""; | ||
} | ||
@@ -242,0 +240,0 @@ |
@@ -22,2 +22,15 @@ // Configuration file management | ||
async function loadConfig(startPathOrFile) { | ||
const configFilePath = await getConfigFileName(startPathOrFile); | ||
// Load user configuration from file | ||
const configUser = loadConfigFromFile(configFilePath); | ||
// If config extends a standard one, merge it | ||
if (configUser.extends) { | ||
const baseConfigFilePath = await findConfigInPath(__dirname, [`.groovylintrc-${configUser.extends}.js`]); | ||
const baseConfig = loadConfigFromFile(baseConfigFilePath); | ||
configUser.rules = Object.assign(baseConfig.rules, configUser.rules); | ||
} | ||
return configUser; | ||
} | ||
async function getConfigFileName(startPathOrFile) { | ||
let configFilePath = null; | ||
@@ -33,11 +46,3 @@ const stat = await fse.lstat(startPathOrFile); | ||
} | ||
// Load user configuration from file | ||
const configUser = loadConfigFromFile(configFilePath); | ||
// If config extends a standard one, merge it | ||
if (configUser.extends) { | ||
const baseConfigFilePath = await findConfigInPath(__dirname, [`.groovylintrc-${configUser.extends}.js`]); | ||
const baseConfig = loadConfigFromFile(baseConfigFilePath); | ||
configUser.rules = Object.assign(baseConfig.rules, configUser.rules); | ||
} | ||
return configUser; | ||
return configFilePath; | ||
} | ||
@@ -155,2 +160,2 @@ | ||
module.exports = { loadConfig }; | ||
module.exports = { loadConfig, getConfigFileName }; |
@@ -74,3 +74,3 @@ #! /usr/bin/env node | ||
this.npmGroovyLintRules[err.rule].fix != null && | ||
(this.fixRules == null || this.fixRules.includes(err.rule)) | ||
(this.fixRules == null || this.fixRules.includes(err.rule) || this.fixRules[0] === "TriggerTestError") | ||
) { | ||
@@ -133,3 +133,3 @@ // Add fixable error | ||
for (const fileFixableError of this.fixableErrors[fileNm]) { | ||
if (this.fixRules != null && !this.fixRules.includes(fileFixableError.ruleName)) { | ||
if (this.fixRules != null && !this.fixRules.includes(fileFixableError.ruleName) && this.fixRules[0] !== "TriggerTestError") { | ||
continue; | ||
@@ -208,5 +208,9 @@ } | ||
try { | ||
if (this.fixRules && this.fixRules[0] === "TriggerTestError") { | ||
throw new Error("Trigger test error"); | ||
} | ||
newLine = fix.func(newLine, evaluatedVars); | ||
} catch (e) { | ||
debug("GroovyLint: Function error: " + e.message + " / " + JSON.stringify(fixableError)); | ||
throw e; | ||
} | ||
@@ -213,0 +217,0 @@ } |
@@ -11,3 +11,3 @@ #! /usr/bin/env node | ||
const { prepareCodeNarcCall, parseCodeNarcResult, manageDeleteTmpFiles } = require("./codenarc-factory"); | ||
const { loadConfig } = require("./config.js"); | ||
const { loadConfig, getConfigFileName } = require("./config.js"); | ||
const optionsDefinition = require("./options"); | ||
@@ -91,2 +91,7 @@ const { computeStats, processOutput } = require("./output.js"); | ||
// Returns the full path of the configuration file | ||
async getConfigFilePath() { | ||
return getConfigFileName(this.options.config); | ||
} | ||
// Actions before call to CodeNarc | ||
@@ -191,3 +196,3 @@ async preProcess() { | ||
// CodeNarc error | ||
if (this.codeNarcStdErr && [null, "", undefined].includes(this.codeNarcStdOut)) { | ||
if ((this.codeNarcStdErr && [null, "", undefined].includes(this.codeNarcStdOut)) || this.status > 0) { | ||
this.status = 1; | ||
@@ -194,0 +199,0 @@ console.error("GroovyLint: Error running CodeNarc: \n" + this.codeNarcStdErr); |
{ | ||
"name": "npm-groovy-lint", | ||
"version": "3.0.0", | ||
"version": "3.0.1-beta.1", | ||
"description": "NPM CodeNarc wrapper to easily lint Groovy files", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
16284693
3801
1