From f04b6d72a3d967ddf3b2bfce42ae01991f84f295 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sun, 27 Oct 2024 11:45:40 -0400 Subject: [PATCH] Static-check fixes from @lespea #1657, batch 2/n --- pkg/bifs/arithmetic.go | 4 ++-- pkg/bifs/cmp.go | 2 +- pkg/bifs/types.go | 6 +++--- pkg/climain/mlrcli_parse.go | 2 +- pkg/dsl/cst/builtin_function_manager.go | 2 +- pkg/dsl/cst/builtin_functions.go | 2 +- pkg/dsl/cst/cond.go | 2 +- pkg/dsl/cst/for.go | 2 +- pkg/dsl/cst/if.go | 2 +- pkg/dsl/cst/while.go | 4 ++-- pkg/lib/util.go | 2 +- pkg/mlrval/mlrval_is.go | 4 ++-- pkg/mlrval/mlrval_new.go | 2 +- pkg/mlrval/mlrval_output.go | 2 +- pkg/terminals/repl/verbs.go | 2 +- pkg/transformers/aaa_chain_transformer.go | 2 +- pkg/transformers/put_or_filter.go | 2 +- 17 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pkg/bifs/arithmetic.go b/pkg/bifs/arithmetic.go index 1edf7cee4a..1ce24544a1 100644 --- a/pkg/bifs/arithmetic.go +++ b/pkg/bifs/arithmetic.go @@ -834,7 +834,7 @@ func min_i_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { // a=F | min=a min=a // a=T | min=b min=b func min_b_bb(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { - if input1.AcquireBoolValue() == false { + if !input1.AcquireBoolValue() { return input1 } else { return input2 @@ -1004,7 +1004,7 @@ func max_i_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { // a=F | max=a max=b // a=T | max=a max=b func max_b_bb(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { - if input2.AcquireBoolValue() == false { + if !input2.AcquireBoolValue() { return input1 } else { return input2 diff --git a/pkg/bifs/cmp.go b/pkg/bifs/cmp.go index b4603d2a87..3be5179900 100644 --- a/pkg/bifs/cmp.go +++ b/pkg/bifs/cmp.go @@ -246,7 +246,7 @@ func eq_b_aa(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { for i := range a { eq := BIF_equals(a[i], b[i]) lib.InternalCodingErrorIf(eq.Type() != mlrval.MT_BOOL) - if eq.AcquireBoolValue() == false { + if !eq.AcquireBoolValue() { return mlrval.FALSE } } diff --git a/pkg/bifs/types.go b/pkg/bifs/types.go index a4eb1f2300..d3e8d61ef9 100644 --- a/pkg/bifs/types.go +++ b/pkg/bifs/types.go @@ -37,7 +37,7 @@ func float_to_int(input1 *mlrval.Mlrval) *mlrval.Mlrval { } func bool_to_int(input1 *mlrval.Mlrval) *mlrval.Mlrval { - if input1.AcquireBoolValue() == true { + if input1.AcquireBoolValue() { return mlrval.FromInt(1) } else { return mlrval.FromInt(0) @@ -92,7 +92,7 @@ func float_to_int_with_base(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { } func bool_to_int_with_base(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { - if input1.AcquireBoolValue() == true { + if input1.AcquireBoolValue() { return mlrval.FromInt(1) } else { return mlrval.FromInt(0) @@ -146,7 +146,7 @@ func int_to_float(input1 *mlrval.Mlrval) *mlrval.Mlrval { } func bool_to_float(input1 *mlrval.Mlrval) *mlrval.Mlrval { - if input1.AcquireBoolValue() == true { + if input1.AcquireBoolValue() { return mlrval.FromFloat(1.0) } else { return mlrval.FromFloat(0.0) diff --git a/pkg/climain/mlrcli_parse.go b/pkg/climain/mlrcli_parse.go index 3641958247..f582cd51ca 100644 --- a/pkg/climain/mlrcli_parse.go +++ b/pkg/climain/mlrcli_parse.go @@ -295,7 +295,7 @@ func parseCommandLinePassTwo( rc := cli.FLAG_TABLE.Parse(args, argc, &argi, options) // Should have been parsed OK in pass one. - lib.InternalCodingErrorIf(rc != true) + lib.InternalCodingErrorIf(!rc) // Make sure we consumed the entire flag sequence as parsed by pass one. lib.InternalCodingErrorIf(argi != argc) } diff --git a/pkg/dsl/cst/builtin_function_manager.go b/pkg/dsl/cst/builtin_function_manager.go index e35ee8b0b4..4a1d83bfab 100644 --- a/pkg/dsl/cst/builtin_function_manager.go +++ b/pkg/dsl/cst/builtin_function_manager.go @@ -2595,7 +2595,7 @@ func (manager *BuiltinFunctionManager) getBuiltinFunctionClasses() []string { classesList := make([]string, 0) for _, builtinFunctionInfo := range *manager.lookupTable { class := string(builtinFunctionInfo.class) - if classesSeen[class] == false { + if !classesSeen[class] { classesList = append(classesList, class) classesSeen[class] = true } diff --git a/pkg/dsl/cst/builtin_functions.go b/pkg/dsl/cst/builtin_functions.go index 3b9fa12f3c..e3558d1cdf 100644 --- a/pkg/dsl/cst/builtin_functions.go +++ b/pkg/dsl/cst/builtin_functions.go @@ -945,7 +945,7 @@ func (node *StandardTernaryOperatorNode) Evaluate( } // Short-circuit: defer evaluation unless needed - if boolValue == true { + if boolValue { return node.b.Evaluate(state) } else { return node.c.Evaluate(state) diff --git a/pkg/dsl/cst/cond.go b/pkg/dsl/cst/cond.go index 53532d9250..52dd30dead 100644 --- a/pkg/dsl/cst/cond.go +++ b/pkg/dsl/cst/cond.go @@ -66,7 +66,7 @@ func (node *CondBlockNode) Execute( ) } - if boolValue == true { + if boolValue { blockExitPayload, err := node.statementBlockNode.Execute(state) if err != nil { return nil, err diff --git a/pkg/dsl/cst/for.go b/pkg/dsl/cst/for.go index 204505aba4..074f3b500d 100644 --- a/pkg/dsl/cst/for.go +++ b/pkg/dsl/cst/for.go @@ -902,7 +902,7 @@ func (node *TripleForLoopNode) Execute(state *runtime.State) (*BlockExitPayload, dsl.TokenToLocationInfo(node.continuationExpressionToken), ) } - if boolValue == false { + if !boolValue { break } } diff --git a/pkg/dsl/cst/if.go b/pkg/dsl/cst/if.go index 3396ddd193..b85f681190 100644 --- a/pkg/dsl/cst/if.go +++ b/pkg/dsl/cst/if.go @@ -134,7 +134,7 @@ func (node *IfChainNode) Execute(state *runtime.State) (*BlockExitPayload, error dsl.TokenToLocationInfo(ifItem.conditionToken), ) } - if boolValue == true { + if boolValue { blockExitPayload, err := ifItem.statementBlockNode.Execute(state) if err != nil { return nil, err diff --git a/pkg/dsl/cst/while.go b/pkg/dsl/cst/while.go index 2e2fd5f125..ccdde00524 100644 --- a/pkg/dsl/cst/while.go +++ b/pkg/dsl/cst/while.go @@ -64,7 +64,7 @@ func (node *WhileLoopNode) Execute(state *runtime.State) (*BlockExitPayload, err dsl.TokenToLocationInfo(node.conditionToken), ) } - if boolValue != true { + if !boolValue { break } blockExitPayload, err := node.statementBlockNode.Execute(state) @@ -161,7 +161,7 @@ func (node *DoWhileLoopNode) Execute(state *runtime.State) (*BlockExitPayload, e dsl.TokenToLocationInfo(node.conditionToken), ) } - if boolValue == false { + if !boolValue { break } } diff --git a/pkg/lib/util.go b/pkg/lib/util.go index 37e90ce469..f37194ccb4 100644 --- a/pkg/lib/util.go +++ b/pkg/lib/util.go @@ -14,7 +14,7 @@ func BooleanXOR(a, b bool) bool { } func BoolToInt(b bool) int64 { - if b == false { + if !b { return 0 } else { return 1 diff --git a/pkg/mlrval/mlrval_is.go b/pkg/mlrval/mlrval_is.go index 7f438871f5..0cdfdadded 100644 --- a/pkg/mlrval/mlrval_is.go +++ b/pkg/mlrval/mlrval_is.go @@ -112,10 +112,10 @@ func (mv *Mlrval) IsBool() bool { } func (mv *Mlrval) IsTrue() bool { - return mv.Type() == MT_BOOL && mv.intf.(bool) == true + return mv.Type() == MT_BOOL && mv.intf.(bool) } func (mv *Mlrval) IsFalse() bool { - return mv.Type() == MT_BOOL && mv.intf.(bool) == false + return mv.Type() == MT_BOOL && !mv.intf.(bool) } func (mv *Mlrval) IsArray() bool { diff --git a/pkg/mlrval/mlrval_new.go b/pkg/mlrval/mlrval_new.go index bcad5590b8..9d63989b12 100644 --- a/pkg/mlrval/mlrval_new.go +++ b/pkg/mlrval/mlrval_new.go @@ -289,7 +289,7 @@ func FromPrevalidatedFloatString(input string, floatval float64) *Mlrval { } func FromBool(input bool) *Mlrval { - if input == true { + if input { return TRUE } else { return FALSE diff --git a/pkg/mlrval/mlrval_output.go b/pkg/mlrval/mlrval_output.go index d864806b3c..a727609986 100644 --- a/pkg/mlrval/mlrval_output.go +++ b/pkg/mlrval/mlrval_output.go @@ -87,7 +87,7 @@ func (mv *Mlrval) setPrintRep() { mv.printrep = strconv.FormatFloat(mv.intf.(float64), 'f', -1, 64) case MT_BOOL: - if mv.intf.(bool) == true { + if mv.intf.(bool) { mv.printrep = "true" } else { mv.printrep = "false" diff --git a/pkg/terminals/repl/verbs.go b/pkg/terminals/repl/verbs.go index bbb1a36b23..3b901b78b9 100644 --- a/pkg/terminals/repl/verbs.go +++ b/pkg/terminals/repl/verbs.go @@ -566,7 +566,7 @@ func skipOrProcessRecord( repl.runtimeState.Update(recordAndContext.Record, &recordAndContext.Context) // End-of-stream marker - if recordAndContext.EndOfStream == true { + if recordAndContext.EndOfStream { fmt.Println("End of record stream") repl.readerChannel = nil repl.errorChannel = nil diff --git a/pkg/transformers/aaa_chain_transformer.go b/pkg/transformers/aaa_chain_transformer.go index 6b67b03b75..a4137b7633 100644 --- a/pkg/transformers/aaa_chain_transformer.go +++ b/pkg/transformers/aaa_chain_transformer.go @@ -265,7 +265,7 @@ func runSingleTransformerBatch( // the output channel without involving the record-transformer, since // there is no record to be transformed. - if inputRecordAndContext.EndOfStream == true || inputRecordAndContext.Record != nil { + if inputRecordAndContext.EndOfStream || inputRecordAndContext.Record != nil { recordTransformer.Transform( inputRecordAndContext, outputRecordsAndContexts, diff --git a/pkg/transformers/put_or_filter.go b/pkg/transformers/put_or_filter.go index 9749033452..648595ce24 100644 --- a/pkg/transformers/put_or_filter.go +++ b/pkg/transformers/put_or_filter.go @@ -542,7 +542,7 @@ func (tr *TransformerPut) Transform( // If there were no input records then we never executed the // begin-blocks. Do so now. - if tr.executedBeginBlocks == false { + if !tr.executedBeginBlocks { err := tr.cstRootNode.ExecuteBeginBlocks(tr.runtimeState) if err != nil { fmt.Fprintln(os.Stderr, err)