@@ -36,13 +36,13 @@ module CC::Engine::Analyzers
36
36
"path" => "foo.go" ,
37
37
"lines" => { "begin" => 6 , "end" => 6 } ,
38
38
} )
39
- expect ( json [ "remediation_points" ] ) . to eq ( 820_000 )
39
+ expect ( json [ "remediation_points" ] ) . to eq ( 540_000 )
40
40
expect ( json [ "other_locations" ] ) . to eq ( [
41
41
{ "path" => "foo.go" , "lines" => { "begin" => 7 , "end" => 7 } } ,
42
42
] )
43
43
expect ( json [ "content" ] [ "body" ] ) . to match ( /This issue has a mass of 16/ )
44
44
expect ( json [ "fingerprint" ] ) . to eq ( "484ee5799eb0e6c933751cfa85ba33c3" )
45
- expect ( json [ "severity" ] ) . to eq ( CC ::Engine ::Analyzers ::Base ::MAJOR )
45
+ expect ( json [ "severity" ] ) . to eq ( CC ::Engine ::Analyzers ::Base ::MINOR )
46
46
end
47
47
48
48
it "prints an issue for similar code" do
@@ -82,7 +82,7 @@ module CC::Engine::Analyzers
82
82
"path" => "foo.go" ,
83
83
"lines" => { "begin" => 5 , "end" => 7 } ,
84
84
} )
85
- expect ( json [ "remediation_points" ] ) . to eq ( 1_540_000 )
85
+ expect ( json [ "remediation_points" ] ) . to eq ( 1_260_000 )
86
86
expect ( json [ "other_locations" ] ) . to eq ( [
87
87
{ "path" => "foo.go" , "lines" => { "begin" => 9 , "end" => 11 } } ,
88
88
{ "path" => "foo.go" , "lines" => { "begin" => 13 , "end" => 15 } } ,
@@ -127,17 +127,70 @@ module CC::Engine::Analyzers
127
127
expect ( issues ) . to be_empty
128
128
end
129
129
130
+ it "does not flag entire file as issue" do
131
+ create_source_file ( "foo.go" , File . read ( fixture_path ( "issue_6609_1.go" ) ) )
132
+ create_source_file ( "bar.go" , File . read ( fixture_path ( "issue_6609_2.go" ) ) )
133
+ issues = run_engine ( engine_conf ) . strip . split ( "\0 " )
134
+ issues . map! { |issue | JSON . parse issue }
135
+ invalid_issues = issues . find_all { |issue | issue [ "location" ] [ "lines" ] [ "begin" ] == 1 }
136
+ expect ( invalid_issues ) . to be_empty , invalid_issues . map { |issue | issue [ "location" ] } . join ( "\n " )
137
+ end
138
+
130
139
it "does not flag duplicate comments" do
131
140
create_source_file ( "foo.go" , <<-EOGO )
141
+ // This is a comment.
142
+ // This is a comment.
143
+ // This is a comment.
144
+ // This is also a comment.
145
+ // This is also a comment.
146
+
132
147
package main
133
148
149
+ // import "fmt"
150
+
151
+ func main() {
152
+ fmt.Println("This is a duplicate!")
153
+ }
154
+
155
+ /* This is a multiline comment */
156
+ /* This is a multiline comment */
157
+ /* This is a also multiline comment */
158
+ /* This is a also multiline comment */
159
+
160
+ // func add(x int, y int) int {
161
+ // return x + y
162
+ // }
163
+
164
+ // func add(x int, y int) int {
165
+ // return x + y
166
+ // }
167
+
168
+ // func add(x int, y int) int {
169
+ // return x + y
170
+ // }
171
+
172
+ // func add(x int, y int) int {
173
+ // return x + y
174
+ // }
175
+ EOGO
176
+
177
+ create_source_file ( "bar.go" , <<-EOGO )
134
178
// This is a comment.
135
179
// This is a comment.
136
180
// This is a comment.
137
181
// This is also a comment.
138
182
// This is also a comment.
139
183
184
+ package main
185
+
186
+ // import "fmt"
187
+
140
188
func main() {
189
+ // This is a comment.
190
+ // This is a comment.
191
+ // This is a comment.
192
+ // This is also a comment.
193
+ // This is also a comment.
141
194
}
142
195
143
196
/* This is a multiline comment */
@@ -178,7 +231,7 @@ def engine_conf
178
231
} ,
179
232
'languages' => {
180
233
'go' => {
181
- 'mass_threshold' => 3 ,
234
+ 'mass_threshold' => 10 ,
182
235
} ,
183
236
} ,
184
237
} ,
0 commit comments