Skip to content

Commit

Permalink
Remove unnecesary function and move the filtering of errors into exec…
Browse files Browse the repository at this point in the history
…MainAction(). Move new --quiet option declaration to the correct place.
  • Loading branch information
florblue committed Aug 30, 2018
1 parent 88858a7 commit a2f5daa
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions solhint.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ function init() {
program
.usage('[options] <file> [...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')
Expand All @@ -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);
Expand Down Expand Up @@ -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}`);
Expand Down

0 comments on commit a2f5daa

Please sign in to comment.