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

Use Go 1.22 #737

Merged
merged 1 commit into from
May 22, 2024
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
2 changes: 1 addition & 1 deletion cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func opaTest(args []string) int {
AddCustomBuiltins(builtins.TestContextBuiltins()).
Filter(testParams.runRegex)

for i := 0; i < testParams.count; i++ {
for range testParams.count {
exitCode := runTests(ctx, txn, runner, testReporter(cov, modules))
if exitCode != 0 {
return exitCode
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/styrainc/regal

go 1.21 // any officially supported Golang version should be OK
go 1.22

toolchain go1.22.0

Expand Down
4 changes: 0 additions & 4 deletions internal/lsp/commands/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ func TestParse(t *testing.T) {
}

for name, tc := range testCases {
tc := tc

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -92,8 +90,6 @@ func TestParse_Errors(t *testing.T) {
}

for name, tc := range testCases {
tc := tc

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
6 changes: 0 additions & 6 deletions internal/lsp/documentsymbol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ func TestRefToString(t *testing.T) {
}

for _, tc := range cases {
tc := tc

t.Run(tc.title, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -131,8 +129,6 @@ func TestDocumentSymbols(t *testing.T) {
}

for _, tc := range cases {
tc := tc

t.Run(tc.title, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -219,8 +215,6 @@ func TestSimplifyType(t *testing.T) {
}

for _, tc := range cases {
tc := tc

t.Run(tc.input, func(t *testing.T) {
t.Parallel()

Expand Down
32 changes: 12 additions & 20 deletions internal/lsp/uri/uri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ func TestPathToURI(t *testing.T) {
}

for label, tc := range testCases {
tt := tc

t.Run(label, func(t *testing.T) {
t.Parallel()

got := FromPath(clients.IdentifierGeneric, tt.path)
got := FromPath(clients.IdentifierGeneric, tc.path)

if got != tt.want {
t.Errorf("got %q, want %q", got, tt.want)
if got != tc.want {
t.Errorf("got %q, want %q", got, tc.want)
}
})
}
Expand Down Expand Up @@ -69,15 +67,13 @@ func TestPathToURI_VSCode(t *testing.T) {
}

for label, tc := range testCases {
tt := tc

t.Run(label, func(t *testing.T) {
t.Parallel()

got := FromPath(clients.IdentifierVSCode, tt.path)
got := FromPath(clients.IdentifierVSCode, tc.path)

if got != tt.want {
t.Errorf("got %q, want %q", got, tt.want)
if got != tc.want {
t.Errorf("got %q, want %q", got, tc.want)
}
})
}
Expand Down Expand Up @@ -105,14 +101,12 @@ func TestURIToPath(t *testing.T) {
}

for label, tc := range testCases {
tt := tc

t.Run(label, func(t *testing.T) {
t.Parallel()

got := ToPath(clients.IdentifierGeneric, tt.uri)
if got != tt.want {
t.Errorf("got %q, want %q", got, tt.want)
got := ToPath(clients.IdentifierGeneric, tc.uri)
if got != tc.want {
t.Errorf("got %q, want %q", got, tc.want)
}
})
}
Expand Down Expand Up @@ -157,14 +151,12 @@ func TestURIToPath_VSCode(t *testing.T) {
}

for label, tc := range testCases {
tt := tc

t.Run(label, func(t *testing.T) {
t.Parallel()

got := ToPath(clients.IdentifierVSCode, tt.uri)
if got != tt.want {
t.Errorf("got %q, want %q", got, tt.want)
got := ToPath(clients.IdentifierVSCode, tc.uri)
if got != tc.want {
t.Errorf("got %q, want %q", got, tc.want)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion internal/novelty/holidays.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func HappyHolidays() error {
)
allSprites.Sprites = append(allSprites.Sprites, messageSprite)

for i := 0; i < 30; i++ {
for range 30 {
//nolint:gosec
flakeX := rand.Intn(width)
//nolint:gosec
Expand Down
2 changes: 0 additions & 2 deletions pkg/config/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ func TestFilterIgnoredPaths(t *testing.T) {
}

for name, tc := range testCases {
tc := tc

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions pkg/fixer/fixes/fmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ allow := true
}

for testName, tc := range testCases {
tc := tc

t.Run(testName, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions pkg/fixer/fixes/nowhitespacecomment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ func TestNoWhitespaceComment(t *testing.T) {
}

for testName, tc := range testCases {
tc := tc

nwc := NoWhitespaceComment{}

t.Run(testName, func(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/fixer/fixes/useassignmentoperator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ allow := true
}

for testName, tc := range testCases {
tc := tc

t.Run(testName, func(t *testing.T) {
t.Parallel()

Expand Down
29 changes: 14 additions & 15 deletions pkg/linter/linter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,46 +263,45 @@ or := 1
}

for _, tc := range tests {
tt := tc
t.Run(tt.name, func(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

linter := NewLinter()

linter = linter.WithRootDir(tt.rootDir)
linter = linter.WithRootDir(tc.rootDir)

if tt.userConfig != nil {
linter = linter.WithUserConfig(*tt.userConfig)
if tc.userConfig != nil {
linter = linter.WithUserConfig(*tc.userConfig)
}

if tt.ignoreFilesFlag != nil {
linter = linter.WithIgnore(tt.ignoreFilesFlag)
if tc.ignoreFilesFlag != nil {
linter = linter.WithIgnore(tc.ignoreFilesFlag)
}

input := test.InputPolicy(tt.filename, policy)
input := test.InputPolicy(tc.filename, policy)

linter = linter.WithInputModules(&input)

result := testutil.Must(linter.Lint(context.Background()))(t)

if len(result.Violations) != len(tt.expViolations) {
if len(result.Violations) != len(tc.expViolations) {
t.Fatalf("expected %d violation, got %d: %v",
len(tt.expViolations),
len(tc.expViolations),
len(result.Violations),
result.Violations,
)
}

for idx, violation := range result.Violations {
if violation.Title != tt.expViolations[idx] {
t.Errorf("expected first violation to be '%s', got %s", tt.expViolations[idx], result.Violations[0].Title)
if violation.Title != tc.expViolations[idx] {
t.Errorf("expected first violation to be '%s', got %s", tc.expViolations[idx], result.Violations[0].Title)
}
}

if len(tt.expLevels) > 0 {
if len(tc.expLevels) > 0 {
for idx, violation := range result.Violations {
if violation.Level != tt.expLevels[idx] {
t.Errorf("expected first violation to be '%s', got %s", tt.expLevels[idx], result.Violations[0].Level)
if violation.Level != tc.expLevels[idx] {
t.Errorf("expected first violation to be '%s', got %s", tc.expLevels[idx], result.Violations[0].Level)
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/rules/fmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ func TestFmtRuleFail(t *testing.T) {
}

for name, tc := range testCases {
tc := tc

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down