mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-10 16:55:40 +00:00
Fix linter errors
This commit is contained in:
parent
b499322914
commit
7b36729880
@ -19,7 +19,7 @@ c:
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Number division
|
## 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:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
@ -8,12 +8,6 @@ import (
|
|||||||
yaml "gopkg.in/yaml.v3"
|
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) {
|
func divideOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
|
||||||
log.Debugf("Divide operator")
|
log.Debugf("Divide operator")
|
||||||
|
|
||||||
@ -33,7 +27,7 @@ func divide(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *Cand
|
|||||||
target := &yaml.Node{}
|
target := &yaml.Node{}
|
||||||
|
|
||||||
if lhsNode.Kind == yaml.ScalarNode && rhs.Node.Kind == yaml.ScalarNode {
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -43,7 +37,7 @@ func divide(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *Cand
|
|||||||
return lhs.CreateReplacement(target), nil
|
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
|
lhsTag := lhs.Tag
|
||||||
rhsTag := guessTagFromCustomType(rhs)
|
rhsTag := guessTagFromCustomType(rhs)
|
||||||
lhsIsCustom := false
|
lhsIsCustom := false
|
||||||
|
|||||||
@ -32,7 +32,7 @@ var divideOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Number division",
|
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}`,
|
document: `{a: 12, b: 2.5}`,
|
||||||
expression: `.a = .a / .b`,
|
expression: `.a = .a / .b`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
|
|||||||
@ -9,12 +9,6 @@ import (
|
|||||||
yaml "gopkg.in/yaml.v3"
|
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) {
|
func moduloOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
|
||||||
log.Debugf("Modulo operator")
|
log.Debugf("Modulo operator")
|
||||||
|
|
||||||
@ -34,7 +28,7 @@ func modulo(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *Cand
|
|||||||
target := &yaml.Node{}
|
target := &yaml.Node{}
|
||||||
|
|
||||||
if lhsNode.Kind == yaml.ScalarNode && rhs.Node.Kind == yaml.ScalarNode {
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -44,7 +38,7 @@ func modulo(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *Cand
|
|||||||
return lhs.CreateReplacement(target), nil
|
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
|
lhsTag := lhs.Tag
|
||||||
rhsTag := guessTagFromCustomType(rhs)
|
rhsTag := guessTagFromCustomType(rhs)
|
||||||
lhsIsCustom := false
|
lhsIsCustom := false
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user