npm-groovy-lint
Advanced tools
Comparing version 7.5.1 to 7.5.2
# Changelog | ||
## [7.5.1] 2020-09-02 | ||
- Fix [(#96)](https://github.com/nvuillam/npm-groovy-lint/issues/96) --fix adds redundant space into `${VARIABLE}` (SpaceBeforeOpeningBrace fix rule error) | ||
- Fix grails framework detection | ||
- Fix Groovy parsing parsing when multiple files | ||
- Add `.gvy` and `.nf` in default browsed files extensions | ||
## [7.5.0] 2020-09-02 | ||
@@ -4,0 +11,0 @@ |
@@ -206,3 +206,3 @@ const Amplitude = require("amplitude"); | ||
{ name: "beakerx", priority: 3 }, // UNDEFINED | ||
{ name: "codenarc", priority: 3, sourceIncludes: ["codenarc", "groovy-lint"] }, | ||
{ name: "codenarc", priority: 3, sourceIncludes: ["codenarc", "groovylint"] }, | ||
{ name: "dru", priority: 2, packages: ["com.agorapulse.dru"] }, | ||
@@ -216,3 +216,3 @@ { name: "ersatz", priority: 2, packages: ["com.stehno.ersatz"] }, | ||
{ name: "gradle", priority: 1, fileExtensions: [".gradle"] }, | ||
{ name: "grails", priority: 1 }, // UNDEFINED | ||
{ name: "grails", priority: 1, filePathIncludes: ["grails-app"] }, | ||
{ name: "grain", priority: 2, packages: ["com.sysgears"] }, | ||
@@ -247,4 +247,6 @@ { name: "griffon", priority: 2, sourceIncludes: ["griffon"] }, | ||
const frameworksUsed = []; | ||
const fileBaseName = path.basename(file); | ||
const fileExtname = path.extname(file); | ||
for (const frameworkDef of frameworkDefs) { | ||
if (isUsedFramework(frameworkDef, file, source)) { | ||
if (isUsedFramework(frameworkDef, file, source, fileExtname, fileBaseName)) { | ||
frameworksUsed.push(frameworkDef); | ||
@@ -260,7 +262,7 @@ } | ||
function isUsedFramework(frameworkDef, file, source) { | ||
function isUsedFramework(frameworkDef, file, source, fileExtname, fileBaseName) { | ||
// Check file extension | ||
if (frameworkDef.fileExtensions) { | ||
for (const ext of frameworkDef.fileExtensions) { | ||
if (path.extname(file) === ext) { | ||
if (fileExtname === ext) { | ||
return true; | ||
@@ -289,3 +291,3 @@ } | ||
for (const str of frameworkDef.fileNameIncludes) { | ||
if (path.basename(file).includes(str)) { | ||
if (fileBaseName.includes(str)) { | ||
return true; | ||
@@ -295,2 +297,12 @@ } | ||
} | ||
// Check file path | ||
if (frameworkDef.filePathIncludes) { | ||
for (const str of frameworkDef.filePathIncludes) { | ||
if (file.includes(str)) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
@@ -297,0 +309,0 @@ } |
@@ -66,3 +66,3 @@ // Shared functions | ||
// Build ruleSet & file CodeNarc arguments | ||
let defaultFilesPattern = "**/*.groovy,**/Jenkinsfile,**/*.gradle"; | ||
let defaultFilesPattern = "**/*.groovy,**/*.gvy,**/Jenkinsfile,**/*.gradle,**/*.nf"; | ||
@@ -69,0 +69,0 @@ // RuleSet codeNarc arg |
@@ -15,3 +15,3 @@ // Space before opening brace | ||
func: line => { | ||
const regexMatch = line.match(new RegExp(/[^ ]{/, "g")); | ||
const regexMatch = line.match(new RegExp(/[^ |$]{/, "g")); | ||
if (regexMatch && regexMatch[0]) { | ||
@@ -33,3 +33,33 @@ line = line.replace(regexMatch[0], regexMatch[0][0] + " {"); | ||
` | ||
}, | ||
{ | ||
sourceBefore: ` | ||
pipeline { | ||
stages { | ||
stage('CleanWorkspace') { | ||
steps { | ||
cleanWs() | ||
dir("../\${JOB_NAME}@2"){ | ||
deleteDir() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`, | ||
sourceAfter: ` | ||
pipeline { | ||
stages { | ||
stage('CleanWorkspace') { | ||
steps { | ||
cleanWs() | ||
dir("../\${JOB_NAME}@2") { | ||
deleteDir() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
` | ||
} | ||
] | ||
@@ -36,0 +66,0 @@ }; |
@@ -131,2 +131,3 @@ #! /usr/bin/env node | ||
it("(API:files) should ignore fake_node_modules pattern", async () => { | ||
const lintedFilesNb = 10; | ||
const npmGroovyLintConfig = { | ||
@@ -142,4 +143,4 @@ files: "**/*.groovy", | ||
assert( | ||
linter.outputString.includes(`npm-groovy-lint results in ${c.bold(9)} linted files`), | ||
"Number of linted files is displayed in summary" | ||
linter.outputString.includes(`npm-groovy-lint results in ${c.bold(lintedFilesNb)} linted files`), | ||
`Number of linted files is displayed in summary: ${c.bold(lintedFilesNb)}` | ||
); | ||
@@ -146,0 +147,0 @@ }); |
@@ -42,3 +42,3 @@ #! /usr/bin/env node | ||
assert(!stdout.includes(`ToIgnore.groovy`), `ToIgnore.groovy has been ignored \n${stdout}`); | ||
assert(stdout.includes(`npm-groovy-lint results in ${c.bold(9)} linted files`), `Number of linted files is displayed in summary \n${stdout}`); | ||
assert(stdout.includes(`npm-groovy-lint results in ${c.bold(10)} linted files`), `Number of linted files is displayed in summary \n${stdout}`); | ||
}); | ||
@@ -45,0 +45,0 @@ |
@@ -161,2 +161,13 @@ #! /usr/bin/env node | ||
it("(API:source) send anonymous usage statistics (2)", async () => { | ||
const npmGroovyLintConfig = { | ||
path: "./lib/example/grails-app", | ||
returnrules: true, | ||
output: "txt" | ||
}; | ||
const linter = await new NpmGroovyLint(npmGroovyLintConfig, {}).run(); | ||
assert(linter.status === 0, `Linter status is 0 (${linter.status} returned)`); | ||
assert(linter.startElapse != null, "Anonymous stats has not been sent"); | ||
}); | ||
it("(API:source) should use a CodeNarc ruleset defined in groovylintrc.json", async () => { | ||
@@ -163,0 +174,0 @@ const npmGroovyLintConfig = { |
{ | ||
"name": "npm-groovy-lint", | ||
"version": "7.5.1", | ||
"version": "7.5.2", | ||
"description": "Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -400,2 +400,9 @@ <!-- markdownlint-disable MD033 --> | ||
### [7.5.1] 2020-09-02 | ||
- Fix [(#96)](https://github.com/nvuillam/npm-groovy-lint/issues/96) --fix adds redundant space into `${VARIABLE}` (SpaceBeforeOpeningBrace fix rule error) | ||
- Fix grails framework detection | ||
- Fix Groovy parsing parsing when multiple files | ||
- Add `.gvy` and `.nf` in default browsed files extensions | ||
### [7.4.3] 2020-08-29 | ||
@@ -402,0 +409,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16597155
117
8248
458