-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --quiet option #55
Add --quiet option #55
Conversation
…t filter only error from linter results, and it was modified execMainAction() function to add the quiet option
solhint.js
Outdated
@@ -17,6 +17,11 @@ function init() { | |||
.description('Linter for Solidity programming language') | |||
.action(execMainAction); | |||
|
|||
program | |||
.usage('[options] <file> [...other_files]') | |||
.option('-q, --quiet', 'report errors only - default: false') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicating the previous block. I think you just need to add the .option
line in that block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, I will modify it.
solhint.js
Outdated
@@ -39,6 +44,12 @@ function execMainAction() { | |||
const reportLists = program.args.filter(_.isString).map(processPath); | |||
const reports =_.flatten(reportLists); | |||
|
|||
if (program.quiet) { | |||
console.log('::::Quiet mode enabled - filtering out warnings::::'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that we should log anything here.
solhint.js
Outdated
* @returns {LintResult[]} The filtered results. | ||
**/ | ||
function getErrorResults(reporter) { | ||
const reporterErrors = reporter[0].reports.filter(i => i.severity === 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is short and unlikely to be reused, I would do it inline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, its a good observation.
…g when quiet option in enable.
solhint.js
Outdated
@@ -17,6 +17,9 @@ function init() { | |||
.description('Linter for Solidity programming language') | |||
.action(execMainAction); | |||
|
|||
program | |||
.option('-q, --quiet', 'report errors only - default: false'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be chained after line 16.
solhint.js
Outdated
* @returns {LintResult[]} The filtered results. | ||
**/ | ||
function getErrorResults(reporter) { | ||
return reporter[0].reports.filter(i => i.severity === 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I wasn't clear about this. I meant that the function should be removed and the filter inlined in the if (program.quiet)
block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I get it now
…MainAction(). Move new --quiet option declaration to the correct place.
Description
It was added --quiet (-q) option that allows to report errors only, filtering out warnings reports.
Its resolves an item of Issue #5
To do this, it was modified execMainAction(), and it was added a function that filter errors reports.
Type of change