Skip to content
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

Merged
merged 3 commits into from
Sep 3, 2018

Conversation

florblue
Copy link
Contributor

@florblue florblue commented Aug 28, 2018

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

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

…t filter only error from linter results, and it was modified execMainAction() function to add the quiet option
@coveralls
Copy link

coveralls commented Aug 28, 2018

Coverage Status

Coverage remained the same at 99.657% when pulling a2f5daa on Cambalab:add-contribution-quiet-option into aa45463 on protofire:master.

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')
Copy link
Contributor

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.

Copy link
Contributor Author

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::::');
Copy link
Contributor

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

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');
Copy link
Contributor

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);
Copy link
Contributor

@fvictorio fvictorio Aug 30, 2018

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.

Copy link
Contributor Author

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.
@fvictorio fvictorio merged commit 2263ccb into protofire:master Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants