Skip to content

Commit

Permalink
Organize golangci-lint linters (open-policy-agent#564)
Browse files Browse the repository at this point in the history
* Update documentation for file extensions

Signed-off-by: John Reese <[email protected]>

* Organize golangci-lint linters

Signed-off-by: John Reese <[email protected]>
  • Loading branch information
jpreese authored May 11, 2021
1 parent a901976 commit 0f795bf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
26 changes: 16 additions & 10 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@ linter-settings:
linters:
disable-all: true
enable:
- deadcode
- errcheck
- govet
- ineffassign
- golint
- goconst
- gofmt
- goimports
- unused
- varcheck
- deadcode
- golint
- gosec
- gosimple
- govet
- ineffassign
- makezero
- misspell
- typecheck
- structcheck
- nilerr
- predeclared
- staticcheck
- gosimple
- gosec
- structcheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- wastedassign
2 changes: 1 addition & 1 deletion plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (p *Plugin) Exec(ctx context.Context, args []string) error {
// Plugin configurations reference the CONFTEST_PLUGIN_DIR
// environment to be able to call the plugin.
os.Setenv("CONFTEST_PLUGIN_DIR", p.Directory())
expandedCommand := os.ExpandEnv(string(p.Command))
expandedCommand := os.ExpandEnv(p.Command)

var command string
var arguments []string
Expand Down
6 changes: 3 additions & 3 deletions policy/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (e *Engine) check(ctx context.Context, path string, config interface{}, nam
// is queried, so the severity prefix must be removed.
exceptionQuery := fmt.Sprintf("data.%s.exception[_][_] == %q", namespace, removeRulePrefix(rule))

exceptionQueryResult, err := e.query(ctx, config, exceptionQuery, namespace)
exceptionQueryResult, err := e.query(ctx, config, exceptionQuery)
if err != nil {
return output.CheckResult{}, fmt.Errorf("query exception: %w", err)
}
Expand All @@ -291,7 +291,7 @@ func (e *Engine) check(ctx context.Context, path string, config interface{}, nam
}

ruleQuery := fmt.Sprintf("data.%s.%s", namespace, rule)
ruleQueryResult, err := e.query(ctx, config, ruleQuery, namespace)
ruleQueryResult, err := e.query(ctx, config, ruleQuery)
if err != nil {
return output.CheckResult{}, fmt.Errorf("query rule: %w", err)
}
Expand Down Expand Up @@ -345,7 +345,7 @@ func (e *Engine) check(ctx context.Context, path string, config interface{}, nam
// Example queries could include:
// data.main.deny to query the deny rule in the main namespace
// data.main.warn to query the warn rule in the main namespace
func (e *Engine) query(ctx context.Context, input interface{}, query string, namespace string) (output.QueryResult, error) {
func (e *Engine) query(ctx context.Context, input interface{}, query string) (output.QueryResult, error) {
options := []func(r *rego.Rego){
rego.Input(input),
rego.Query(query),
Expand Down

0 comments on commit 0f795bf

Please sign in to comment.