Static-check fixes from @lespea #1657, batch 6/n (#1708)

* Static-check fixes from @lespea #1657, batch 2/n

* Static-check fixes from @lespea #1657, batch 3/n

* Static-check fixes from @lespea #1657, batch 4/n

* Static-check fixes from @lespea #1657, batch 5/n

* Static-check fixes from @lespea #1657, batch 6/n
This commit is contained in:
John Kerl 2024-10-27 12:06:17 -04:00 committed by GitHub
parent 02bd5344b9
commit b4ff26a7d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 7 additions and 7 deletions

View file

@ -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)
}

View file

@ -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.

View file

@ -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
}

View file

@ -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")
}

View file

@ -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
}
@ -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
}
@ -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)
}