Skip to content

Commit 7bb8a28

Browse files
author
dbale-altoros
committed
added compact format and e2e tests
1 parent af1c996 commit 7bb8a28

File tree

14 files changed

+603
-15
lines changed

14 files changed

+603
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Linter for Solidity programming language
5555
Options:
5656
5757
-V, --version output the version number
58-
-f, --formatter [name] report formatter name (stylish, table, tap, unix, json)
58+
-f, --formatter [name] report formatter name (stylish, table, tap, unix, json, compact)
5959
-w, --max-warnings [maxWarningsNumber] number of allowed warnings
6060
-c, --config [file_name] file to use as your .solhint.json
6161
-q, --quiet report errors only - default: false

e2e/06-formatters/.solhint.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "solhint:all"
3+
}

e2e/06-formatters/contracts/Foo.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity >=0.6.0;
3+
4+
contract Foo {
5+
uint256 public constant test1 = 1;
6+
uint256 TEST2;
7+
8+
constructor() {
9+
10+
}
11+
}

e2e/06-formatters/contracts/Foo2.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity >=0.5.8;
3+
4+
contract Foo {
5+
uint256 public constant test1 = 1;
6+
7+
constructor() {
8+
9+
}
10+
}

e2e/06-formatters/contracts/Foo3.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity >=0.5.8;
3+
4+
contract Foo {
5+
uint256 public constant TEST1 = 1;
6+
uint256 public value;
7+
8+
function _goodContract() private {
9+
value = TEST1;
10+
}
11+
}

e2e/06-formatters/helpers/helpers.js

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
const foo1Output = [
2+
{
3+
line: 2,
4+
column: 1,
5+
severity: 'Error',
6+
message: 'Compiler version >=0.6.0 does not satisfy the ^0.5.8 semver requirement',
7+
ruleId: 'compiler-version',
8+
fix: null,
9+
filePath: 'contracts/Foo.sol',
10+
},
11+
{
12+
line: 5,
13+
column: 5,
14+
severity: 'Warning',
15+
message: 'Constant name must be in capitalized SNAKE_CASE',
16+
ruleId: 'const-name-snakecase',
17+
fix: null,
18+
filePath: 'contracts/Foo.sol',
19+
},
20+
{
21+
line: 6,
22+
column: 5,
23+
severity: 'Warning',
24+
message: 'Explicitly mark visibility of state',
25+
ruleId: 'state-visibility',
26+
fix: null,
27+
filePath: 'contracts/Foo.sol',
28+
},
29+
{
30+
line: 6,
31+
column: 5,
32+
severity: 'Warning',
33+
message: "'TEST2' should start with _",
34+
ruleId: 'private-vars-leading-underscore',
35+
fix: null,
36+
filePath: 'contracts/Foo.sol',
37+
},
38+
{
39+
line: 6,
40+
column: 5,
41+
severity: 'Warning',
42+
message: 'Variable name must be in mixedCase',
43+
ruleId: 'var-name-mixedcase',
44+
fix: null,
45+
filePath: 'contracts/Foo.sol',
46+
},
47+
{
48+
line: 8,
49+
column: 5,
50+
severity: 'Warning',
51+
message:
52+
'Explicitly mark visibility in function (Set ignoreConstructors to true if using solidity >=0.7.0)',
53+
ruleId: 'func-visibility',
54+
fix: null,
55+
filePath: 'contracts/Foo.sol',
56+
},
57+
{
58+
line: 8,
59+
column: 19,
60+
severity: 'Warning',
61+
message: 'Code contains empty blocks',
62+
ruleId: 'no-empty-blocks',
63+
fix: null,
64+
filePath: 'contracts/Foo.sol',
65+
},
66+
]
67+
68+
const foo2Output = [
69+
{
70+
line: 5,
71+
column: 5,
72+
severity: 'Warning',
73+
message: 'Constant name must be in capitalized SNAKE_CASE',
74+
ruleId: 'const-name-snakecase',
75+
fix: null,
76+
filePath: 'contracts/Foo2.sol',
77+
},
78+
{
79+
line: 7,
80+
column: 5,
81+
severity: 'Warning',
82+
message:
83+
'Explicitly mark visibility in function (Set ignoreConstructors to true if using solidity >=0.7.0)',
84+
ruleId: 'func-visibility',
85+
fix: null,
86+
filePath: 'contracts/Foo2.sol',
87+
},
88+
{
89+
line: 7,
90+
column: 19,
91+
severity: 'Warning',
92+
message: 'Code contains empty blocks',
93+
ruleId: 'no-empty-blocks',
94+
fix: null,
95+
filePath: 'contracts/Foo2.sol',
96+
},
97+
]
98+
99+
module.exports = { foo1Output, foo2Output }

0 commit comments

Comments
 (0)