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

Exit code 1 should only be used to flag rule violations in API files #2150

Open
maxi-milian opened this issue May 4, 2022 · 0 comments
Open

Comments

@maxi-milian
Copy link

Describe the bug

Assume that ruleset.yml and openapi.yml are available in the current dir and that openapi.yml violates some rules defined in ruleset.yml. This is flagged with exit code 1:

spectral lint -r ruleset.yml openapi.yml
echo $? # prints 1

👍

Other errors are flagged with nonzero exit code != 1. Assume that not-available.yml is not there in the current directory
and that invalid.yml is available but does not store a valid ruleset:

spectral lint -r ruleset.yml not-available.yml --fail-on-unmatched-globs
echo $? # prints 2
spectral lint -r invalid.yml openapi.yml
echo $? # prints 2
spectral lint -r not-available.yml openapi.yml
echo $? # prints 2

👍

However, there are some types of errors (Unknown arguments, Invalid values and maybe more) which are flagged with exit code 1:

spectral lint -r ruleset.yml openapi.yml --fail-severity invalid-value
echo $? # prints 1
spectral lint -r ruleset.yml openapi.yml --unknown-arg
echo $? # prints 1

Unfortunately this makes it impossible to evaluate a Spectral lint run by just inspecting the exit code. 😢

To Reproduce

spectral lint -r not-available.yml not-available.yml --invalid-arg
echo $? # prints 1

Expected behavior

Any error is flagged with nonzero exit code != 1. Rule violation in API file is flagged with exit code 1.

Environment

  • Library version: 6.3.0

Additional context

See also #2149

@P0lip P0lip added the CLI CLI component label May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants