Skip to content

Commit

Permalink
fix lint issues reported by golangci-lint
Browse files Browse the repository at this point in the history
Except for some errcheck findings related to viper that I believe are
commonly ignored:

    $ golangci-lint run ./...
    pkg/commands/commands.go:39:17: Error return value of `viper.BindPFlag` is not checked (errcheck)
            viper.BindPFlag("policy", cmd.PersistentFlags().Lookup("policy"))
                           ^
    pkg/commands/commands.go:40:17: Error return value of `viper.BindPFlag` is not checked (errcheck)
            viper.BindPFlag("debug", cmd.PersistentFlags().Lookup("debug"))
                           ^
    pkg/commands/commands.go:41:17: Error return value of `viper.BindPFlag` is not checked (errcheck)
            viper.BindPFlag("trace", cmd.PersistentFlags().Lookup("trace"))
                           ^
    pkg/commands/commands.go:49:20: Error return value of `viper.ReadInConfig` is not checked (errcheck)
            viper.ReadInConfig()
                          ^
Signed-off-by: Stephan Renatus <[email protected]>
  • Loading branch information
srenatus committed Aug 1, 2019
1 parent 30adbb2 commit ff9f736
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 0 additions & 4 deletions pkg/commands/test/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ type jsonOutputManager struct {
data []jsonCheckResult
}

func newDefaultJSONOutputManager() *jsonOutputManager {
return newJSONOutputManager(log.New(os.Stdout, "", 0))
}

func newJSONOutputManager(l *log.Logger) *jsonOutputManager {
return &jsonOutputManager{
logger: l,
Expand Down
3 changes: 3 additions & 0 deletions pkg/commands/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ func buildCompiler(path string) (*ast.Compiler, error) {
var dirPath string
if info.IsDir() {
files, err = ioutil.ReadDir(path)
if err != nil {
return nil, err
}
dirPath = path
} else {
files = []os.FileInfo{info}
Expand Down
5 changes: 4 additions & 1 deletion pkg/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ type Policy struct {
// DownloadPolicy downloads the given policies
func DownloadPolicy(ctx context.Context, policies []Policy) {
policyDir := filepath.Join(".", viper.GetString("policy"))
os.MkdirAll(policyDir, os.ModePerm)
err := os.MkdirAll(policyDir, os.ModePerm)
if err != nil {
log.G(ctx).Warnf("Error creating policy directory %q: %v\n", policyDir, err)
}

cli, err := auth.NewClient()
if err != nil {
Expand Down

0 comments on commit ff9f736

Please sign in to comment.