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

feat: control fail severity and result display #540

Merged
merged 4 commits into from
Sep 17, 2019
Merged

Conversation

philsturgeon
Copy link
Contributor

@philsturgeon philsturgeon commented Sep 10, 2019

Fixes #368

Let folks control what results are displayed, and what level off severity constitutes a failure. This PR respects the existing behavior and does not break BC, but we should raise the default --fail-severity to warn in v5.0.

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

Screenshots

image

@philsturgeon philsturgeon force-pushed the feat/error-only-error branch 2 times, most recently from 6a9e2c6 to b452e9d Compare September 10, 2019 20:19
@philsturgeon philsturgeon self-assigned this Sep 10, 2019
@philsturgeon philsturgeon force-pushed the feat/error-only-error branch 2 times, most recently from df663cd to f817006 Compare September 10, 2019 20:26
P0lip
P0lip previously approved these changes Sep 11, 2019
--version Show version number [boolean]
--help Show help [boolean]
--encoding, -e text encoding to use [string] [default: "utf8"]
--format, -f formatter to use for outputting results [string] [default: "stylish"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the lack of available formats expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not no. damn where'd they go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

This PR did not remove them, the test harness shows that develop branch is missing them already. Let's carry on with this merge and fix them in another PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alrighty, sounds good.

--skip-rule, -s ignore certain rules if they are causing trouble [string]
--fail-severity, -F results of this level or above will trigger a failure exit code
[string] [choices: "error", "warn", "info", "hint"] [default: "hint"]
--display-only-failures, -D only output results equal to or greater than --fail-severity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

greater sounds a bit unfortunate, given DiagnosticSeverity.Error equals 0, Warn 1 etc.
I know what the intention is, but perhaps there is a way to make it more clear, i.e. more severe or higher/lower?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

greater and higher are synonomous and i dont think anyone knows what the internal ints are? This is probably find, if anyone gets confused we can ask them for suggestions.

src/cli/commands/lint.ts Outdated Show resolved Hide resolved
},
'display-only-failures': {
alias: 'D',
description: 'only output results equal to or greater than --fail-severity',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in docs.

src/cli/commands/lint.ts Outdated Show resolved Hide resolved
docs/guides/cli.md Outdated Show resolved Hide resolved
.then(results => {
if (results.length) {
process.exitCode = 1;
process.exitCode = severeEnoughToFail(results, failSeverity) ? 1 : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
process.exitCode = severeEnoughToFail(results, failSeverity) ? 1 : 0;
process.exitCode = isSevereEnoughToFail(results, failSeverity) ? 1 : 0;

const expectedStatus = replaceVars(scenario.status.trim(), replacements);
const expectedStdout = replaceVars(scenario.stdout.trim(), replacements);
const expectedStderr = replaceVars(scenario.stderr.trim(), replacements);
const status = commandHandle.status;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's maybe differentiate between expected and actual to be consistent? here, actualStatus would tell more than just status

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actualStatus is the status. I think t's ok.

lag-of-death
lag-of-death previously approved these changes Sep 11, 2019
Copy link
Contributor

@lag-of-death lag-of-death left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a couple of suggestions, looks cool 👍

Co-Authored-By: lag-of-death <[email protected]>
Co-Authored-By: Jakub Rożek <[email protected]>
lag-of-death
lag-of-death previously approved these changes Sep 13, 2019
P0lip
P0lip previously approved these changes Sep 16, 2019
@P0lip P0lip dismissed stale reviews from lag-of-death and themself via 5001713 September 17, 2019 08:02
Copy link
Contributor

@P0lip P0lip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving.

@P0lip P0lip merged commit 19e5e81 into develop Sep 17, 2019
@P0lip P0lip deleted the feat/error-only-error branch September 17, 2019 08:24
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.

Make CLI not to return non-zero exist code when only warnings occur
3 participants