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

ns-jsanalyzer

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ns-jsanalyzer - npm Package Compare versions

Comparing version

to
0.0.2

49

index.js
#!/usr/bin/env node
var {analyze} = require("sonarjs")
var {analyze} = require("sonarjs");
var program = require("commander");
console.log("Analyzing js");

@@ -10,22 +12,51 @@

function onStart() {
console.log("Analysis is started");
console.log("Analysis is started...");
}
function onEnd() {
console.log("Analysis is finished");
//console.log("Analysis is finished...");
}
function printIssue(issue) {
var code = issue.key.split(":")[1];
console.log("%s - %s: %s line:%s", issue.severity, code, issue.file, issue.pos.line+":"+issue.pos.column)
}
var allowedBlockers = [
'S2703',
'S3796'
];
program
.option("-a, --all", "Show all issues")
.option("-d, --directory [directory]", "Directory to scan")
.parse(process.argv);
async function runSonarJS() {
const issues = await analyze("src", {log,onStart, onEnd});
var directory = program.directory;
if (typeof directory == 'undefined' || directory === true) {
directory = 'src';
}
console.log("Scanning directory:", directory);
const issues = await analyze(directory, {log,onStart, onEnd});
var blockers = [];
issues.forEach(issue => {
if (issue.severity == 'BLOCKER') {
blockers.push(issue);
var code = issue.key.split(":")[1];
issue.code = code;
if (allowedBlockers.indexOf(code) == -1) {
blockers.push(issue);
}
}
if (program.all) {
printIssue(issue);
}
});
blockers.map(blocker => console.log("Found a blocker:", blocker));
if (blockers) {
if (blockers.length > 0) {
console.log("ANALYSIS FAILED. PLEASE FIX THE BLOCKERS.");
blockers.map(blocker => printIssue(blocker));
process.exit(1);

@@ -38,2 +69,2 @@ } else {

runSonarJS();
runSonarJS();

3

package.json
{
"name": "ns-jsanalyzer",
"version": "0.0.1",
"version": "0.0.2",
"description": "",

@@ -15,4 +15,5 @@ "main": "index.js",

"dependencies": {
"commander": "^2.15.1",
"sonarjs": "^1.0.0"
}
}

Sorry, the diff of this file is not supported yet