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
rubocop: Trim Naming/MethodParameterName
allowlist
#14922
rubocop: Trim Naming/MethodParameterName
allowlist
#14922
Conversation
Review period will end on 2023-03-09 at 00:46:11 UTC. |
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.
Great work here! One suggested tweak only to a comment.
@@ -183,7 +183,6 @@ Naming/MethodName: | |||
- '\A(fetch_)?HEAD\?\Z' | |||
|
|||
# allow those that are standard | |||
# TODO: try to remove some of these |
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 think we can leave this comment as-is and aim to remove more later.
I'm personally of the belief that single/double letter variables almost always hinder readability more than the value they provide through speedy typing.
The only one I can see being ever valuable here is f
and pr
because their meanings are more obvious but even f
has been widely misused to mean f(ormula or cask)
which hinders readability.
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.
Yeah I was gonna follow up with this, I just got tired last night. Shouldn't have removed the comment. 💤
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 think there's an argument that pr
as an allowed variable should be upstreamed to core RuboCop given it's so ubiquitous, but I'll try that another day.
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.
@issyl0 Yeh, I'm a strong 👍🏻 on "if we can get Exclude:
and/or Enabled: false
changes upstreamed then let's do so and otherwise: let's try to move towards a configuration RuboCop supports".
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.
Thanks @issyl0!
Good to 🚢 once merge conflicts fixed and CI is 💚 |
Review period skipped due to |
- These are already included in https://github.com/rubocop/rubocop/blob/6136ffd91e8d6fba22d6fb44ec8498a5d43537d0/config/default.yml#L2834-L2862 upstream default allowed method names, so we don't need them here too. - Practically this makes no difference since the `inherit_mode` is `merge` it'll just merge the two, but for tidiness I thought I'd do this anyway since the duplication annoyed me.
- This was an easy fix, "v" => "version".
- I originally thought this was short for "function", but upon closer inspection all its usages are to do with filenames. So, use "filename", it's clearer.
- It's entirely unused as a parameter name.
- Most usages of this were in the `pretty_duration` method, where "s" is better described as "seconds" since we're calculating a duration. - I also took the executive decision to do the same to "m" which refers to "minutes".
- This stands for "resource" in our case, so use the long name.
- It's used to refer to a patch, so use the long name.
- It seems that "ff" was short for plural formula, so formulae.
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
a727a69
to
e1c4555
Compare
def include?(str) | ||
@text.include? str |
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.
def include?(str) | |
@text.include? str | |
def include?(string) | |
@text.include? string |
@@ -50,14 +50,14 @@ def error(string, label: nil) | |||
# so we always wrap one word before an option. | |||
# @see https://github.com/Homebrew/brew/pull/12672 | |||
# @see https://macromates.com/blog/2006/wrapping-text-with-regular-expressions/ | |||
def format_help_text(s, width: 172) | |||
def format_help_text(str, width: 172) |
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.
def format_help_text(str, width: 172) | |
def format_help_text(string, width: 172) |
.gsub(/^( +-.+ +(?=\S.{#{desc}}))(.{1,#{desc}})( +|$)(?!-)\n?/, "\\1\\2\n#{" " * indent}") | ||
.gsub(/^( {#{indent}}(?=\S.{#{desc}}))(.{1,#{desc}})( +|$)(?!-)\n?/, "\\1\\2\n#{" " * indent}") | ||
.gsub(/(.{1,#{width}})( +|$)(?!-)\n?/, "\\1\n") | ||
str.gsub(/(?<=\S) *\n(?=\S)/, " ") |
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.
str.gsub(/(?<=\S) *\n(?=\S)/, " ") | |
string.gsub(/(?<=\S) *\n(?=\S)/, " ") |
and this will break indentation below, sorry!
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.
Automerge was too quick! I'll fix these up soon!
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.
No worries, I triggered it 😅
- Three characters is the RuboCop limit for parameter names, but more descriptive is good. - Requested in Homebrew#14922 (review), but the automerge was too quick for me to get to it.
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?