From 7b367298801cd6ada6eb7977a4ae41ea7219d5f6 Mon Sep 17 00:00:00 2001 From: TJ Miller Date: Tue, 14 Mar 2023 23:31:31 -0700 Subject: [PATCH] Fix linter errors --- pkg/yqlib/doc/operators/divide.md | 2 +- pkg/yqlib/operator_divide.go | 10 ++-------- pkg/yqlib/operator_divide_test.go | 2 +- pkg/yqlib/operator_modulo.go | 10 ++-------- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/pkg/yqlib/doc/operators/divide.md b/pkg/yqlib/doc/operators/divide.md index 22a917a4..34242728 100644 --- a/pkg/yqlib/doc/operators/divide.md +++ b/pkg/yqlib/doc/operators/divide.md @@ -19,7 +19,7 @@ c: ``` ## Number division -The result during divison is calculated as a float +The result during division is calculated as a float Given a sample.yml file of: ```yaml diff --git a/pkg/yqlib/operator_divide.go b/pkg/yqlib/operator_divide.go index 83442afc..c3d5eb23 100644 --- a/pkg/yqlib/operator_divide.go +++ b/pkg/yqlib/operator_divide.go @@ -8,12 +8,6 @@ import ( yaml "gopkg.in/yaml.v3" ) -func createDivideOp(lhs *ExpressionNode, rhs *ExpressionNode) *ExpressionNode { - return &ExpressionNode{Operation: &Operation{OperationType: divideOpType}, - LHS: lhs, - RHS: rhs} -} - func divideOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) { log.Debugf("Divide operator") @@ -33,7 +27,7 @@ func divide(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *Cand target := &yaml.Node{} if lhsNode.Kind == yaml.ScalarNode && rhs.Node.Kind == yaml.ScalarNode { - if err := divideScalars(context, target, lhsNode, rhs.Node); err != nil { + if err := divideScalars(target, lhsNode, rhs.Node); err != nil { return nil, err } } else { @@ -43,7 +37,7 @@ func divide(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *Cand return lhs.CreateReplacement(target), nil } -func divideScalars(context Context, target *yaml.Node, lhs *yaml.Node, rhs *yaml.Node) error { +func divideScalars(target *yaml.Node, lhs *yaml.Node, rhs *yaml.Node) error { lhsTag := lhs.Tag rhsTag := guessTagFromCustomType(rhs) lhsIsCustom := false diff --git a/pkg/yqlib/operator_divide_test.go b/pkg/yqlib/operator_divide_test.go index bbdc1339..fc7297a3 100644 --- a/pkg/yqlib/operator_divide_test.go +++ b/pkg/yqlib/operator_divide_test.go @@ -32,7 +32,7 @@ var divideOperatorScenarios = []expressionScenario{ }, { description: "Number division", - subdescription: "The result during divison is calculated as a float", + subdescription: "The result during division is calculated as a float", document: `{a: 12, b: 2.5}`, expression: `.a = .a / .b`, expected: []string{ diff --git a/pkg/yqlib/operator_modulo.go b/pkg/yqlib/operator_modulo.go index 287fa129..ecb9b406 100644 --- a/pkg/yqlib/operator_modulo.go +++ b/pkg/yqlib/operator_modulo.go @@ -9,12 +9,6 @@ import ( yaml "gopkg.in/yaml.v3" ) -func createModuloOp(lhs *ExpressionNode, rhs *ExpressionNode) *ExpressionNode { - return &ExpressionNode{Operation: &Operation{OperationType: moduloOpType}, - LHS: lhs, - RHS: rhs} -} - func moduloOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) { log.Debugf("Modulo operator") @@ -34,7 +28,7 @@ func modulo(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *Cand target := &yaml.Node{} if lhsNode.Kind == yaml.ScalarNode && rhs.Node.Kind == yaml.ScalarNode { - if err := moduloScalars(context, target, lhsNode, rhs.Node); err != nil { + if err := moduloScalars(target, lhsNode, rhs.Node); err != nil { return nil, err } } else { @@ -44,7 +38,7 @@ func modulo(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *Cand return lhs.CreateReplacement(target), nil } -func moduloScalars(context Context, target *yaml.Node, lhs *yaml.Node, rhs *yaml.Node) error { +func moduloScalars(target *yaml.Node, lhs *yaml.Node, rhs *yaml.Node) error { lhsTag := lhs.Tag rhsTag := guessTagFromCustomType(rhs) lhsIsCustom := false