core(deps): bump golang-cilint to v2.0.2 (#83)

This commit is contained in:
ChristopherHX
2025-04-25 21:58:30 +02:00
committed by GitHub
parent 4be22e9b76
commit fba76f10dd
38 changed files with 184 additions and 174 deletions

View File

@@ -94,13 +94,13 @@ func (impl *interperterImpl) format(str reflect.Value, replaceValue ...reflect.V
case '}':
index, err := strconv.ParseInt(replacementIndex, 10, 32)
if err != nil {
return "", fmt.Errorf("The following format string is invalid: '%s'", input)
return "", fmt.Errorf("the following format string is invalid: '%s'", input)
}
replacementIndex = ""
if len(replaceValue) <= int(index) {
return "", fmt.Errorf("The following format string references more arguments than were supplied: '%s'", input)
return "", fmt.Errorf("the following format string references more arguments than were supplied: '%s'", input)
}
output += impl.coerceToString(replaceValue[index]).String()
@@ -127,10 +127,10 @@ func (impl *interperterImpl) format(str reflect.Value, replaceValue ...reflect.V
if state != passThrough {
switch state {
case bracketOpen:
return "", fmt.Errorf("Unclosed brackets. The following format string is invalid: '%s'", input)
return "", fmt.Errorf("unclosed brackets. The following format string is invalid: '%s'", input)
case bracketClose:
return "", fmt.Errorf("Closing bracket without opening one. The following format string is invalid: '%s'", input)
return "", fmt.Errorf("closing bracket without opening one. The following format string is invalid: '%s'", input)
}
}
@@ -159,7 +159,7 @@ func (impl *interperterImpl) toJSON(value reflect.Value) (string, error) {
json, err := json.MarshalIndent(value.Interface(), "", " ")
if err != nil {
return "", fmt.Errorf("Cannot convert value to JSON. Cause: %v", err)
return "", fmt.Errorf("cannot convert value to JSON. Cause: %v", err)
}
return string(json), nil
@@ -167,14 +167,14 @@ func (impl *interperterImpl) toJSON(value reflect.Value) (string, error) {
func (impl *interperterImpl) fromJSON(value reflect.Value) (interface{}, error) {
if value.Kind() != reflect.String {
return nil, fmt.Errorf("Cannot parse non-string type %v as JSON", value.Kind())
return nil, fmt.Errorf("cannot parse non-string type %v as JSON", value.Kind())
}
var data interface{}
err := json.Unmarshal([]byte(value.String()), &data)
if err != nil {
return nil, fmt.Errorf("Invalid JSON: %v", err)
return nil, fmt.Errorf("invalid JSON: %v", err)
}
return data, nil
@@ -195,7 +195,7 @@ func (impl *interperterImpl) hashFiles(paths ...reflect.Value) (string, error) {
}
ps = append(ps, gitignore.ParsePattern(cleanPath, nil))
} else {
return "", fmt.Errorf("Non-string path passed to hashFiles")
return "", fmt.Errorf("non-string path passed to hashFiles")
}
}
@@ -214,7 +214,7 @@ func (impl *interperterImpl) hashFiles(paths ...reflect.Value) (string, error) {
files = append(files, path)
return nil
}); err != nil {
return "", fmt.Errorf("Unable to filepath.Walk: %v", err)
return "", fmt.Errorf("unable to filepath.Walk: %v", err)
}
if len(files) == 0 {
@@ -226,15 +226,15 @@ func (impl *interperterImpl) hashFiles(paths ...reflect.Value) (string, error) {
for _, file := range files {
f, err := os.Open(file)
if err != nil {
return "", fmt.Errorf("Unable to os.Open: %v", err)
return "", fmt.Errorf("unable to os.Open: %v", err)
}
if _, err := io.Copy(hasher, f); err != nil {
return "", fmt.Errorf("Unable to io.Copy: %v", err)
return "", fmt.Errorf("unable to io.Copy: %v", err)
}
if err := f.Close(); err != nil {
return "", fmt.Errorf("Unable to Close file: %v", err)
return "", fmt.Errorf("unable to Close file: %v", err)
}
}

View File

@@ -233,10 +233,10 @@ func TestFunctionFormat(t *testing.T) {
{`format('Hello "{0}" {1} {2}', fromJSON('[0, true, "abc"]'), fromJSON('[{"a":1}]'), fromJSON('{"a":{"b":1}}'))`, `Hello "Array" Array Object`, nil, "format-with-complex-types"},
{"format(true)", "true", nil, "format-with-primitive-args"},
{"format('echo Hello {0} ${{Test}}', github.undefined_property)", "echo Hello ${Test}", nil, "format-with-undefined-value"},
{"format('{0}}', '{1}', 'World')", nil, "Closing bracket without opening one. The following format string is invalid: '{0}}'", "format-invalid-format-string"},
{"format('{0', '{1}', 'World')", nil, "Unclosed brackets. The following format string is invalid: '{0'", "format-invalid-format-string"},
{"format('{2}', '{1}', 'World')", "", "The following format string references more arguments than were supplied: '{2}'", "format-invalid-replacement-reference"},
{"format('{2147483648}')", "", "The following format string is invalid: '{2147483648}'", "format-invalid-replacement-reference"},
{"format('{0}}', '{1}', 'World')", nil, "closing bracket without opening one. The following format string is invalid: '{0}}'", "format-invalid-format-string"},
{"format('{0', '{1}', 'World')", nil, "unclosed brackets. The following format string is invalid: '{0'", "format-invalid-format-string"},
{"format('{2}', '{1}', 'World')", "", "the following format string references more arguments than were supplied: '{2}'", "format-invalid-replacement-reference"},
{"format('{2147483648}')", "", "the following format string is invalid: '{2147483648}'", "format-invalid-replacement-reference"},
{"format('{0} {1} {2} {3}', 1.0, 1.1, 1234567890.0, 12345678901234567890.0)", "1 1.1 1234567890 1.23456789012346E+19", nil, "format-floats"},
}

View File

@@ -86,7 +86,7 @@ func (impl *interperterImpl) Evaluate(input string, defaultStatusCheck DefaultSt
parser := actionlint.NewExprParser()
exprNode, err := parser.Parse(actionlint.NewExprLexer(input + "}}"))
if err != nil {
return nil, fmt.Errorf("Failed to parse: %s", err.Message)
return nil, fmt.Errorf("failed to parse: %s", err.Message)
}
if defaultStatusCheck != DefaultStatusCheckNone {
@@ -146,7 +146,7 @@ func (impl *interperterImpl) evaluateNode(exprNode actionlint.ExprNode) (interfa
case *actionlint.FuncCallNode:
return impl.evaluateFuncCall(node)
default:
return nil, fmt.Errorf("Fatal error! Unknown node type: %s node: %+v", reflect.TypeOf(exprNode), exprNode)
return nil, fmt.Errorf("fatal error! Unknown node type: %s node: %+v", reflect.TypeOf(exprNode), exprNode)
}
}
@@ -160,7 +160,7 @@ func (impl *interperterImpl) evaluateVariable(variableNode *actionlint.VariableN
return impl.env.Job, nil
case "jobs":
if impl.env.Jobs == nil {
return nil, fmt.Errorf("Unavailable context: jobs")
return nil, fmt.Errorf("unavailable context: jobs")
}
return impl.env.Jobs, nil
case "steps":
@@ -184,7 +184,7 @@ func (impl *interperterImpl) evaluateVariable(variableNode *actionlint.VariableN
case "nan":
return math.NaN(), nil
default:
return nil, fmt.Errorf("Unavailable context: %s", variableNode.Name)
return nil, fmt.Errorf("unavailable context: %s", variableNode.Name)
}
}
@@ -414,10 +414,10 @@ func (impl *interperterImpl) compareValues(leftValue reflect.Value, rightValue r
}
// not possible situation - params are converted to the same type in code above
return nil, fmt.Errorf("Compare params of Invalid type: left: %+v, right: %+v", leftValue.Kind(), rightValue.Kind())
return nil, fmt.Errorf("compare params of Invalid type: left: %+v, right: %+v", leftValue.Kind(), rightValue.Kind())
default:
return nil, fmt.Errorf("Compare not implemented for types: left: %+v, right: %+v", leftValue.Kind(), rightValue.Kind())
return nil, fmt.Errorf("compare not implemented for types: left: %+v, right: %+v", leftValue.Kind(), rightValue.Kind())
}
}
@@ -505,7 +505,7 @@ func (impl *interperterImpl) compareString(left string, right string, kind actio
case actionlint.CompareOpNodeKindNotEq:
return left != right, nil
default:
return false, fmt.Errorf("TODO: not implemented to compare '%+v'", kind)
return false, fmt.Errorf("todo: not implemented to compare '%+v'", kind)
}
}
@@ -524,7 +524,7 @@ func (impl *interperterImpl) compareNumber(left float64, right float64, kind act
case actionlint.CompareOpNodeKindNotEq:
return left != right, nil
default:
return false, fmt.Errorf("TODO: not implemented to compare '%+v'", kind)
return false, fmt.Errorf("todo: not implemented to compare '%+v'", kind)
}
}
@@ -604,7 +604,7 @@ func (impl *interperterImpl) evaluateLogicalCompare(compareNode *actionlint.Logi
return impl.getSafeValue(rightValue), nil
}
return nil, fmt.Errorf("Unable to compare incompatibles types '%s' and '%s'", leftValue.Kind(), rightValue.Kind())
return nil, fmt.Errorf("unable to compare incompatibles types '%s' and '%s'", leftValue.Kind(), rightValue.Kind())
}
//nolint:gocyclo
@@ -652,7 +652,7 @@ func (impl *interperterImpl) evaluateFuncCall(funcCallNode *actionlint.FuncCallN
if impl.config.Context == "step" {
return impl.stepSuccess()
}
return nil, fmt.Errorf("Context '%s' must be one of 'job' or 'step'", impl.config.Context)
return nil, fmt.Errorf("context '%s' must be one of 'job' or 'step'", impl.config.Context)
case "failure":
if impl.config.Context == "job" {
return impl.jobFailure()
@@ -660,10 +660,10 @@ func (impl *interperterImpl) evaluateFuncCall(funcCallNode *actionlint.FuncCallN
if impl.config.Context == "step" {
return impl.stepFailure()
}
return nil, fmt.Errorf("Context '%s' must be one of 'job' or 'step'", impl.config.Context)
return nil, fmt.Errorf("context '%s' must be one of 'job' or 'step'", impl.config.Context)
case "cancelled":
return impl.cancelled()
default:
return nil, fmt.Errorf("TODO: '%s' not implemented", funcCallNode.Callee)
return nil, fmt.Errorf("todo: '%s' not implemented", funcCallNode.Callee)
}
}

View File

@@ -73,7 +73,7 @@ func TestOperators(t *testing.T) {
{"github.event.commits[0].author.username1 != github.event.commits[1].author.username", true, "property-comparison2", ""},
{"github.event.commits[0].author.username != github.event.commits[1].author.username1", true, "property-comparison3", ""},
{"github.event.commits[0].author.username1 != github.event.commits[1].author.username2", true, "property-comparison4", ""},
{"secrets != env", nil, "property-comparison5", "Compare not implemented for types: left: map, right: map"},
{"secrets != env", nil, "property-comparison5", "compare not implemented for types: left: map, right: map"},
}
env := &EvaluationEnvironment{