Updated to latest golint

This commit is contained in:
Mike Farah 2024-01-11 13:17:34 +11:00
parent 8af3e46fcb
commit 010750daf6
60 changed files with 95 additions and 94 deletions

View File

@ -20,12 +20,15 @@ linters:
- unparam
linters-settings:
depguard:
list-type: blacklist
include-go-root: true
packages:
- io/ioutil
packages-with-error-message:
- io/ioutil: "The 'io/ioutil' package is deprecated. Use corresponding 'os' or 'io' functions instead."
rules:
prevent_unmaintained_packages:
list-mode: lax
files:
- $all
- "!$test"
deny:
- pkg: io/ioutil
desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil"
issues:
exclude-rules:
- linters:

View File

@ -272,7 +272,7 @@ func documentCSVRoundTripScenario(w *bufio.Writer, s formatScenario, formatType
)
}
func documentCSVScenario(t *testing.T, w *bufio.Writer, i interface{}) {
func documentCSVScenario(_ *testing.T, w *bufio.Writer, i interface{}) {
s := i.(formatScenario)
if s.skipDoc {
return

View File

@ -18,11 +18,11 @@ func (e *base64Encoder) CanHandleAliases() bool {
return false
}
func (e *base64Encoder) PrintDocumentSeparator(writer io.Writer) error {
func (e *base64Encoder) PrintDocumentSeparator(_ io.Writer) error {
return nil
}
func (e *base64Encoder) PrintLeadingContent(writer io.Writer, content string) error {
func (e *base64Encoder) PrintLeadingContent(_ io.Writer, _ string) error {
return nil
}

View File

@ -18,11 +18,11 @@ func (e *csvEncoder) CanHandleAliases() bool {
return false
}
func (e *csvEncoder) PrintDocumentSeparator(writer io.Writer) error {
func (e *csvEncoder) PrintDocumentSeparator(_ io.Writer) error {
return nil
}
func (e *csvEncoder) PrintLeadingContent(writer io.Writer, content string) error {
func (e *csvEncoder) PrintLeadingContent(_ io.Writer, _ string) error {
return nil
}

View File

@ -29,11 +29,11 @@ func (je *jsonEncoder) CanHandleAliases() bool {
return false
}
func (je *jsonEncoder) PrintDocumentSeparator(writer io.Writer) error {
func (je *jsonEncoder) PrintDocumentSeparator(_ io.Writer) error {
return nil
}
func (je *jsonEncoder) PrintLeadingContent(writer io.Writer, content string) error {
func (je *jsonEncoder) PrintLeadingContent(_ io.Writer, _ string) error {
return nil
}

View File

@ -72,11 +72,11 @@ func NewLuaEncoder(prefs LuaPreferences) Encoder {
return &luaEncoder{unescape.Replace(prefs.DocPrefix), unescape.Replace(prefs.DocSuffix), 0, "\t", prefs.UnquotedKeys, prefs.Globals, escape}
}
func (le *luaEncoder) PrintDocumentSeparator(writer io.Writer) error {
func (le *luaEncoder) PrintDocumentSeparator(_ io.Writer) error {
return nil
}
func (le *luaEncoder) PrintLeadingContent(writer io.Writer, content string) error {
func (le *luaEncoder) PrintLeadingContent(_ io.Writer, _ string) error {
return nil
}

View File

@ -24,7 +24,7 @@ func (pe *propertiesEncoder) CanHandleAliases() bool {
return false
}
func (pe *propertiesEncoder) PrintDocumentSeparator(writer io.Writer) error {
func (pe *propertiesEncoder) PrintDocumentSeparator(_ io.Writer) error {
return nil
}

View File

@ -21,11 +21,11 @@ func (e *shEncoder) CanHandleAliases() bool {
return false
}
func (e *shEncoder) PrintDocumentSeparator(writer io.Writer) error {
func (e *shEncoder) PrintDocumentSeparator(_ io.Writer) error {
return nil
}
func (e *shEncoder) PrintLeadingContent(writer io.Writer, content string) error {
func (e *shEncoder) PrintLeadingContent(_ io.Writer, _ string) error {
return nil
}

View File

@ -19,11 +19,11 @@ func (te *tomlEncoder) Encode(writer io.Writer, node *CandidateNode) error {
return fmt.Errorf("only scalars (e.g. strings, numbers, booleans) are supported for TOML output at the moment. Please use yaml output format (-oy) until the encoder has been fully implemented")
}
func (te *tomlEncoder) PrintDocumentSeparator(writer io.Writer) error {
func (te *tomlEncoder) PrintDocumentSeparator(_ io.Writer) error {
return nil
}
func (te *tomlEncoder) PrintLeadingContent(writer io.Writer, content string) error {
func (te *tomlEncoder) PrintLeadingContent(_ io.Writer, _ string) error {
return nil
}

View File

@ -17,11 +17,11 @@ func (e *uriEncoder) CanHandleAliases() bool {
return false
}
func (e *uriEncoder) PrintDocumentSeparator(writer io.Writer) error {
func (e *uriEncoder) PrintDocumentSeparator(_ io.Writer) error {
return nil
}
func (e *uriEncoder) PrintLeadingContent(writer io.Writer, content string) error {
func (e *uriEncoder) PrintLeadingContent(_ io.Writer, _ string) error {
return nil
}

View File

@ -30,11 +30,11 @@ func (e *xmlEncoder) CanHandleAliases() bool {
return false
}
func (e *xmlEncoder) PrintDocumentSeparator(writer io.Writer) error {
func (e *xmlEncoder) PrintDocumentSeparator(_ io.Writer) error {
return nil
}
func (e *xmlEncoder) PrintLeadingContent(writer io.Writer, content string) error {
func (e *xmlEncoder) PrintLeadingContent(_ io.Writer, content string) error {
e.leadingContent = content
return nil
}
@ -122,7 +122,7 @@ func (e *xmlEncoder) encodeTopLevelMap(encoder *xml.Encoder, node *CandidateNode
}
}
if key.Value == (e.prefs.ProcInstPrefix + "xml") {
if key.Value == (e.prefs.ProcInstPrefix + "xml") { //nolint
// dont double process these.
} else if strings.HasPrefix(key.Value, e.prefs.ProcInstPrefix) {
name := strings.Replace(key.Value, e.prefs.ProcInstPrefix, "", 1)

View File

@ -51,9 +51,8 @@ func (t *token) toString(detail bool) string {
} else if t.TokenType == traverseArrayCollect {
return ".["
} else {
return "NFI"
}
return "NFI"
}
func unwrap(value string) string {

View File

@ -357,9 +357,8 @@ func (p *Operation) toString() string {
return "SELF"
} else if p.OperationType == valueOpType {
return fmt.Sprintf("%v (%T)", p.Value, p.Value)
} else {
return fmt.Sprintf("%v", p.OperationType.Type)
}
return fmt.Sprintf("%v", p.OperationType.Type)
}
// use for debugging only

View File

@ -277,7 +277,7 @@ func testLuaScenario(t *testing.T, s formatScenario) {
}
}
func documentLuaScenario(t *testing.T, w *bufio.Writer, i interface{}) {
func documentLuaScenario(_ *testing.T, w *bufio.Writer, i interface{}) {
s := i.(formatScenario)
if s.skipDoc {

View File

@ -42,7 +42,7 @@ func addOperator(d *dataTreeNavigator, context Context, expressionNode *Expressi
return crossFunction(d, context.ReadOnlyClone(), expressionNode, add, false)
}
func add(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
func add(_ *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
lhsNode := lhs
if lhsNode.Tag == "!!null" {

View File

@ -19,7 +19,7 @@ func alternativeOperator(d *dataTreeNavigator, context Context, expressionNode *
return crossFunctionWithPrefs(d, context, expressionNode, prefs)
}
func alternativeFunc(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
func alternativeFunc(_ *dataTreeNavigator, _ Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
if lhs == nil {
return rhs, nil
}

View File

@ -48,7 +48,7 @@ func assignAliasOperator(d *dataTreeNavigator, context Context, expressionNode *
return context, nil
}
func getAliasOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func getAliasOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("GetAlias operator!")
var results = list.New()
@ -102,7 +102,7 @@ func assignAnchorOperator(d *dataTreeNavigator, context Context, expressionNode
return context, nil
}
func getAnchorOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func getAnchorOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("GetAnchor operator!")
var results = list.New()

View File

@ -35,7 +35,7 @@ func getOwner(lhs *CandidateNode, rhs *CandidateNode) *CandidateNode {
return owner
}
func returnRhsTruthy(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
func returnRhsTruthy(_ *dataTreeNavigator, _ Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
owner := getOwner(lhs, rhs)
rhsBool := isTruthyNode(rhs)
@ -136,7 +136,7 @@ func andOperator(d *dataTreeNavigator, context Context, expressionNode *Expressi
return crossFunctionWithPrefs(d, context.ReadOnlyClone(), expressionNode, prefs)
}
func notOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func notOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("-- notOperation")
var results = list.New()

View File

@ -15,7 +15,7 @@ import (
...
*/
func collectObjectOperator(d *dataTreeNavigator, originalContext Context, expressionNode *ExpressionNode) (Context, error) {
func collectObjectOperator(d *dataTreeNavigator, originalContext Context, _ *ExpressionNode) (Context, error) {
log.Debugf("-- collectObjectOperation")
context := originalContext.WritableClone()

View File

@ -5,7 +5,7 @@ import (
"fmt"
)
func columnOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func columnOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("columnOperator")
var results = list.New()

View File

@ -72,7 +72,7 @@ func assignCommentsOperator(d *dataTreeNavigator, context Context, expressionNod
return context, nil
}
func getCommentsOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func getCommentsOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
preferences := expressionNode.Operation.Preferences.(commentOpPreferences)
var startCommentCharacterRegExp = regexp.MustCompile(`^# `)
var subsequentCommentCharacterRegExp = regexp.MustCompile(`\n# `)

View File

@ -92,7 +92,7 @@ func contains(lhs *CandidateNode, rhs *CandidateNode) (bool, error) {
return false, fmt.Errorf("%v not yet supported for contains", lhs.Tag)
}
func containsWithNodes(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
func containsWithNodes(_ *dataTreeNavigator, _ Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
if lhs.Kind != rhs.Kind {
return nil, fmt.Errorf("%v cannot check contained in %v", rhs.Tag, lhs.Tag)
}

View File

@ -37,7 +37,7 @@ func withDateTimeFormat(d *dataTreeNavigator, context Context, expressionNode *E
// for unit tests
var Now = time.Now
func nowOp(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func nowOp(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
node := &CandidateNode{
Tag: "!!timestamp",
@ -134,7 +134,7 @@ func parseUnixTime(unixTime string) (time.Time, error) {
return time.UnixMilli(int64(seconds * 1000)), nil
}
func fromUnixOp(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func fromUnixOp(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
var results = list.New()
@ -160,7 +160,7 @@ func fromUnixOp(d *dataTreeNavigator, context Context, expressionNode *Expressio
return context.ChildContext(results), nil
}
func toUnixOp(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func toUnixOp(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
layout := context.GetDateTimeLayout()

View File

@ -12,7 +12,7 @@ func divideOperator(d *dataTreeNavigator, context Context, expressionNode *Expre
return crossFunction(d, context.ReadOnlyClone(), expressionNode, divide, false)
}
func divide(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
func divide(_ *dataTreeNavigator, _ Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
if lhs.Tag == "!!null" {
return nil, fmt.Errorf("%v (%v) cannot be divided by %v (%v)", lhs.Tag, lhs.GetNicePath(), rhs.Tag, rhs.GetNicePath())
}

View File

@ -5,7 +5,7 @@ import (
"fmt"
)
func getDocumentIndexOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func getDocumentIndexOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
var results = list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {

View File

@ -54,7 +54,7 @@ type encoderPreferences struct {
/* encodes object as yaml string */
func encodeOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func encodeOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
preferences := expressionNode.Operation.Preferences.(encoderPreferences)
var results = list.New()
@ -122,7 +122,7 @@ func createDecoder(format InputFormat) Decoder {
}
/* takes a string and decodes it back into an object */
func decodeOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func decodeOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
preferences := expressionNode.Operation.Preferences.(decoderPreferences)

View File

@ -40,7 +40,7 @@ func toEntriesfromSeq(candidateNode *CandidateNode) *CandidateNode {
return sequence
}
func toEntriesOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func toEntriesOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
var results = list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
@ -102,7 +102,7 @@ func fromEntries(candidateNode *CandidateNode) (*CandidateNode, error) {
return node, nil
}
func fromEntriesOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func fromEntriesOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
var results = list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)

View File

@ -16,7 +16,7 @@ type envOpPreferences struct {
FailFast bool
}
func envOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func envOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
envName := expressionNode.Operation.CandidateNode.Value
log.Debug("EnvOperator, env name:", envName)
@ -53,7 +53,7 @@ func envOperator(d *dataTreeNavigator, context Context, expressionNode *Expressi
return context.SingleChildContext(node), nil
}
func envsubstOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func envsubstOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
var results = list.New()
preferences := envOpPreferences{}
if expressionNode.Operation.Preferences != nil {

View File

@ -5,7 +5,7 @@ import (
"fmt"
)
func getFilenameOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func getFilenameOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("GetFilename")
var results = list.New()
@ -19,7 +19,7 @@ func getFilenameOperator(d *dataTreeNavigator, context Context, expressionNode *
return context.ChildContext(results), nil
}
func getFileIndexOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func getFileIndexOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("GetFileIndex")
var results = list.New()

View File

@ -32,7 +32,7 @@ func flatten(node *CandidateNode, depth int) {
node.AddChildren(newSeq)
}
func flattenOp(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func flattenOp(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
log.Debugf("-- flatten Operator")
depth := expressionNode.Operation.Preferences.(flattenPreferences).depth

View File

@ -5,7 +5,7 @@ import (
"fmt"
)
func isKeyOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func isKeyOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("-- isKeyOperator")
var results = list.New()
@ -19,7 +19,7 @@ func isKeyOperator(d *dataTreeNavigator, context Context, expressionNode *Expres
return context.ChildContext(results), nil
}
func getKeyOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func getKeyOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("-- getKeyOperator")
var results = list.New()
@ -36,7 +36,7 @@ func getKeyOperator(d *dataTreeNavigator, context Context, expressionNode *Expre
}
func keysOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func keysOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("-- keysOperator")
var results = list.New()

View File

@ -19,7 +19,7 @@ func kindToText(kind Kind) string {
}
}
func getKindOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func getKindOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("GetKindOperator")
var results = list.New()

View File

@ -5,7 +5,7 @@ import (
"fmt"
)
func lengthOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func lengthOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("-- lengthOperation")
var results = list.New()

View File

@ -5,7 +5,7 @@ import (
"fmt"
)
func lineOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func lineOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("lineOperator")
var results = list.New()

View File

@ -54,13 +54,12 @@ func loadYaml(filename string, decoder Decoder) (*CandidateNode, error) {
candidate := documents.Front().Value.(*CandidateNode)
return candidate, nil
} else {
sequenceNode := &CandidateNode{Kind: SequenceNode}
for doc := documents.Front(); doc != nil; doc = doc.Next() {
sequenceNode.AddChild(doc.Value.(*CandidateNode))
}
return sequenceNode, nil
}
sequenceNode := &CandidateNode{Kind: SequenceNode}
for doc := documents.Front(); doc != nil; doc = doc.Next() {
sequenceNode.AddChild(doc.Value.(*CandidateNode))
}
return sequenceNode, nil
}
func loadYamlOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {

View File

@ -13,7 +13,7 @@ func moduloOperator(d *dataTreeNavigator, context Context, expressionNode *Expre
return crossFunction(d, context.ReadOnlyClone(), expressionNode, modulo, false)
}
func modulo(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
func modulo(_ *dataTreeNavigator, _ Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
if lhs.Tag == "!!null" {
return nil, fmt.Errorf("%v (%v) cannot modulo by %v (%v)", lhs.Tag, lhs.GetNicePath(), rhs.Tag, rhs.GetNicePath())
}

View File

@ -2,7 +2,7 @@ package yqlib
import "container/list"
func getParentOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func getParentOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("-- getParentOperator")
var results = list.New()

View File

@ -147,7 +147,7 @@ func delPathsOperator(d *dataTreeNavigator, context Context, expressionNode *Exp
}
func getPathOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func getPathOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("GetPath")
var results = list.New()

View File

@ -9,7 +9,7 @@ type recursiveDescentPreferences struct {
RecurseArray bool
}
func recursiveDescentOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func recursiveDescentOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
var results = list.New()
preferences := expressionNode.Operation.Preferences.(recursiveDescentPreferences)

View File

@ -5,7 +5,7 @@ import (
"fmt"
)
func reverseOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func reverseOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
results := list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {

View File

@ -1,5 +1,5 @@
package yqlib
func selfOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func selfOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
return context, nil
}

View File

@ -6,7 +6,7 @@ import (
"math/rand"
)
func shuffleOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func shuffleOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
// ignore CWE-338 gosec issue of not using crypto/rand
// this is just to shuffle an array rather generating a

View File

@ -1,6 +1,6 @@
package yqlib
func splitDocumentOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func splitDocumentOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("-- splitDocumentOperator")
var index uint

View File

@ -11,7 +11,7 @@ type changeCasePrefs struct {
ToUpperCase bool
}
func trimSpaceOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func trimSpaceOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
results := list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
node := el.Value.(*CandidateNode)
@ -29,7 +29,7 @@ func trimSpaceOperator(d *dataTreeNavigator, context Context, expressionNode *Ex
return context.ChildContext(results), nil
}
func changeCaseOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func changeCaseOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
results := list.New()
prefs := expressionNode.Operation.Preferences.(changeCasePrefs)

View File

@ -71,7 +71,7 @@ func assignStyleOperator(d *dataTreeNavigator, context Context, expressionNode *
return context, nil
}
func getStyleOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func getStyleOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("GetStyleOperator")
var results = list.New()

View File

@ -42,7 +42,7 @@ func subtractArray(lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, erro
return lhs, nil
}
func subtract(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
func subtract(_ *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
if lhs.Tag == "!!null" {
return lhs.CopyAsReplacement(rhs), nil
}

View File

@ -45,7 +45,7 @@ func assignTagOperator(d *dataTreeNavigator, context Context, expressionNode *Ex
return context, nil
}
func getTagOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func getTagOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("GetTagOperator")
var results = list.New()

View File

@ -22,7 +22,7 @@ func tryConvertToNumber(value string) (string, bool) {
}
func toNumberOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func toNumberOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("ToNumberOperator")
var results = list.New()

View File

@ -19,7 +19,7 @@ func splat(context Context, prefs traversePreferences) (Context, error) {
return traverseNodesWithArrayIndices(context, make([]*CandidateNode, 0), prefs)
}
func traversePathOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func traversePathOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
log.Debugf("-- traversePathOperator")
var matches = list.New()

View File

@ -7,7 +7,7 @@ import (
"github.com/elliotchance/orderedmap"
)
func unique(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func unique(d *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
selfExpression := &ExpressionNode{Operation: &Operation{OperationType: selfReferenceOpType}}
uniqueByExpression := &ExpressionNode{Operation: &Operation{OperationType: uniqueByOpType}, RHS: selfExpression}
return uniqueBy(d, context, uniqueByExpression)

View File

@ -2,11 +2,11 @@ package yqlib
import "container/list"
func referenceOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func referenceOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
return context.SingleChildContext(expressionNode.Operation.CandidateNode), nil
}
func valueOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func valueOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
log.Debug("value = %v", expressionNode.Operation.CandidateNode.Value)
if context.MatchingNodes.Len() == 0 {
clone := expressionNode.Operation.CandidateNode.Copy()

View File

@ -5,7 +5,7 @@ import (
"fmt"
)
func getVariableOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func getVariableOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
variableName := expressionNode.Operation.StringValue
log.Debug("getVariableOperator %v", variableName)
result := context.GetVariable(variableName)
@ -19,7 +19,7 @@ type assignVarPreferences struct {
IsReference bool
}
func useWithPipe(d *dataTreeNavigator, context Context, originalExp *ExpressionNode) (Context, error) {
func useWithPipe(_ *dataTreeNavigator, _ Context, _ *ExpressionNode) (Context, error) {
return Context{}, fmt.Errorf("must use variable with a pipe, e.g. `exp as $x | ...`")
}

View File

@ -51,7 +51,7 @@ func compoundAssignFunction(d *dataTreeNavigator, context Context, expressionNod
return context, nil
}
func emptyOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
func emptyOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
context.MatchingNodes = list.New()
return context, nil
}

View File

@ -40,7 +40,7 @@ func TestMain(m *testing.M) {
os.Exit(code)
}
func NewSimpleYamlPrinter(writer io.Writer, outputFormat PrinterOutputFormat, unwrapScalar bool, colorsEnabled bool, indent int, printDocSeparators bool) Printer {
func NewSimpleYamlPrinter(writer io.Writer, _ PrinterOutputFormat, unwrapScalar bool, colorsEnabled bool, indent int, printDocSeparators bool) Printer {
prefs := NewDefaultYamlPreferences()
prefs.PrintDocSeparators = printDocSeparators
prefs.UnwrapScalar = unwrapScalar

View File

@ -22,7 +22,7 @@ func NewSinglePrinterWriter(writer io.Writer) PrinterWriter {
}
}
func (sp *singlePrinterWriter) GetWriter(node *CandidateNode) (*bufio.Writer, error) {
func (sp *singlePrinterWriter) GetWriter(_ *CandidateNode) (*bufio.Writer, error) {
return sp.bufferedWriter, nil
}

View File

@ -350,7 +350,7 @@ func documentRoundTripPropertyScenario(w *bufio.Writer, s formatScenario) {
writeOrPanic(w, fmt.Sprintf("```properties\n%v```\n\n", mustProcessFormatScenario(s, NewPropertiesDecoder(), NewPropertiesEncoder(true))))
}
func documentPropertyScenario(t *testing.T, w *bufio.Writer, i interface{}) {
func documentPropertyScenario(_ *testing.T, w *bufio.Writer, i interface{}) {
s := i.(formatScenario)
if s.skipDoc {
return

View File

@ -268,7 +268,7 @@ func documentTomlRoundtripScenario(w *bufio.Writer, s formatScenario) {
writeOrPanic(w, fmt.Sprintf("```yaml\n%v```\n\n", mustProcessFormatScenario(s, NewTomlDecoder(), NewTomlEncoder())))
}
func documentTomlScenario(t *testing.T, w *bufio.Writer, i interface{}) {
func documentTomlScenario(_ *testing.T, w *bufio.Writer, i interface{}) {
s := i.(formatScenario)
if s.skipDoc {

View File

@ -658,7 +658,7 @@ func testXMLScenario(t *testing.T, s formatScenario) {
}
}
func documentXMLScenario(t *testing.T, w *bufio.Writer, i interface{}) {
func documentXMLScenario(_ *testing.T, w *bufio.Writer, i interface{}) {
s := i.(formatScenario)
if s.skipDoc {

View File

@ -250,4 +250,5 @@ yqlib
yuin
zabbix
tonumber
noyaml
noyaml
nolint

View File

@ -1,5 +1,5 @@
#!/bin/sh
set -ex
go mod download golang.org/x/tools@latest
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
wget -O- -nv https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s