mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-11 01:09:54 +00:00
enable revive linter
This commit is contained in:
parent
d8abcce633
commit
ca972aaf60
8
.github/workflows/go.yml
vendored
8
.github/workflows/go.yml
vendored
@ -15,7 +15,13 @@ jobs:
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
|
||||
- name: Setup golangci-lint
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: latest
|
||||
args: --verbose
|
||||
|
||||
- name: Get dependencies
|
||||
run: |
|
||||
go get -v -t -d ./...
|
||||
|
||||
@ -8,9 +8,16 @@ linters:
|
||||
- goimports
|
||||
- gosec
|
||||
- misspell
|
||||
- revive
|
||||
issues:
|
||||
exclude-rules:
|
||||
- linters:
|
||||
- gosec
|
||||
text: "Implicit memory aliasing in for loop."
|
||||
path: _test\.go
|
||||
- linters:
|
||||
- revive
|
||||
text: "unexported-return"
|
||||
- linters:
|
||||
- revive
|
||||
text: "var-naming"
|
||||
|
||||
@ -50,7 +50,7 @@ func (e *allAtOnceEvaluator) EvaluateFiles(expression string, filenames []string
|
||||
fileIndex := 0
|
||||
firstFileLeadingContent := ""
|
||||
|
||||
var allDocuments *list.List = list.New()
|
||||
var allDocuments = list.New()
|
||||
for _, filename := range filenames {
|
||||
reader, leadingContent, err := readStream(filename, fileIndex == 0 && leadingContentPreProcessing)
|
||||
if err != nil {
|
||||
|
||||
@ -56,7 +56,7 @@ func (n *CandidateNode) AsList() *list.List {
|
||||
}
|
||||
|
||||
func (n *CandidateNode) CreateChildInMap(key *yaml.Node, node *yaml.Node) *CandidateNode {
|
||||
var value interface{} = nil
|
||||
var value interface{}
|
||||
if key != nil {
|
||||
value = key.Value
|
||||
}
|
||||
|
||||
@ -220,22 +220,21 @@ func explodeNode(node *yaml.Node, context Context) error {
|
||||
if hasAlias {
|
||||
// this is a slow op, which is why we want to check before running it.
|
||||
return reconstructAliasedMap(node, context)
|
||||
} else {
|
||||
// this map has no aliases, but it's kids might
|
||||
for index := 0; index < len(node.Content); index = index + 2 {
|
||||
keyNode := node.Content[index]
|
||||
valueNode := node.Content[index+1]
|
||||
err := explodeNode(keyNode, context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = explodeNode(valueNode, context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// this map has no aliases, but it's kids might
|
||||
for index := 0; index < len(node.Content); index = index + 2 {
|
||||
keyNode := node.Content[index]
|
||||
valueNode := node.Content[index+1]
|
||||
err := explodeNode(keyNode, context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = explodeNode(valueNode, context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ func collectObjectOperator(d *dataTreeNavigator, originalContext Context, expres
|
||||
return context.SingleChildContext(candidate), nil
|
||||
}
|
||||
first := context.MatchingNodes.Front().Value.(*CandidateNode)
|
||||
var rotated []*list.List = make([]*list.List, len(first.Node.Content))
|
||||
var rotated = make([]*list.List, len(first.Node.Content))
|
||||
|
||||
for i := 0; i < len(first.Node.Content); i++ {
|
||||
rotated[i] = list.New()
|
||||
|
||||
@ -14,7 +14,7 @@ func createMapOperator(d *dataTreeNavigator, context Context, expressionNode *Ex
|
||||
|
||||
var path []interface{}
|
||||
|
||||
var document uint = 0
|
||||
var document uint
|
||||
|
||||
sequences := list.New()
|
||||
|
||||
@ -42,7 +42,7 @@ func createMapOperator(d *dataTreeNavigator, context Context, expressionNode *Ex
|
||||
|
||||
func sequenceFor(d *dataTreeNavigator, context Context, matchingNode *CandidateNode, expressionNode *ExpressionNode) (*CandidateNode, error) {
|
||||
var path []interface{}
|
||||
var document uint = 0
|
||||
var document uint
|
||||
var matches = list.New()
|
||||
|
||||
if matchingNode != nil {
|
||||
|
||||
@ -114,7 +114,7 @@ func mergeObjects(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var pathIndexToStartFrom int = 0
|
||||
var pathIndexToStartFrom int
|
||||
if results.Front() != nil {
|
||||
pathIndexToStartFrom = len(results.Front().Value.(*CandidateNode).Path)
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package yqlib
|
||||
func splitDocumentOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
|
||||
log.Debugf("-- splitDocumentOperator")
|
||||
|
||||
var index uint = 0
|
||||
var index uint
|
||||
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
|
||||
candidate := el.Value.(*CandidateNode)
|
||||
candidate.Document = index
|
||||
|
||||
@ -62,7 +62,7 @@ func substituteStringOperator(d *dataTreeNavigator, context Context, expressionN
|
||||
candidate := el.Value.(*CandidateNode)
|
||||
node := unwrapDoc(candidate.Node)
|
||||
if node.Tag != "!!str" {
|
||||
return Context{}, fmt.Errorf("cannot substitute with %v, can only substitute strings. Hint: Most often you'll want to use '|=' over '=' for this operation.", node.Tag)
|
||||
return Context{}, fmt.Errorf("cannot substitute with %v, can only substitute strings. Hint: Most often you'll want to use '|=' over '=' for this operation", node.Tag)
|
||||
}
|
||||
|
||||
targetNode := substitute(node.Value, regEx, replacementText)
|
||||
|
||||
@ -91,7 +91,7 @@ func testScenario(t *testing.T, s *expressionScenario) {
|
||||
}
|
||||
|
||||
func resultsToString(t *testing.T, results *list.List) []string {
|
||||
var pretty []string = make([]string, 0)
|
||||
var pretty = make([]string, 0)
|
||||
|
||||
for el := results.Front(); el != nil; el = el.Next() {
|
||||
n := el.Value.(*CandidateNode)
|
||||
|
||||
@ -52,7 +52,7 @@ func (s *streamEvaluator) EvaluateNew(expression string, printer Printer, leadin
|
||||
}
|
||||
|
||||
func (s *streamEvaluator) EvaluateFiles(expression string, filenames []string, printer Printer, leadingContentPreProcessing bool) error {
|
||||
var totalProcessDocs uint = 0
|
||||
var totalProcessDocs uint
|
||||
node, err := s.treeCreator.ParseExpression(expression)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -110,7 +110,7 @@ func processReadStream(reader *bufio.Reader) (io.Reader, string, error) {
|
||||
func readDocuments(reader io.Reader, filename string, fileIndex int) (*list.List, error) {
|
||||
decoder := yaml.NewDecoder(reader)
|
||||
inputList := list.New()
|
||||
var currentIndex uint = 0
|
||||
var currentIndex uint
|
||||
|
||||
for {
|
||||
var dataBucket yaml.Node
|
||||
|
||||
Loading…
Reference in New Issue
Block a user