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

Fix exit codes and max-warnings on quiet #578

Merged
merged 4 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## [5.0.0] - 2024-05-11
### BREAKING CHANGES

#### Solhint EXIT codes
Solhint changed how the exit codes are implemented:

`Exit with 0 code` When execution was ok and there were no errors when evaluating the code according to the rules<br>
`Exit with 1 code` When execution was ok and there are errors reported<br>
`Exit with 1 code` When execution was ok and max warnings is lower than the reported warnings<br>
`Exit with 255 code` When there's an error in the execution (bad config, writing not allowed, wrong parameter, file not found, etc)<br>

#### Solhint QUIET mode
QUIET mode (-c quiet) option now works with the warnings and may exit with 1 if there are more than defined by user

Thanks to [@juanpcapurro](https://github.com/juanpcapurro) for providing the code

<br><br>
## [4.5.4] - 2024-04-10
### Fixed
- `gas-custom-errors` improved logic to ranged pragma versions [#573](https://github.com/protofire/solhint/pull/573)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Options:

-V, --version output the version number
-f, --formatter [name] report formatter name (stylish, table, tap, unix, json, compact, sarif)
-w, --max-warnings [maxWarningsNumber] number of allowed warnings
-w, --max-warnings [maxWarningsNumber] number of allowed warnings, works in quiet mode as well
-c, --config [file_name] file to use as your .solhint.json
-q, --quiet report errors only - default: false
--ignore-path [file_name] file to use as your .solhintignore
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM node:20-alpine
LABEL maintainer="diego.bale@protofire.io"
ENV VERSION=4.5.4
ENV VERSION=5.0.0

RUN npm install -g solhint@"$VERSION"
27 changes: 14 additions & 13 deletions e2e/autofix-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const shell = require('shelljs')
const spawnSync = require('spawn-sync')

const E2E = true
const EXIT_CODES = { BAD_OPTIONS: 255, OK: 0, REPORTED_ERRORS: 1 }

let params
let currentConfig
Expand Down Expand Up @@ -103,7 +104,7 @@ describe('e2e', function () {
}
)

expect(solhintProcess.status).to.equal(0)
expect(solhintProcess.status).to.equal(EXIT_CODES.REPORTED_ERRORS)
expect(solhintProcess.stdout.toString().includes('5 problems (5 errors, 0 warnings)'))
})
})
Expand All @@ -129,7 +130,7 @@ describe('e2e', function () {
`${params.command} ${params.param1} -c ${currentConfig} ${currentFile} --fix --disc --noPrompt`
)

expect(code).to.equal(0)
expect(code).to.equal(EXIT_CODES.REPORTED_ERRORS)

const reportLines = stdout.split('\n')
const finalLine = '5 problems (5 errors, 0 warnings)'
Expand Down Expand Up @@ -175,8 +176,8 @@ describe('e2e', function () {
expect(result).to.be.true
})

it('should execute and exit with code 0 (2)', () => {
expect(code).to.equal(0)
it('should execute and exit with code 1 (2)', () => {
expect(code).to.equal(EXIT_CODES.REPORTED_ERRORS)
})

it('should get the right report (2)', () => {
Expand Down Expand Up @@ -221,8 +222,8 @@ describe('e2e', function () {
expect(result).to.be.true
})

it('should execute and exit with code 1 (3)', () => {
expect(code).to.equal(0)
it('should execute and exit with code 0 (3)', () => {
expect(code).to.equal(EXIT_CODES.REPORTED_ERRORS)
})

it('should get the right report (3)', () => {
Expand Down Expand Up @@ -268,7 +269,7 @@ describe('e2e', function () {
})

it('should execute and exit with code 1 (4)', () => {
expect(code).to.equal(0)
expect(code).to.equal(EXIT_CODES.REPORTED_ERRORS)
})

it('should get the right report (4)', () => {
Expand Down Expand Up @@ -314,7 +315,7 @@ describe('e2e', function () {
})

it('should execute and exit with code 1 (5)', () => {
expect(code).to.equal(0)
expect(code).to.equal(EXIT_CODES.REPORTED_ERRORS)
})

it('should get the right report (5)', () => {
Expand Down Expand Up @@ -361,7 +362,7 @@ describe('e2e', function () {
})

it('should execute and exit with code 1 (6)', () => {
expect(code).to.equal(0)
expect(code).to.equal(EXIT_CODES.REPORTED_ERRORS)
})

it('should get the right report (6)', () => {
Expand Down Expand Up @@ -401,7 +402,7 @@ describe('e2e', function () {
})

it('should execute and exit with code 1 (6)', () => {
expect(code).to.equal(0)
expect(code).to.equal(EXIT_CODES.REPORTED_ERRORS)
})

it('should get the right report (6)', () => {
Expand Down Expand Up @@ -448,7 +449,7 @@ describe('e2e', function () {
})

it('should execute and exit with code 1 (7)', () => {
expect(code).to.equal(0)
expect(code).to.equal(EXIT_CODES.REPORTED_ERRORS)
})

it('should get the right report (7)', () => {
Expand Down Expand Up @@ -494,7 +495,7 @@ describe('e2e', function () {
})

it('should execute and exit with code 1 (8)', () => {
expect(code).to.equal(0)
expect(code).to.equal(EXIT_CODES.REPORTED_ERRORS)
})

it('should get the right report (8)', () => {
Expand Down Expand Up @@ -540,7 +541,7 @@ describe('e2e', function () {
})

it('should execute and exit with code 1 (8)', () => {
expect(code).to.equal(0)
expect(code).to.equal(EXIT_CODES.REPORTED_ERRORS)
})

it('should get the right report (8)', () => {
Expand Down
Loading
Loading