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

models: break out of loops #12159

Merged
merged 2 commits into from
Jul 6, 2020
Merged

models: break out of loops #12159

merged 2 commits into from
Jul 6, 2020

Conversation

alrs
Copy link
Contributor

@alrs alrs commented Jul 6, 2020

This fixes three spots in the models package where a break was being called from a switch that was inside a for loop, turning it into a no-op. This labels the outer loop so the break will make it out of both the for and the switch.

@techknowlogick techknowlogick added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Jul 6, 2020
@techknowlogick techknowlogick added this to the 1.13.0 milestone Jul 6, 2020
Copy link
Contributor

@zeripath zeripath left a comment

Choose a reason for hiding this comment

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

mea culpa.

@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Jul 6, 2020
@cornelk
Copy link
Contributor

cornelk commented Jul 6, 2020

will an empty case not result in the same result but not require a goto and lable?

@zeripath
Copy link
Contributor

zeripath commented Jul 6, 2020

@cornelk compare:

https://play.golang.org/p/TFSvn_2IK6T

with:

https://play.golang.org/p/arHLETHlrm9

or:

https://play.golang.org/p/gi550S1EmOP

@zeripath
Copy link
Contributor

zeripath commented Jul 6, 2020

the error came from when during a failed refactor attempt I tried to move this out to a method that returned directly - but didn't I unwind the refactor completely

@lafriks
Copy link
Member

lafriks commented Jul 6, 2020

Maybe break could be replaced with return true, signingKey, nil. I know it duplicates code but at least label is not needed :)

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 6, 2020
@zeripath
Copy link
Contributor

zeripath commented Jul 6, 2020

make lgtm work

@zeripath zeripath merged commit 56f222d into go-gitea:master Jul 6, 2020
ydelafollye pushed a commit to ydelafollye/gitea that referenced this pull request Jul 31, 2020
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants