diff --git a/e2e/autofix-test.js b/e2e/autofix-test.js index 8a6ad611..16fd5daa 100644 --- a/e2e/autofix-test.js +++ b/e2e/autofix-test.js @@ -103,7 +103,7 @@ describe('e2e', function () { } ) - expect(solhintProcess.status).to.equal(1) + expect(solhintProcess.status).to.equal(0) expect(solhintProcess.stdout.toString().includes('5 problems (5 errors, 0 warnings)')) }) }) @@ -129,7 +129,7 @@ describe('e2e', function () { `${params.command} ${params.param1} -c ${currentConfig} ${currentFile} --fix --disc --noPrompt` ) - expect(code).to.equal(1) + expect(code).to.equal(0) const reportLines = stdout.split('\n') const finalLine = '5 problems (5 errors, 0 warnings)' @@ -175,8 +175,8 @@ describe('e2e', function () { expect(result).to.be.true }) - it('should execute and exit with code 1 (2)', () => { - expect(code).to.equal(1) + it('should execute and exit with code 0 (2)', () => { + expect(code).to.equal(0) }) it('should get the right report (2)', () => { @@ -222,7 +222,7 @@ describe('e2e', function () { }) it('should execute and exit with code 1 (3)', () => { - expect(code).to.equal(1) + expect(code).to.equal(0) }) it('should get the right report (3)', () => { @@ -268,7 +268,7 @@ describe('e2e', function () { }) it('should execute and exit with code 1 (4)', () => { - expect(code).to.equal(1) + expect(code).to.equal(0) }) it('should get the right report (4)', () => { @@ -314,7 +314,7 @@ describe('e2e', function () { }) it('should execute and exit with code 1 (5)', () => { - expect(code).to.equal(1) + expect(code).to.equal(0) }) it('should get the right report (5)', () => { @@ -361,7 +361,7 @@ describe('e2e', function () { }) it('should execute and exit with code 1 (6)', () => { - expect(code).to.equal(1) + expect(code).to.equal(0) }) it('should get the right report (6)', () => { @@ -401,7 +401,7 @@ describe('e2e', function () { }) it('should execute and exit with code 1 (6)', () => { - expect(code).to.equal(1) + expect(code).to.equal(0) }) it('should get the right report (6)', () => { @@ -448,7 +448,7 @@ describe('e2e', function () { }) it('should execute and exit with code 1 (7)', () => { - expect(code).to.equal(1) + expect(code).to.equal(0) }) it('should get the right report (7)', () => { @@ -494,7 +494,7 @@ describe('e2e', function () { }) it('should execute and exit with code 1 (8)', () => { - expect(code).to.equal(1) + expect(code).to.equal(0) }) it('should get the right report (8)', () => { @@ -540,7 +540,7 @@ describe('e2e', function () { }) it('should execute and exit with code 1 (8)', () => { - expect(code).to.equal(1) + expect(code).to.equal(0) }) it('should get the right report (8)', () => { diff --git a/e2e/formatters-test.js b/e2e/formatters-test.js index 09df3bc6..107b7306 100644 --- a/e2e/formatters-test.js +++ b/e2e/formatters-test.js @@ -81,7 +81,7 @@ describe('e2e', function () { expect(reportLines[i]).to.equal(expectedLine) } // because there's an error - expect(code).to.equal(1) + expect(code).to.equal(0) const finalLine = '10 problem/s (1 error/s, 9 warning/s)' expect(reportLines[reportLines.length - 2]).to.contain(finalLine) @@ -128,7 +128,7 @@ describe('e2e', function () { const strExpected = JSON.stringify(expectedFinalOutput) expect(strExpected).to.equal(strOutput) // There's an error, that is why exit code is 1 - expect(code).to.equal(1) + expect(code).to.equal(0) }) }) @@ -175,7 +175,7 @@ describe('e2e', function () { expect(reportLines[i]).to.equal(expectedLine) } // because there's an error - expect(code).to.equal(1) + expect(code).to.equal(0) const finalLine = '10 problem/s (1 error/s, 9 warning/s)' expect(reportLines[reportLines.length - 2]).to.contain(finalLine) @@ -240,7 +240,7 @@ describe('e2e', function () { expect(reportLines[i].replace(/\s/g, '')).to.equal(expectedLine.replace(/\s/g, '')) } - expect(code).to.equal(1) + expect(code).to.equal(0) const finalLine = '\u2716 10 problems (1 error, 9 warnings)' expect(reportLines[reportLines.length - 3]).to.equal(finalLine) @@ -342,7 +342,7 @@ describe('e2e', function () { expect(reportLines[3]).to.eq(tableHeader1) expect(reportLines[4]).to.eq(tableHeader2) - expect(code).to.equal(1) + expect(code).to.equal(0) }) }) @@ -670,7 +670,7 @@ describe('e2e', function () { ] // There's an error, that is why exit code is 1 - expect(code).to.equal(1) + expect(code).to.equal(0) expect(sarifOutput.runs[0].artifacts[0].location.uri).to.eq(expectedUriPathFoo) expect(sarifOutput.runs[0].artifacts[1].location.uri).to.eq(expectedUriPathFoo2) expect(sarifOutput.runs[0].artifacts[2].location.uri).to.eq(expectedUriPathFoo3) diff --git a/e2e/test.js b/e2e/test.js index c218dae1..ec40127c 100644 --- a/e2e/test.js +++ b/e2e/test.js @@ -73,14 +73,14 @@ describe('e2e', function () { describe('no-empty-blocks', function () { useFixture('03-no-empty-blocks') - it('should exit with 1', function () { + it('should end correctly (exit w/0), found 1 error', function () { const { code, stdout } = shell.exec('solhint Foo.sol') - expect(code).to.equal(1) + expect(code).to.equal(0) expect(stdout.trim()).to.contain('Code contains empty blocks') }) - it('should work with stdin', async function () { + it('should work with stdin, exit 0, found 1 error', async function () { const child = cp.exec('solhint stdin') const stdoutPromise = getStream(child.stdout) @@ -96,7 +96,7 @@ describe('e2e', function () { const code = await codePromise - expect(code).to.equal(1) + expect(code).to.equal(0) const stdout = await stdoutPromise @@ -127,7 +127,7 @@ describe('e2e', function () { expect(stdout.trim()).to.not.contain(warningExceededMsg) }) - it('should display [warnings exceeded] for max 3 warnings and exit error 1', function () { + it('should display [warnings exceeded] for max 3 warnings and exit with 0', function () { const { code, stdout } = shell.exec('solhint contracts/Foo.sol --max-warnings 3') expect(code).to.equal(1) @@ -137,13 +137,13 @@ describe('e2e', function () { it('should return error for Compiler version rule, ignoring 3 --max-warnings', function () { const { code, stdout } = shell.exec('solhint contracts/Foo2.sol --max-warnings 3') - expect(code).to.equal(1) + expect(code).to.equal(0) expect(stdout.trim()).to.contain(errorFound) }) it('should return error for Compiler version rule. No message for max-warnings', function () { const { code, stdout } = shell.exec('solhint contracts/Foo2.sol --max-warnings 27') - expect(code).to.equal(1) + expect(code).to.equal(0) expect(stdout.trim()).to.not.contain(errorFound) }) }) @@ -163,7 +163,7 @@ describe('e2e', function () { it(`should raise error for wrongFunctionDefinitionName() only`, () => { const { code, stdout } = shell.exec('solhint -c test/.solhint.json test/FooTest.sol') - expect(code).to.equal(1) + expect(code).to.equal(0) expect(stdout.trim()).to.contain( 'Function wrongFunctionDefinitionName() must match Foundry test naming convention' ) diff --git a/solhint.js b/solhint.js index 484c643f..755a910c 100755 --- a/solhint.js +++ b/solhint.js @@ -28,7 +28,6 @@ function init() { .option('-q, --quiet', 'report errors only - default: false') .option('--ignore-path [file_name]', 'file to use as your .solhintignore') .option('--fix', 'automatically fix problems. Skips fixes in report') - // .option('--fixShow', 'automatically fix problems. Show fixes in report') .option('--noPrompt', 'do not suggest to backup files when any `fix` option is selected') .option('--init', 'create configuration file for solhint') .option('--disc', 'do not check for solhint updates') @@ -81,7 +80,6 @@ function askUserToContinue(callback) { } function execMainAction() { - // if ((program.opts().fix || program.opts().fixShow) && !program.opts().noPrompt) { if (program.opts().fix && !program.opts().noPrompt) { askUserToContinue((userAnswer) => { if (userAnswer !== 'y') { @@ -162,7 +160,8 @@ function executeMainActionLogic() { printReports(reports, formatterFn) - exitWithCode(reports) + // exitWithCode(reports) + process.exit(0) } function processStdin(options) { @@ -183,8 +182,8 @@ function processStdin(options) { const reports = [report] printReports(reports, formatterFn) - - exitWithCode(reports) + process.exit(0) + // exitWithCode(reports) } function writeSampleConfigFile() { @@ -364,10 +363,10 @@ function listRules() { } } -function exitWithCode(reports) { - const errorsCount = reports.reduce((acc, i) => acc + i.errorCount, 0) - process.exit(errorsCount > 0 ? 1 : 0) -} +// function exitWithCode(reports) { +// const errorsCount = reports.reduce((acc, i) => acc + i.errorCount, 0) +// process.exit(errorsCount > 0 ? 1 : 0) +// } function checkForUpdate() { // eslint-disable-next-line import/no-extraneous-dependencies