diff --git a/solhint.js b/solhint.js index 2803e869..44341d28 100755 --- a/solhint.js +++ b/solhint.js @@ -14,12 +14,10 @@ function init() { program .usage('[options] [...other_files]') .option('-f, --formatter [name]', 'report formatter name (stylish, table, tap, unix)') + .option('-q, --quiet', 'report errors only - default: false') .description('Linter for Solidity programming language') .action(execMainAction); - program - .option('-q, --quiet', 'report errors only - default: false'); - program .command('stdin') .description('linting of source code data provided to STDIN') @@ -43,8 +41,8 @@ function execMainAction() { const reports =_.flatten(reportLists); if (program.quiet) { - // Setting int the report list errors only. - reports[0].reports = getErrorResults(reports); + // filter the list of reports, to set errors only. + reports[0].reports = reports[0].reports.filter(i => i.severity === 2); } printReports(reports, program.formatter); @@ -121,17 +119,6 @@ function processPath(path) { return linter.processPath(path, readConfig()); } - -/** - * Returns results that only contains errors. - * @param {LintResult[]} reporter The results to filter. - * @returns {LintResult[]} The filtered results. -**/ -function getErrorResults(reporter) { - return reporter[0].reports.filter(i => i.severity === 2); - -} - function printReports(reports, formatter) { const formatterName = formatter || 'stylish'; const formatterFn = require(`eslint/lib/formatters/${formatterName}`);