Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add std reverse linter #709

Merged
merged 3 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions linter/internal/types/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func prepareStdlib(g *typeGraph) {
"join": g.newSimpleFuncType(stringOrArray, "sep", "arr"),
"lines": g.newSimpleFuncType(arrayOfString, "arr"),
"flattenArrays": g.newSimpleFuncType(anyArrayType, "arrs"),
"reverse": g.newSimpleFuncType(anyArrayType, "arrs"),
"sort": g.newFuncType(anyArrayType, []ast.Parameter{required("arr"), optional("keyF")}),
"uniq": g.newFuncType(anyArrayType, []ast.Parameter{required("arr"), optional("keyF")}),
"sum": g.newSimpleFuncType(numberType, "arr"),
Expand Down
10 changes: 0 additions & 10 deletions testdata/builtinReverse.linter.golden
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
../testdata/builtinReverse:1:1-12 Indexed object has no field "reverse"

std.reverse([1, 2])


../testdata/builtinReverse:1:1-20 Called value must be a function, but it is assumed to be void

std.reverse([1, 2])


10 changes: 0 additions & 10 deletions testdata/builtinReverse_empty.linter.golden
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
../testdata/builtinReverse_empty:1:1-12 Indexed object has no field "reverse"

std.reverse([])


../testdata/builtinReverse_empty:1:1-16 Called value must be a function, but it is assumed to be void

std.reverse([])


10 changes: 0 additions & 10 deletions testdata/builtinReverse_many.linter.golden
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
../testdata/builtinReverse_many:1:1-12 Indexed object has no field "reverse"

std.reverse(["hello", "my", "name", "is", "tester"])


../testdata/builtinReverse_many:1:1-53 Called value must be a function, but it is assumed to be void

std.reverse(["hello", "my", "name", "is", "tester"])


10 changes: 0 additions & 10 deletions testdata/builtinReverse_not_array.linter.golden
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
../testdata/builtinReverse_not_array:1:1-12 Indexed object has no field "reverse"

std.reverse(false)


../testdata/builtinReverse_not_array:1:1-19 Called value must be a function, but it is assumed to be void

std.reverse(false)


10 changes: 0 additions & 10 deletions testdata/builtinReverse_single.linter.golden
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
../testdata/builtinReverse_single:1:1-12 Indexed object has no field "reverse"

std.reverse(["hello"])


../testdata/builtinReverse_single:1:1-23 Called value must be a function, but it is assumed to be void

std.reverse(["hello"])


4 changes: 4 additions & 0 deletions testdata/stdlib_smoke_test.golden
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@
5
],
"repeat": "foofoofoo",
"reverse": [
"a",
"b"
],
"rstripChars": "aaabbbb",
"set": [
[
Expand Down
1 change: 1 addition & 0 deletions testdata/stdlib_smoke_test.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
join: std.join(sep=",", arr=["a", "b", "c"]),
lines: std.lines(arr=["a", "b", "c"]),
flattenArrays: std.flattenArrays([[1], [2, 3], [4, 5, [6, 7]]]),
reverse: std.reverse(["b", "a"]),
sort: [
std.sort([2, 3, 1]),
std.sort(arr=[2, 3, 1], keyF=function(x) -x),
Expand Down