New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

npm-groovy-lint

Package Overview
Dependencies
Maintainers
1
Versions
204
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-groovy-lint - npm Package Compare versions

Comparing version 5.0.1 to 5.0.2

lib/rules/BlankLineBeforePackage.js

18

CHANGELOG.md
# Changelog
## [5.0.0] 2020-25-05
## [5.0.2] 2020-05-27
- Avoid to apply wrong fix in case of CodeNarc false positive
- New fix rules
- BlankLineBeforePackage
- Updated fix rules
- BracesForIfElse
- BracesForMethod
- BracesForTryCatchFinally
- ClassEndsWithBlankLine
- ClassStartsWithBlankLine
- MissingBlankLineAfterImports
- MissingBlankLineAfterPackage
- UnnecessaryGroovyImport
- UnusedImport
## [5.0.0] 2020-05-25
- **BIG BANG**: Improve performances, compatibility, architecture and delivery

@@ -6,0 +22,0 @@ - Get rid of [jDeploy](https://github.com/shannah/jdeploy) dependency

2

lib/codenarc-factory.js

@@ -49,3 +49,3 @@ // Shared functions

await fse.writeFile(result.tmpGroovyFileName, options.source);
await fse.writeFile(result.tmpGroovyFileName, options.source.replace(/\r?\n/g, "\r\n"));
debug(`CREATE GROOVY temp file ${result.tmpGroovyFileName} with input source, as CodeNarc requires physical files`);

@@ -52,0 +52,0 @@ }

@@ -133,2 +133,3 @@ // Additional definition for codenarc rules ( get position & available fix)

"DuplicateImport",
"BlankLineBeforePackage",
"BlockStartsWithBlankLine",

@@ -135,0 +136,0 @@ "BlockEndsWithBlankLine",

@@ -72,4 +72,3 @@ #! /usr/bin/env node

child.unref();
}
else {
} else {
// Gather stdout and stderr if not detached sub process

@@ -76,0 +75,0 @@ child.stdout.on("data", data => {

@@ -7,2 +7,3 @@ // Braces for if else

scope: "file",
unitary: true,
range: {

@@ -9,0 +10,0 @@ type: "function",

@@ -7,2 +7,3 @@ // Braces for method

scope: "file",
unitary: true,
variables: [

@@ -53,2 +54,37 @@ {

`
},
{
sourceBefore: `
class VersionHandler implements Serializable {
/**
* Gets a list of versions from the changelog
*
* @return List
*/
List changelogVersions(String changelog='CHANGELOG.md')
{
changelog = context.readFile "\${changelog}"
def versions = getVersionsFromChangeLog(changelog)
return this.sort(versions)
}
}
`,
sourceAfter: `
class VersionHandler implements Serializable {
/**
* Gets a list of versions from the changelog
*
* @return List
*/
List changelogVersions(String changelog='CHANGELOG.md') {
changelog = context.readFile "\${changelog}"
def versions = getVersionsFromChangeLog(changelog)
return this.sort(versions)
}
}
`
} /*

@@ -55,0 +91,0 @@ NV: Disable fix while not detected by CodeNarc

@@ -7,2 +7,3 @@ // Braces for try catch finally

scope: "file",
unitary: true,
range: {

@@ -9,0 +10,0 @@ type: "function",

@@ -7,2 +7,3 @@ // Unused import

scope: "file",
unitary: true,
fix: {

@@ -9,0 +10,0 @@ label: "Add blank line before end of the class",

@@ -7,2 +7,3 @@ // Unused import

scope: "file",
unitary: true,
fix: {

@@ -9,0 +10,0 @@ label: "Add blank line after the beginning of the class",

@@ -7,2 +7,3 @@ // Missing blank lines after import

scope: "file",
unitary: true,
fix: {

@@ -9,0 +10,0 @@ label: "Add blank line after imports",

@@ -7,2 +7,3 @@ // Missing blank lines after package

scope: "file",
unitary: true,
fix: {

@@ -9,0 +10,0 @@ label: "Add blank line after package",

@@ -7,2 +7,3 @@ // Unnecessary Groovy Import

scope: "file",
unitary: true,
fix: {

@@ -9,0 +10,0 @@ label: "Remove unnecessary groovy import",

@@ -7,2 +7,3 @@ // Unused import

scope: "file",
unitary: true,
variables: [

@@ -15,3 +16,2 @@ {

],
unitary: true,
fix: {

@@ -18,0 +18,0 @@ label: "Remove unused import",

@@ -305,11 +305,23 @@ // Shared functions

const range = getVariable(variables, "range", { mandatory: true });
const realPos = allLines[range.end.line - 1].includes("{") ? range.end.line : allLines[range.end.line].includes("{") ? range.end.line + 1 : -1;
if (realPos === -1) {
throw new Error("Unable to find opening bracket");
}
if (
allLines[realPos - 1]
.trim()
.replace(/ /g, "")
.includes("){")
) {
throw new Error("Fix not applied: probably a CodeNarc false positive");
}
// Add bracket after if
const addedBracketLine = allLines[range.end.line - 2].trimEnd() + " {";
allLines[range.end.line - 2] = addedBracketLine;
const addedBracketLine = allLines[realPos - 2].trimEnd() + " {";
allLines[realPos - 2] = addedBracketLine;
// Remove bracket which was on the wrong line
const removedBracketLine = allLines[range.end.line - 1].substring(allLines[range.end.line - 1].indexOf("{") + 1).trimEnd();
allLines[range.end.line - 1] = removedBracketLine;
const removedBracketLine = allLines[realPos - 1].substring(allLines[realPos - 1].indexOf("{") + 1).trimEnd();
allLines[realPos - 1] = removedBracketLine;
// Remove removed bracket line if empty
if (allLines[range.end.line - 1].trim() === "") {
allLines.splice(range.end.line - 1, 1);
if (allLines[realPos - 1].trim() === "") {
allLines.splice(realPos - 1, 1);
}

@@ -316,0 +328,0 @@ return allLines;

{
"name": "npm-groovy-lint",
"version": "5.0.1",
"version": "5.0.2",
"description": "Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -325,4 +325,20 @@ # NPM GROOVY LINT (+ Format & Auto-fix)

### [5.0.0] 2020-25-05
## [5.0.2] 2020-05-27
- Avoid to apply wrong fix in case of CodeNarc false positive
- New fix rules
- BlankLineBeforePackage
- Updated fix rules
- BracesForIfElse
- BracesForMethod
- BracesForTryCatchFinally
- ClassEndsWithBlankLine
- ClassStartsWithBlankLine
- MissingBlankLineAfterImports
- MissingBlankLineAfterPackage
- UnnecessaryGroovyImport
- UnusedImport
### [5.0.0] 2020-05-25
- **BIG BANG**: Improve performances, compatibility, architecture and delivery

@@ -329,0 +345,0 @@ - Get rid of [jDeploy](https://github.com/shannah/jdeploy) dependency

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc