Huge News!Announcing our $40M Series B led by Abstract Ventures.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 2.2.0-beta.2 to 2.2.0-beta.3

9

jdeploy-bundle/groovy-lint-fix.js

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

// Read file
let fileContent = await fse.readFile(fileNm);
let fileContent = this.options.source || (await fse.readFile(fileNm));
let fileLines = fileContent

@@ -162,5 +162,8 @@ .toString()

}
const newSources = fileLines.join("\r\n") + "\r\n";
// Write new file content if it has been updated
if (fixedInFileNb) {
fse.writeFileSync(fileNm, fileLines.join("\r\n") + "\r\n");
if (this.options.save && fixedInFileNb > 0) {
fse.writeFileSync(fileNm, newSources);
} else if (fixedInFileNb > 0) {
this.updatedLintResult.files[fileNm].updatedSource = newSources;
}

@@ -167,0 +170,0 @@ })

@@ -24,2 +24,3 @@ #! /usr/bin/env node

tmpXmlFileName;
tmpGroovyFileName;

@@ -51,3 +52,2 @@ // Codenarc

this.jdeployRootPath = internalOpts.jdeployRootPath || process.env.JDEPLOY_ROOT_PATH || __dirname;
this.tmpXmlFileName = internalOpts.tmpXmlFileName || os.tmpdir() + "/CodeNarcReportXml_" + Math.random() + ".xml";
}

@@ -103,8 +103,17 @@

let cnPath = this.options.path;
let cnFiles = this.options.files;
// If source option, create a temporary Groovy file
if (this.options.source) {
cnPath = os.tmpdir();
const tmpFileNm = "codeNarcTmpFile_" + Math.random() + ".groovy";
this.tmpGroovyFileName = os.tmpdir() + "/" + tmpFileNm;
cnFiles = "**/" + tmpFileNm;
await fse.writeFile(this.tmpGroovyFileName, this.options.source);
}
// Base directory
const baseBefore =
(this.options.path !== "." && this.options.path.startsWith("/")) || this.options.path.includes(":/") || this.options.path.includes(":\\")
? ""
: process.cwd() + "/";
this.codeNarcBaseDir = this.options.path !== "." ? baseBefore + this.options.path.replace(/^"(.*)"$/, "$1") : process.cwd();
const baseBefore = (cnPath !== "." && cnPath.startsWith("/")) || cnPath.includes(":/") || cnPath.includes(":\\") ? "" : process.cwd() + "/";
this.codeNarcBaseDir = cnPath !== "." ? baseBefore + cnPath.replace(/^"(.*)"$/, "$1") : process.cwd();
this.codenarcArgs.push('-basedir="' + this.codeNarcBaseDir + '"');

@@ -131,4 +140,4 @@

// Matching files pattern(s)
if (this.options.files) {
this.codenarcArgs.push('-includes="' + this.options.files.replace(/^"(.*)"$/, "$1") + '"');
if (cnFiles) {
this.codenarcArgs.push('-includes="' + cnFiles.replace(/^"(.*)"$/, "$1") + '"');
} else {

@@ -147,2 +156,3 @@ // If files not sent, use defaultFilesPattern, guessed from options.rulesets value

this.outputType = this.output.endsWith(".txt") ? "txt" : this.output.endsWith(".json") ? "json" : this.output;
this.tmpXmlFileName = os.tmpdir() + "/codeNarcReportXml_" + Math.random() + ".xml";
this.codenarcArgs.push('-report=xml:"' + this.tmpXmlFileName + '"');

@@ -235,3 +245,5 @@ } else if (["html", "xml"].includes(this.output.split(".").pop())) {

verbose: this.options.verbose,
fixrules: this.options.fixrules
fixrules: this.options.fixrules,
source: this.options.source,
save: this.tmpGroovyFileName ? false : true
});

@@ -244,2 +256,7 @@ await this.fixer.run();

}
// Remove temporary file created for source argument if provided
if (this.tmpGroovyFileName) {
await fse.remove(this.tmpGroovyFileName);
}
}

@@ -273,3 +290,5 @@ // Parse XML result file as js object

for (const fileInfo of folderInfo.File) {
const fileNm = this.codeNarcBaseDir + "/" + (folderInfo["$"].path ? folderInfo["$"].path + "/" : "") + fileInfo["$"].name;
const fileNm = this.options.source
? 0
: this.codeNarcBaseDir + "/" + (folderInfo["$"].path ? folderInfo["$"].path + "/" : "") + fileInfo["$"].name;
if (files[fileNm] == null) {

@@ -276,0 +295,0 @@ files[fileNm] = { errors: [] };

@@ -45,2 +45,9 @@ /**

{
option: "source",
alias: "s",
type: "String",
description: "Source text to lint (if no path/files arguments)",
example: ["import groovyx.net.http.HTTPBuilder\n\nimport class Toto { \n }"]
},
{
option: "rulesets",

@@ -133,3 +140,8 @@ alias: "r",

}
],
mutuallyExclusive: [
["files", "source", "codenarcargs", "help"],
[["path", "files"], "source"],
["failonerror", "failonwarning", "failoninfo"]
]
});
{
"name": "npm-groovy-lint",
"version": "2.2.0-beta.2",
"version": "2.2.0-beta.3",
"description": "NPM CodeNarc wrapper to easily lint Groovy files",

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

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