-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
dev: rename function parameter i
to issue
#4460
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
Conversation
I will decline this PR, |
I think the changes that was receiving arguments and variables makes sense. Single letter variables for receiving type is best practices but not as arbitrary variable in the code or as receiving argument afaik? |
Not sure to understand 🤔 One letter for a receiver is best practice. The problem is one letter as a variable. ( I don't understand your message. |
I guess it's subjective but for me: // Receiving type, more common over `issue`
func (i Issue) Fn() {}
// Not the receiving type, more common than `i`
func Fn(issue Issue) {} Example from stdlib (not the best source always but hey), they use I guess it depends on the type as well, you don't have much context over the type Here's an article mentioning the same topic: https://medium.com/@TonyBologni/go-bits-variable-names-fa8240284edc. I notice that it actually refers to the wiki (that's now moved) that somewhat suggest otherwise so maybe I'm wrong here. |
🤔 do you mean that the variable func (i *Issues) Validate() error {
for i, rule := range i.ExcludeRules {
if err := rule.Validate(); err != nil {
return fmt.Errorf("error in exclude rule #%d: %w", i, err)
} |
https://go.dev/wiki/CodeReviewComments#receiver-names https://go.dev/wiki/CodeReviewComments#variable-names There is a "fight" between the 2 rules from my POV about |
I agree that |
I understand the root of my confusion: PR contains several changes.
I was focused on the receiver names |
I guess I'm just not consistent here so maybe dismiss my argument here. In general I wouldn't rename Maybe this is not a rule that you can always apply, I wouldn't think |
Sorry it's my fault for misreading the PR. |
@alexandear can you rebase your PR to fix the conflict? |
I'm still not convinced by the receiver name I think we can keep the other 2 letters receiver but |
918c9e5
to
a526dea
Compare
i
to issue
Rebased and left only changes where |
a526dea
to
60d8fef
Compare
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.
LGTM
Sorry again for misreading the PR.
The PR renames the identifier
i
to enhance readability and maintainability.It mostly renames
i *result.Issue
toissue *result.Issue
. Other changes includenewI
tonewIssue
,copyI
tocopyIssue
.