-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #317
- Loading branch information
Showing
7 changed files
with
58 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM golang:1.16-alpine AS build | ||
|
||
COPY . /root | ||
|
||
RUN /root/test.bash |
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,2 @@ | ||
/root/target.go:11:2: uncheckedTypeAssert: avoid unchecked type assertions as they can panic (rules.go:27) | ||
/root/target.go:13:19: badCond: statement always true (diag.go:14) |
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 @@ | ||
module issue317 | ||
|
||
go 1.17 |
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,15 @@ | ||
//go:build ignore | ||
// +build ignore | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/quasilyte/go-ruleguard/dsl" | ||
corerules "github.com/quasilyte/go-ruleguard/rules" | ||
uber "github.com/quasilyte/uber-rules" | ||
) | ||
|
||
func init() { | ||
dsl.ImportRules("", corerules.Bundle) | ||
dsl.ImportRules("", uber.Bundle) | ||
} |
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,14 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func main() { | ||
var k interface{} | ||
|
||
msg := k.(string) // expects warning | ||
|
||
fmt.Println(msg, strings.Count("foo", "bar") >= 0) | ||
} |
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,18 @@ | ||
set -e | ||
|
||
apk update && apk add git | ||
|
||
cd /root | ||
|
||
GO111MODULE=on go get -v github.com/quasilyte/go-ruleguard/cmd/ruleguard@master | ||
go get -v github.com/quasilyte/go-ruleguard/dsl | ||
go get -v github.com/quasilyte/uber-rules | ||
go get -v github.com/quasilyte/go-ruleguard/rules | ||
# Try running with different rules file order. | ||
|
||
export CGO_ENABLED=0 | ||
|
||
ruleguard -rules rules.go . > actual.txt 2>&1 || true | ||
diff -u actual.txt /root/expected.txt | ||
|
||
echo SUCCESS |