encore-auditor
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -11,4 +11,27 @@ 'use strict'; | ||
.replace(/\s{2,}/, ' '); | ||
} | ||
}//normalizeMessage() | ||
function formattedMessage (result) { | ||
let fmt; | ||
let msg = result.signature.level; | ||
switch(result.signature.level) { | ||
case 'error': | ||
// white on red | ||
fmt = chalk.bold.white.bgRed; | ||
break; | ||
case 'info': | ||
// white on blue | ||
fmt = chalk.bold.white.bgBlue; | ||
break; | ||
default: | ||
msg = 'warning'; | ||
// black on yellow | ||
fmt = chalk.bold.black.bgYellow; | ||
break; | ||
} | ||
return fmt(msg.toUpperCase()); | ||
}//formattedMessage() | ||
module.exports = class BasicReporter { | ||
@@ -22,5 +45,8 @@ constructor(results) { | ||
[ | ||
chalk.bold(`${result.file.path}:${result.file.lineNumber}:${result.file.line}`), | ||
[ | ||
formattedMessage(result), | ||
chalk.bold(`${result.file.path}:${result.file.lineNumber}:${result.file.line}`) | ||
].join(' '), | ||
result.signature.messages.map(normalizeMessage).join('\n'), | ||
'', // empty line for readability | ||
'', // empty line | ||
].forEach((m) => console.log(m)); | ||
@@ -27,0 +53,0 @@ }); |
@@ -7,2 +7,3 @@ 'use strict'; | ||
const util = require('util'); | ||
const audits = require('./audits'); | ||
@@ -15,10 +16,5 @@ /** | ||
let config = require('../package.json').config; | ||
config.audits = audits; | ||
let auditor = new Auditor(config); | ||
// Legacy audits are for deprecations in LTS block(s). | ||
let ltsAudits = require('./audits/blank'); // none for initial release | ||
// Current audits are for deprecations in current major block. | ||
let currentAudits = require('./audits/onedot'); | ||
config.audits = [ ltsAudits, currentAudits ]; | ||
if (program.debug) { | ||
@@ -30,6 +26,2 @@ console.log('OPTIONS:\n', util.inspect(options, { depth: null })); | ||
// Custom Rules should be fixed AT EARLIEST CONVENIENCE | ||
//config.customRules = require(path_to_custom.json); | ||
let auditor = new Auditor(config); | ||
auditor.analyze().then((results) => { | ||
@@ -36,0 +28,0 @@ let reporter = new BasicReporter(results); |
@@ -46,19 +46,16 @@ 'use strict' | ||
// iterate over Current and LTS audit signatures | ||
audits.forEach((audit) => { // O(n) | ||
let lineNo = 0; | ||
file.split('\n').forEach((line) => { // O(n) | ||
lineNo++; | ||
audit.signatures[ilk].forEach((signature) => { // O(n) | ||
if (line.match(signature.pattern)) { | ||
allResults.push({ | ||
signature: signature, | ||
file: { | ||
path: path, | ||
line: line, | ||
lineNumber: lineNo | ||
} | ||
}); | ||
} | ||
}); | ||
let lineNo = 0; | ||
file.split('\n').forEach((line) => { // O(n) | ||
lineNo++; | ||
audits.signatures[ilk].forEach((signature) => { // O(n) | ||
if (line.match(signature.pattern)) { | ||
allResults.push({ | ||
signature: signature, | ||
file: { | ||
path: path, | ||
line: line, | ||
lineNumber: lineNo | ||
} | ||
}); | ||
} | ||
}); | ||
@@ -65,0 +62,0 @@ }); |
{ | ||
"name": "encore-auditor", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Source code analyzer for EncoreUI applications.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/encore-auditor.js", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
28908
631
8
1