-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
fix!: Refactor the repository ruleset code #3430
Merged
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9c5fc32
fix!: Refactored the repository ruleset code
stevehipwell a38ea41
fixup! fix!: Refactored the repository ruleset code
stevehipwell 152169a
fixup! fix!: Refactored the repository ruleset code
stevehipwell 959df1e
fixup! fix!: Refactored the repository ruleset code
stevehipwell a149d40
fixup! fix!: Refactored the repository ruleset code
stevehipwell b9041af
fixup! fix!: Refactored the repository ruleset code
stevehipwell a24903b
fixup! fix!: Refactored the repository ruleset code
stevehipwell b12b08c
fixup! fix!: Refactored the repository ruleset code
stevehipwell 6971bef
fixup! fix!: Refactored the repository ruleset code
stevehipwell 1f00cfe
fixup! fix!: Refactored the repository ruleset code
stevehipwell 528ce0e
Merge branch 'master' into refactor-rules
gmlewis dffa330
fixup! fix!: Refactored the repository ruleset code
stevehipwell 81b59ee
fixup! fix!: Refactored the repository ruleset code
stevehipwell 49fbce8
fixup! fix!: Refactored the repository ruleset code
stevehipwell 47d0c77
Merge remote-tracking branch 'upstream/master' into refactor-rules
stevehipwell 7241f1a
fixup! fix!: Refactored the repository ruleset code
stevehipwell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a comment here as to why
21
was chosen for the capacity, for the benefit of the maintainers and developers?If it is completely arbitrary, then please remove it entirely, as that is not idiomatic Go.
The Go team has gone to extensive lengths with benchmarking to make the defaults very reasonable, and if you don't have a good reason for the capacity, then it is not only distracting, but makes the code harder to read and understand, which also violates idiomatic Go, as one of the whole points of Go's design is that it should be super-easy to read and understand.
Therefore, if it is arbitrary, it is idiomatic Go to always take advantage of the zero-value of a type when its initial value is not the focus of the code. Therefore, this would simply be:
Short, sweet, and does not distract the reader into thinking there is something special going on here.
In fact, the comment on 482 is also distracting and reader-time-consuming, in my opinion, if there is nothing special going on here.
However, once again, if the
21
IS important (it is not obvious to me how it possibly could be), then change the comment on 482 to explain why21
is important. Otherwise, this is just a magic number:https://en.wikipedia.org/wiki/Magic_number_(programming)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a comment, but basically there will always be between 1 and 21 items in the slice due to the GitHub data model. My understanding was that if you had prior knowledge on the size of a Go array/slice that you should explicitly set it? If I'm incorrectly informed in this case I'll happily remove the
make()
call.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, fine, then please change the comment. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed 2 of the 3 cases as they were incorrect and improved the comment for the case where I think it's worth setting the capacity.