-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add default case when no arguments provided to a rule
- Loading branch information
1 parent
0e8acea
commit 2b4cf05
Showing
24 changed files
with
571 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package fixtures | ||
|
||
func foo(a, b, c, d, e, f, g, h int) { | ||
} | ||
|
||
func bar(a, b, c, d, e, f, g, h, i int64) { // MATCH /maximum number of arguments per function exceeded; max 8 but got 9/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package fixtures | ||
|
||
const Ω = "Omega" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package pkg | ||
|
||
func l() { // MATCH /function l has cognitive complexity 8 (> max enabled 7)/ | ||
for i := 1; i <= max; i++ { | ||
for j := 2; j < i; j++ { | ||
if (i%j == 0) || (i%j == 1) { | ||
continue | ||
} | ||
total += i | ||
} | ||
} | ||
return total && max | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package foo | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
) | ||
|
||
func x(_ AllowedBeforePtrStruct, ctx context.Context) { // MATCH /context.Context should be the first parameter of a function/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package pkg | ||
|
||
import "log" | ||
|
||
func f(x int) bool { // MATCH /function f has cyclomatic complexity 11 (> max enabled 10)/ | ||
if x > 0 && true || false { | ||
return true | ||
} else { | ||
log.Printf("non-positive x: %d", x) | ||
} | ||
switch x { | ||
case 1: | ||
case 2: | ||
case 3: | ||
case 4: | ||
default: | ||
} | ||
return true || true && true | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package fixtures | ||
|
||
import ( | ||
. "context" // MATCH /should not use dot imports/ | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package fixtures | ||
|
||
func compliantFunc(a, b int, c string) {} | ||
|
||
func nonCompliantFunc1(a int, b int, c string) {} | ||
func nonCompliantFunc2(a int, b, c int) {} | ||
|
||
type myStruct struct{} | ||
|
||
func (m myStruct) compliantMethod(a, b int, c string) {} | ||
|
||
func (m myStruct) nonCompliantMethod1(a int, b int, c string) {} | ||
func (m myStruct) nonCompliantMethod2(a int, b, c int) {} | ||
|
||
func variadicFunction(a int, b ...int) {} | ||
|
||
func singleArgFunction(a int) {} | ||
|
||
func multiTypeArgs(a int, b string, c float64) {} | ||
|
||
func mixedCompliance(a, b int, c int, d string) {} |
Oops, something went wrong.