Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
teejaded committed Mar 15, 2023
1 parent b499322 commit 7b36729
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pkg/yqlib/doc/operators/divide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions pkg/yqlib/operator_divide.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/yqlib/operator_divide_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
10 changes: 2 additions & 8 deletions pkg/yqlib/operator_modulo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 7b36729

Please sign in to comment.