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

internal/lsp/*_test.go: replace for+success pattern #1248

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

srenatus
Copy link
Member

@srenatus srenatus commented Nov 8, 2024

It's no functional change, just makes the code a little more concise.

Hope you don't mind me messing with your test code like this. Originally, I had attempted to use labels, like

outer:
    for {
      select {
        case ... :
          // stuff
        break outer
    }

but labels need to be unique within a file, and having to go with outer1, outer2, ... etc would have been awkward.

select {
default:
uri := "file://" + filepath.Join(tempDir, "admins.rego")

aggs := ls.cache.GetFileAggregates(uri)
if len(aggs) > 0 {
success = true
break // don't sleep
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the only non-automatic change here

Copy link
Member

@charlieegan3 charlieegan3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me!

@srenatus
Copy link
Member Author

srenatus commented Nov 8, 2024

I'll fix the linter finding after lunch...

It's no functional change, just makes the code a little more concise.

Signed-off-by: Stephan Renatus <stephan@styra.com>
@srenatus srenatus merged commit d016a23 into StyraInc:main Nov 8, 2024
5 checks passed
@srenatus srenatus deleted the sr/success-loop branch November 8, 2024 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants