Skip to content

Commit

Permalink
Static-check fixes from @lespea #1657, batch 6/n
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Oct 27, 2024
1 parent fe63d2d commit a5ebdc9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/climain/mlrcli_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func parseCommandLinePassTwo(
options.FileNames = nil
}

if options.DoInPlace && (options.FileNames == nil || len(options.FileNames) == 0) {
if options.DoInPlace && len(options.FileNames) == 0 {
fmt.Fprintf(os.Stderr, "%s: -I option (in-place operation) requires input files.\n", "mlr")
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/dsl/ast_print.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (node *ASTNode) printParexOneLineAux() {

// IsLeaf determines if an AST node is a leaf node.
func (node *ASTNode) IsLeaf() bool {
return node.Children == nil || len(node.Children) == 0
return len(node.Children) == 0
}

// ChildrenAreAllLeaves determines if an AST node's children are all leaf nodes.
Expand Down
2 changes: 1 addition & 1 deletion pkg/dsl/cst/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (root *RootNode) regexProtectPrePass(ast *dsl.AST) {

func (root *RootNode) regexProtectPrePassAux(astNode *dsl.ASTNode) {

if astNode.Children == nil || len(astNode.Children) == 0 {
if len(astNode.Children) == 0 {
return
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/dsl/cst/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func ValidateAST(

// They can do mlr put '': there are simply zero statements.
// But filter '' is an error.
if ast.RootNode.Children == nil || len(ast.RootNode.Children) == 0 {
if len(ast.RootNode.Children) == 0 {
if dslInstanceType == DSLInstanceTypeFilter {
return fmt.Errorf("mlr: filter statement must not be empty")
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/lib/regex.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func regexCompiledSubOrGsub(
breakOnFirst bool,
) string {
matrix := regex.FindAllStringSubmatchIndex(input, -1)
if matrix == nil || len(matrix) == 0 {
if len(matrix) == 0 {
return input
}

Expand Down Expand Up @@ -321,7 +321,7 @@ func RegexCompiledMatchWithMapResults(
ends := make([]int, 0, 10)

matrix := regex.FindAllStringSubmatchIndex(input, -1)
if matrix == nil || len(matrix) == 0 {
if len(matrix) == 0 {
return false, captures, starts, ends
}

Expand Down Expand Up @@ -407,7 +407,7 @@ func RegexCompiledMatchWithCaptures(
regex *regexp.Regexp,
) (bool, []string) {
matrix := regex.FindAllStringSubmatchIndex(input, -1)
if matrix == nil || len(matrix) == 0 {
if len(matrix) == 0 {
// Set all captures to ""
return false, make([]string, 10)
}
Expand Down

0 comments on commit a5ebdc9

Please sign in to comment.