Skip to content

Commit

Permalink
Merge pull request #581 from protofire/develop
Browse files Browse the repository at this point in the history
5.0.1 Develop into Master
  • Loading branch information
dbale-altoros committed May 13, 2024
2 parents 7451f79 + cf6bf43 commit e20b8c8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [5.0.1] - 2024-05-13
### BREAKING CHANGES (refer to v5.0.0)
Fixed an issue on the returining values where only was evaluating the first report instead of all of them.


<br><br>
## [5.0.0] - 2024-05-11
### BREAKING CHANGES

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=5.0.0
ENV VERSION=5.0.1

RUN npm install -g solhint@"$VERSION"
24 changes: 16 additions & 8 deletions e2e/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('e2e', function () {

it('should show warning when using --init', function () {
const { code, stderr } = shell.exec(`${NODE}solhint --init`)

expect(code).to.equal(EXIT_CODES.BAD_OPTIONS)
expect(stderr).to.include('Configuration file already exists')
})
Expand All @@ -96,12 +96,12 @@ describe('e2e', function () {
const PATH = '03-no-empty-blocks'
const { PREFIX, SUFFIX } = prepareContext(PATH)

it('No contracts to lint should fail with appropiate message', function () {
const { code, stderr } = shell.exec(`${NODE}solhint Foo1.sol ${SUFFIX}`)
expect(code).to.equal(EXIT_CODES.BAD_OPTIONS)
expect(stderr).to.include('No files to lint!')
})
it('No contracts to lint should fail with appropiate message', function () {
const { code, stderr } = shell.exec(`${NODE}solhint Foo1.sol ${SUFFIX}`)

expect(code).to.equal(EXIT_CODES.BAD_OPTIONS)
expect(stderr).to.include('No files to lint!')
})

it('should end with REPORTED_ERRORS = 1 because report contains errors', function () {
const { code, stdout } = shell.exec(`${NODE}solhint ${PREFIX}Foo.sol ${SUFFIX}`)
Expand Down Expand Up @@ -193,6 +193,14 @@ describe('e2e', function () {

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

it('should exit with code 1 if one of evaluated contracts contains errors', function () {
const { code } = shell.exec(
`${NODE}solhint ${PREFIX}contracts/Foo.sol ${PREFIX}contracts/Foo2.sol ${SUFFIX}`
)

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

describe('Linter - foundry-test-functions with shell', () => {
Expand All @@ -211,7 +219,7 @@ describe('e2e', function () {

it(`should raise error for wrongFunctionDefinitionName() only`, () => {
const SUFFIX2 = `-c ${PREFIX}test/.solhint.json --disc`

const { code, stdout } = shell.exec(`${NODE}solhint ${PREFIX}test/FooTest.sol ${SUFFIX2}`)

expect(code).to.equal(EXIT_CODES.REPORTED_ERRORS)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "solhint",
"version": "5.0.0",
"version": "5.0.1",
"description": "Solidity Code Linter",
"main": "lib/index.js",
"keywords": [
Expand Down
11 changes: 6 additions & 5 deletions solhint.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,10 @@ function executeMainActionLogic() {

printReports(reports, formatterFn)

if (reports[0].errorCount > 0) process.exit(EXIT_CODES.REPORTED_ERRORS)
// check if there's any error reported
const reportedErrors = reports.some((obj) => obj.errorCount > 0)

process.exit(EXIT_CODES.OK)
process.exit(reportedErrors ? EXIT_CODES.REPORTED_ERRORS : EXIT_CODES.OK)
}

function processStdin(options) {
Expand All @@ -201,12 +202,12 @@ function processStdin(options) {
}

const reports = [report]

printReports(reports, formatterFn)

if (reports[0].errorCount > 0) process.exit(EXIT_CODES.REPORTED_ERRORS)
// check if there's any error reported
const reportedErrors = reports.some((obj) => obj.errorCount > 0)

process.exit(EXIT_CODES.OK)
process.exit(reportedErrors ? EXIT_CODES.REPORTED_ERRORS : EXIT_CODES.OK)
}

function writeSampleConfigFile() {
Expand Down

0 comments on commit e20b8c8

Please sign in to comment.