File tree Expand file tree Collapse file tree 5 files changed +38
-4
lines changed
testdata/ignoreSigs_config Expand file tree Collapse file tree 5 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,5 @@ require (
66 github.com/spf13/viper v1.7.1
77 github.com/stretchr/testify v1.6.1
88 golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d
9+ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
910)
Original file line number Diff line number Diff line change 1+ ignoreSigs :
2+ - json.Marshal(
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "encoding/json"
5+ )
6+
7+ func main () {
8+ do ()
9+ }
10+
11+ func do () error {
12+ _ , err := json .Marshal (struct {}{})
13+ if err != nil {
14+ return err
15+ }
16+
17+ return nil
18+ }
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ type WrapcheckConfig struct {
3838 // Note: Setting this value will intentionally override the default ignored
3939 // sigs. To achieve the same behaviour as default, you should add the default
4040 // list to your config.
41- IgnoreSigs []string `mapstructure:"ignoreSigs"`
41+ IgnoreSigs []string `mapstructure:"ignoreSigs" yaml:"ignoreSigs" `
4242}
4343
4444func NewDefaultConfig () WrapcheckConfig {
Original file line number Diff line number Diff line change @@ -2,12 +2,14 @@ package wrapcheck
22
33import (
44 "io/ioutil"
5+ "os"
56 "path"
67 "path/filepath"
78 "testing"
89
910 "github.com/stretchr/testify/assert"
1011 "golang.org/x/tools/go/analysis/analysistest"
12+ "gopkg.in/yaml.v3"
1113)
1214
1315func TestAnalyzer (t * testing.T ) {
@@ -24,10 +26,21 @@ func TestAnalyzer(t *testing.T) {
2426 t .Fatalf ("cannot run on non-directory: %s" , f .Name ())
2527 }
2628
27- p , err := filepath .Abs (path .Join ("./testdata" , f .Name ()))
29+ dirPath , err := filepath .Abs (path .Join ("./testdata" , f .Name ()))
2830 assert .NoError (t , err )
29- analysistest .Run (t , p , NewAnalyzer (NewDefaultConfig ()))
31+
32+ configPath := path .Join (dirPath , ".wrapcheck.yaml" )
33+ if _ , err := os .Stat (configPath ); os .IsNotExist (err ) {
34+ analysistest .Run (t , dirPath , NewAnalyzer (NewDefaultConfig ()))
35+ } else {
36+ configFile , err := os .ReadFile (configPath )
37+ assert .NoError (t , err )
38+
39+ var config WrapcheckConfig
40+ assert .NoError (t , yaml .Unmarshal (configFile , & config ))
41+
42+ analysistest .Run (t , dirPath , NewAnalyzer (config ))
43+ }
3044 })
3145 }
32-
3346}
You can’t perform that action at this time.
0 commit comments