You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
We've started suffixing some methods with _v1, _v2, etc. to indicate when we're effectively versioning them and introducing new versions, so we can do "soft" code releases where we start using the new method, and can still use the old method alongside to identify and upgrade existing things that were stored by the old method. E.g.
def model_details_hasher(model)
+ NewHashingAlgorithm(model.to_json)+end++def model_details_hasher_v1(model)
SomeHashingAlgorithm(model.to_s)
end
We have Naming/VariableNumber set to EnforcedStyle: snake_case so the cop says it must be _v_1, _v_2, etc.
Describe the solution you'd like
We prefer _v1 to _v_1, so we'd like to be able to always allow these methods, whenever we add new ones. We also want to keep the rest of the rules under EnforcedStyle: snake_case the same.
Perhaps by allowing a regex to be configured, like AllowIf: /_v\d$/?
Or offering a specific option like AllowVersionSuffixInSnakeCase that does the same as the above, when the cop is set to EnforcedStyle: snake_case? This would be helpful if you want to control the speed of this feature (if allowing any regex could slow down rubocop and cause more bug reports/support issues as a result), and if other people would also want to use this combination of snake_case whilst allowing (imo) nicer-reading _v1.
Or even an option like MaxAllowedLettersBeforeNumber so you can also allow _a1, _b2, etc.
# .rubocop.ymlNaming/VariableNumber:
EnforcedStyle: snake_caseMaxAllowedLettersBeforeNumber: 1# default is 0
Describe alternatives you've considered
Disable the cop inline on every method, which then feels like that particular method is "going against style", when it's actually the style we want.
Or add each new method name to the AllowedIdentifiers array on the cop settings, which will become tiresome as we use this method of code versioning more and more into the future.
Fixrubocop#10539
Adds a new integer option called `MaxAllowedLettersBeforeNumber` to
allow a positive number of non-digits before the digits in a snake_case
style that would otherwise require separation between them, e.g. `_v1`.
Fixrubocop#10539
Also fix global variables not being matched correctly, discovered by
filling in the tests with global variable examples and having failures.
…me (#10571)
Also fix global variables not being matched correctly, discovered by
filling in the tests with global variable examples and having failures.
Is your feature request related to a problem? Please describe.
We've started suffixing some methods with
_v1
,_v2
, etc. to indicate when we're effectively versioning them and introducing new versions, so we can do "soft" code releases where we start using the new method, and can still use the old method alongside to identify and upgrade existing things that were stored by the old method. E.g.We have
Naming/VariableNumber
set toEnforcedStyle: snake_case
so the cop says it must be_v_1
,_v_2
, etc.Describe the solution you'd like
We prefer
_v1
to_v_1
, so we'd like to be able to always allow these methods, whenever we add new ones. We also want to keep the rest of the rules underEnforcedStyle: snake_case
the same.Perhaps by allowing a regex to be configured, like
AllowIf: /_v\d$/
?Or offering a specific option like
AllowVersionSuffixInSnakeCase
that does the same as the above, when the cop is set toEnforcedStyle: snake_case
? This would be helpful if you want to control the speed of this feature (if allowing any regex could slow down rubocop and cause more bug reports/support issues as a result), and if other people would also want to use this combination of snake_case whilst allowing (imo) nicer-reading_v1
.Or even an option like
MaxAllowedLettersBeforeNumber
so you can also allow_a1
,_b2
, etc.Describe alternatives you've considered
Disable the cop inline on every method, which then feels like that particular method is "going against style", when it's actually the style we want.
Or add each new method name to the
AllowedIdentifiers
array on the cop settings, which will become tiresome as we use this method of code versioning more and more into the future.The text was updated successfully, but these errors were encountered: