ns-jsanalyzer
Advanced tools
Comparing version
27
index.js
@@ -21,6 +21,6 @@ #!/usr/bin/env node | ||
var code = issue.key.split(":")[1]; | ||
console.log("%s - %s: %s line:%s", issue.severity, code, issue.file, issue.pos.line+":"+issue.pos.column) | ||
console.log("%s - %s: %s line:%s %s", issue.severity, code, issue.file, issue.pos.line+":"+issue.pos.column, issue.message) | ||
} | ||
var allowedBlockers = [ | ||
var allowedIssues = [ | ||
'S2703', | ||
@@ -30,5 +30,14 @@ 'S3796' | ||
function isAllowed(code) { | ||
if (allowedIssues.indexOf(code) > -1) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
program | ||
.option("-a, --all", "Show all issues") | ||
.option("-d, --directory [directory]", "Directory to scan") | ||
.option("-c, --critical", "Fail on critical issues") | ||
.parse(process.argv); | ||
@@ -46,6 +55,7 @@ | ||
issues.forEach(issue => { | ||
var code = issue.key.split(":")[1]; | ||
if (issue.severity == 'BLOCKER') { | ||
var code = issue.key.split(":")[1]; | ||
issue.code = code; | ||
if (allowedBlockers.indexOf(code) == -1) { | ||
if (!isAllowed(code)) { | ||
blockers.push(issue); | ||
@@ -55,2 +65,7 @@ } | ||
} | ||
if (program.critical && issue.severity == 'CRITICAL') { | ||
if (!isAllowed(code)) { | ||
blockers.push(issue); | ||
} | ||
} | ||
if (program.all) { | ||
@@ -63,7 +78,7 @@ printIssue(issue); | ||
if (blockers.length > 0) { | ||
console.log("ANALYSIS FAILED. PLEASE FIX THE BLOCKERS."); | ||
console.log("ANALYSIS FAILED. PLEASE FIX THE FOLLOWING ISSUES:"); | ||
blockers.map(blocker => printIssue(blocker)); | ||
process.exit(1); | ||
} else { | ||
console.log("ANALYSIS PASSED") | ||
console.log("ANALYSIS PASSED"); | ||
process.exit(0); | ||
@@ -70,0 +85,0 @@ } |
{ | ||
"name": "ns-jsanalyzer", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
13374
0.45%67
24.07%