Skip to content

Commit 87ed103

Browse files
committed
[PLUTO-1431] add tests
1 parent 87ce0a8 commit 87ed103

File tree

6 files changed

+374
-0
lines changed

6 files changed

+374
-0
lines changed

integration-tests/init-without-token/expected/codacy.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ runtimes:
33
44
55
6+
67
tools:
78
89
@@ -11,3 +12,4 @@ tools:
1112
1213
1314
15+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[revive]
2+
ignoreGeneratedHeader = true
3+
severity = "warning"
4+
confidence = 0.8
5+
errorCode = 0
6+
warningCode = 0
7+
8+
rules = ["blank-imports", "context-as-argument", "context-keys-type", "dot-imports", "empty-block", "error-naming", "error-return", "error-strings", "errorf", "exported", "increment-decrement", "indent-error-flow", "package-comments", "range", "receiver-naming", "redefines-builtin-id", "superfluous-else", "time-naming", "unexported-return", "unreachable-code", "unused-parameter", "var-declaration", "var-naming"]
9+
10+
[rule.blank-imports]
11+
12+
[rule.context-as-argument]
13+
14+
[rule.context-keys-type]
15+
16+
[rule.dot-imports]
17+
18+
[rule.empty-block]
19+
20+
[rule.error-naming]
21+
22+
[rule.error-return]
23+
24+
[rule.error-strings]
25+
26+
[rule.errorf]
27+
28+
[rule.exported]
29+
30+
[rule.increment-decrement]
31+
32+
[rule.indent-error-flow]
33+
34+
[rule.package-comments]
35+
36+
[rule.range]
37+
38+
[rule.receiver-naming]
39+
40+
[rule.redefines-builtin-id]
41+
42+
[rule.superfluous-else]
43+
arguments = [""]
44+
45+
[rule.time-naming]
46+
47+
[rule.unexported-return]
48+
49+
[rule.unreachable-code]
50+
51+
[rule.unused-parameter]
52+
53+
[rule.var-declaration]
54+
55+
[rule.var-naming]
56+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
runtimes:
2+
3+
tools:
4+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[revive]
2+
ignoreGeneratedHeader = true
3+
severity = "warning"
4+
confidence = 0.8
5+
errorCode = 0
6+
warningCode = 0
7+
8+
rules = ["blank-imports", "context-as-argument", "context-keys-type", "dot-imports", "empty-block", "error-naming", "error-return", "error-strings", "errorf", "exported", "increment-decrement", "indent-error-flow", "package-comments", "range", "receiver-naming", "redefines-builtin-id", "superfluous-else", "time-naming", "unexported-return", "unreachable-code", "unused-parameter", "var-declaration", "var-naming"]
9+
10+
[rule.blank-imports]
11+
12+
[rule.context-as-argument]
13+
14+
[rule.context-keys-type]
15+
16+
[rule.dot-imports]
17+
18+
[rule.empty-block]
19+
20+
[rule.error-naming]
21+
22+
[rule.error-return]
23+
24+
[rule.error-strings]
25+
26+
[rule.errorf]
27+
28+
[rule.exported]
29+
30+
[rule.increment-decrement]
31+
32+
[rule.indent-error-flow]
33+
34+
[rule.package-comments]
35+
36+
[rule.range]
37+
38+
[rule.receiver-naming]
39+
40+
[rule.redefines-builtin-id]
41+
42+
[rule.superfluous-else]
43+
arguments = [""]
44+
45+
[rule.time-naming]
46+
47+
[rule.unexported-return]
48+
49+
[rule.unreachable-code]
50+
51+
[rule.unused-parameter]
52+
53+
[rule.var-declaration]
54+
55+
[rule.var-naming]
56+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package testdata
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
// This function has too many arguments, a magic number, and a bare return
8+
func BadFunction(a int, b int, c int, d int, e int) int {
9+
var foo int = 42 // magic number
10+
if foo == 42 {
11+
fmt.Println("foo is 42")
12+
return
13+
}
14+
return foo
15+
}
16+
17+
// This function has a confusing name and an unused parameter
18+
func xYz(_ int, unused int) {
19+
fmt.Println("confusing name and unused param")
20+
}
21+
22+
// This function has a long line
23+
func LongLine() {
24+
fmt.Println("This is a very very very very very very very very very very very very very very very very very very very long line")
25+
}
26+
27+
// This function has a naked return
28+
func NakedReturn() (x int) {
29+
return
30+
}
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
3+
"runs": [
4+
{
5+
"results": [
6+
{
7+
"locations": [
8+
{
9+
"physicalLocation": {
10+
"artifactLocation": {
11+
"uri": "bad.go"
12+
},
13+
"region": {
14+
"startColumn": 18,
15+
"startLine": 8
16+
}
17+
}
18+
}
19+
],
20+
"message": {
21+
"text": "parameter 'a' seems to be unused, consider removing or renaming it as _"
22+
},
23+
"ruleId": "unused-parameter"
24+
},
25+
{
26+
"locations": [
27+
{
28+
"physicalLocation": {
29+
"artifactLocation": {
30+
"uri": "bad.go"
31+
},
32+
"region": {
33+
"startColumn": 25,
34+
"startLine": 8
35+
}
36+
}
37+
}
38+
],
39+
"message": {
40+
"text": "parameter 'b' seems to be unused, consider removing or renaming it as _"
41+
},
42+
"ruleId": "unused-parameter"
43+
},
44+
{
45+
"locations": [
46+
{
47+
"physicalLocation": {
48+
"artifactLocation": {
49+
"uri": "bad.go"
50+
},
51+
"region": {
52+
"startColumn": 32,
53+
"startLine": 8
54+
}
55+
}
56+
}
57+
],
58+
"message": {
59+
"text": "parameter 'c' seems to be unused, consider removing or renaming it as _"
60+
},
61+
"ruleId": "unused-parameter"
62+
},
63+
{
64+
"locations": [
65+
{
66+
"physicalLocation": {
67+
"artifactLocation": {
68+
"uri": "bad.go"
69+
},
70+
"region": {
71+
"startColumn": 39,
72+
"startLine": 8
73+
}
74+
}
75+
}
76+
],
77+
"message": {
78+
"text": "parameter 'd' seems to be unused, consider removing or renaming it as _"
79+
},
80+
"ruleId": "unused-parameter"
81+
},
82+
{
83+
"locations": [
84+
{
85+
"physicalLocation": {
86+
"artifactLocation": {
87+
"uri": "bad.go"
88+
},
89+
"region": {
90+
"startColumn": 46,
91+
"startLine": 8
92+
}
93+
}
94+
}
95+
],
96+
"message": {
97+
"text": "parameter 'e' seems to be unused, consider removing or renaming it as _"
98+
},
99+
"ruleId": "unused-parameter"
100+
},
101+
{
102+
"locations": [
103+
{
104+
"physicalLocation": {
105+
"artifactLocation": {
106+
"uri": "bad.go"
107+
},
108+
"region": {
109+
"startColumn": 17,
110+
"startLine": 18
111+
}
112+
}
113+
}
114+
],
115+
"message": {
116+
"text": "parameter 'unused' seems to be unused, consider removing or renaming it as _"
117+
},
118+
"ruleId": "unused-parameter"
119+
},
120+
{
121+
"locations": [
122+
{
123+
"physicalLocation": {
124+
"artifactLocation": {
125+
"uri": "bad.go"
126+
},
127+
"region": {
128+
"startColumn": 10,
129+
"startLine": 9
130+
}
131+
}
132+
}
133+
],
134+
"message": {
135+
"text": "should omit type int from declaration of var foo; it will be inferred from the right-hand side"
136+
},
137+
"ruleId": "var-declaration"
138+
},
139+
{
140+
"locations": [
141+
{
142+
"physicalLocation": {
143+
"artifactLocation": {
144+
"uri": "bad.go"
145+
},
146+
"region": {
147+
"startColumn": 1,
148+
"startLine": 7
149+
}
150+
}
151+
}
152+
],
153+
"message": {
154+
"text": "comment on exported function BadFunction should be of the form \"BadFunction ...\""
155+
},
156+
"ruleId": "exported"
157+
},
158+
{
159+
"locations": [
160+
{
161+
"physicalLocation": {
162+
"artifactLocation": {
163+
"uri": "bad.go"
164+
},
165+
"region": {
166+
"startColumn": 1,
167+
"startLine": 22
168+
}
169+
}
170+
}
171+
],
172+
"message": {
173+
"text": "comment on exported function LongLine should be of the form \"LongLine ...\""
174+
},
175+
"ruleId": "exported"
176+
},
177+
{
178+
"locations": [
179+
{
180+
"physicalLocation": {
181+
"artifactLocation": {
182+
"uri": "bad.go"
183+
},
184+
"region": {
185+
"startColumn": 1,
186+
"startLine": 27
187+
}
188+
}
189+
}
190+
],
191+
"message": {
192+
"text": "comment on exported function NakedReturn should be of the form \"NakedReturn ...\""
193+
},
194+
"ruleId": "exported"
195+
},
196+
{
197+
"locations": [
198+
{
199+
"physicalLocation": {
200+
"artifactLocation": {
201+
"uri": "bad.go"
202+
},
203+
"region": {
204+
"startColumn": 1,
205+
"startLine": 1
206+
}
207+
}
208+
}
209+
],
210+
"message": {
211+
"text": "should have a package comment"
212+
},
213+
"ruleId": "package-comments"
214+
}
215+
],
216+
"tool": {
217+
"driver": {
218+
"informationUri": "https://github.com/mgechev/revive",
219+
"name": "revive",
220+
"rules": null
221+
}
222+
}
223+
}
224+
],
225+
"version": "2.1.0"
226+
}

0 commit comments

Comments
 (0)