Skip to content

Commit

Permalink
added compact format and e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dbale-altoros committed Jul 25, 2023
1 parent af1c996 commit a3c4bad
Show file tree
Hide file tree
Showing 15 changed files with 604 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/E2E.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: solhint --version

- name: Run E2E Tests
run: cd e2e && npm install && npm test
run: cd e2e && npm install && npm test && npm test-formatter

e2e_windows:
runs-on: windows-latest
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
run: npm run lint

- name: Run E2E Tests
run: cd e2e && npm install && npm test
run: cd e2e && npm install && npm test && npm test-formatter

e2e_macos:
runs-on: macos-latest
Expand All @@ -106,4 +106,4 @@ jobs:
run: npm run lint

- name: Run Tests
run: cd e2e && npm install && npm test
run: cd e2e && npm install && npm test && npm test-formatter
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Linter for Solidity programming language
Options:
-V, --version output the version number
-f, --formatter [name] report formatter name (stylish, table, tap, unix, json)
-f, --formatter [name] report formatter name (stylish, table, tap, unix, json, compact)
-w, --max-warnings [maxWarningsNumber] number of allowed warnings
-c, --config [file_name] file to use as your .solhint.json
-q, --quiet report errors only - default: false
Expand Down
3 changes: 3 additions & 0 deletions e2e/06-formatters/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "solhint:all"
}
11 changes: 11 additions & 0 deletions e2e/06-formatters/contracts/Foo.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;

contract Foo {
uint256 public constant test1 = 1;
uint256 TEST2;

constructor() {

}
}
10 changes: 10 additions & 0 deletions e2e/06-formatters/contracts/Foo2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.8;

contract Foo {
uint256 public constant test1 = 1;

constructor() {

}
}
11 changes: 11 additions & 0 deletions e2e/06-formatters/contracts/Foo3.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.8;

contract Foo {
uint256 public constant TEST1 = 1;
uint256 public value;

function _goodContract() private {
value = TEST1;
}
}
99 changes: 99 additions & 0 deletions e2e/06-formatters/helpers/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
const foo1Output = [
{
line: 2,
column: 1,
severity: 'Error',
message: 'Compiler version >=0.6.0 does not satisfy the ^0.5.8 semver requirement',
ruleId: 'compiler-version',
fix: null,
filePath: 'contracts/Foo.sol',
},
{
line: 5,
column: 5,
severity: 'Warning',
message: 'Constant name must be in capitalized SNAKE_CASE',
ruleId: 'const-name-snakecase',
fix: null,
filePath: 'contracts/Foo.sol',
},
{
line: 6,
column: 5,
severity: 'Warning',
message: 'Explicitly mark visibility of state',
ruleId: 'state-visibility',
fix: null,
filePath: 'contracts/Foo.sol',
},
{
line: 6,
column: 5,
severity: 'Warning',
message: "'TEST2' should start with _",
ruleId: 'private-vars-leading-underscore',
fix: null,
filePath: 'contracts/Foo.sol',
},
{
line: 6,
column: 5,
severity: 'Warning',
message: 'Variable name must be in mixedCase',
ruleId: 'var-name-mixedcase',
fix: null,
filePath: 'contracts/Foo.sol',
},
{
line: 8,
column: 5,
severity: 'Warning',
message:
'Explicitly mark visibility in function (Set ignoreConstructors to true if using solidity >=0.7.0)',
ruleId: 'func-visibility',
fix: null,
filePath: 'contracts/Foo.sol',
},
{
line: 8,
column: 19,
severity: 'Warning',
message: 'Code contains empty blocks',
ruleId: 'no-empty-blocks',
fix: null,
filePath: 'contracts/Foo.sol',
},
]

const foo2Output = [
{
line: 5,
column: 5,
severity: 'Warning',
message: 'Constant name must be in capitalized SNAKE_CASE',
ruleId: 'const-name-snakecase',
fix: null,
filePath: 'contracts/Foo2.sol',
},
{
line: 7,
column: 5,
severity: 'Warning',
message:
'Explicitly mark visibility in function (Set ignoreConstructors to true if using solidity >=0.7.0)',
ruleId: 'func-visibility',
fix: null,
filePath: 'contracts/Foo2.sol',
},
{
line: 7,
column: 19,
severity: 'Warning',
message: 'Code contains empty blocks',
ruleId: 'no-empty-blocks',
fix: null,
filePath: 'contracts/Foo2.sol',
},
]

module.exports = { foo1Output, foo2Output }
Loading

0 comments on commit a3c4bad

Please sign in to comment.