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
Style/WordArray cop would be more inteligent in case of multidimensional array #10194
Comments
I would argue that it looks confusing because your arrays happen to have some strings with spaces (which cannot be converted to WordArray). Had it been as follows, it is not confusing anymore: CONTENT_TYPE = [
%w[TSR Teaser],
%w[PRO Promo]
] However one solution could be to add a configuration flag which disable cop for nested arrays: # EnabledForNestedArrays: false
# good
CONTENT_TYPE = [
['TSR', 'Teaser'],
['PRO', 'Promo']
]
# EnabledForNestedArrays: true
# bad
CONTENT_TYPE = [
['TSR', 'Teaser'],
['PRO', 'Promo']
] Although I don't prefer adding more complexity with flags, I can put together a PR if maintainers are willing to accept this. |
@tejasbubane I appreciate your comment but the arrays cannot be changed. CONTENT_TYPE = [
['TSR', 'Teaser'],
['PRO', 'Promo'],
['RTG', 'Rating Tag'],
['RTG-F', 'Rating Tag for Feature'],
] What I need in this case the cop ignores this kind of arrays. I think your suggestion to turn off it for them is one of the solution. @koic What do you think? |
@fatkodima Thank you! |
I have some cases of multidimensional array where (from my perspective) default Style/WordArray cop makes the code less readable and confusing. See this example:
Rubocop forces me to change it to:
I don't think this helps to better readability. I would wish if this would be valid and fine for default Style/WordArray cop
Please, consider this as an example ^^.
The text was updated successfully, but these errors were encountered: