enable revive linter

This commit is contained in:
Matthieu MOREL 2021-12-20 08:00:42 +01:00 committed by GitHub
parent d8abcce633
commit ca972aaf60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 39 additions and 27 deletions

View File

@ -16,6 +16,12 @@ 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 ./...

View File

@ -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"

View File

@ -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 {

View File

@ -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
}

View File

@ -220,7 +220,7 @@ 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]
@ -235,7 +235,6 @@ func explodeNode(node *yaml.Node, context Context) error {
}
}
return nil
}
default:
return nil
}

View File

@ -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()

View File

@ -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 {

View File

@ -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)
}

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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