Description
TL;DR
- Reproduction: https://github.com/rubocop-lts/Style-TrailingCommaInArguments
- Bug is present in latest 2.x release
- Bug is present in the
2-stable
branch. - Bug is not present in latest
main
branch, targeting v3 release - If no further releases of 2.x are planned this can probably be ignored
- Reporting because I didn't find any mention of the bug in the tracker
- Perhaps it was fixed in a beneficial refactor.
P.S. I loved meeting so many Shopify people at #RubyKaigi a couple weeks ago! I promised several of them that I would (re)apply, and haven't done it yet. But I will.
Details
When running RuboCop on a project I saw the following errors:
2 errors occurred:
An error occurred while Style/TrailingCommaInArguments cop was inspecting /IdeaProjects/kettle-soup-cover/kettle-soup-cover.gemspec:52:15.
An error occurred while Style/TrailingCommaInArguments cop was inspecting /IdeaProjects/kettle-soup-cover/kettle-soup-cover.gemspec:59:26.
Errors are usually caused by RuboCop bugs.
Please, update to the latest RuboCop version if not already in use, and report a bug if the issue still occurs on this version.
https://github.com/rubocop/rubocop/issues
Mention the following information in the issue report:
1.75.4 (using Parser 3.3.8.0, rubocop-ast 1.44.1, analyzing as Ruby 2.7, running on ruby 3.4.2) [x86_64-linux]
The code at those specific lines was:
spec.files = Dir[
"lib/**/*.rb",
"lib/**/rakelib/*.rake",
"sig/**/*.rbs",
]
and
spec.extra_rdoc_files = Dir[
"CHANGELOG.md",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.md",
"LICENSE.txt",
"README.md",
"SECURITY.md",
]
In both cases the error pointed to the D
in Dir
on the first line of each.
In narrowing down the culprit of the bug I found that it was triggered by rubocop-shopify, not rubocop.
NOTE: The bug does not occur if Dir.glob([...])
is used instead of Dir[...]
.
I was able to create a reproduction of the bug in this repository using the
latest 2.x release of the rubocop-shopify gem.
The bug does not occur with vanilla rubocop.
The bug has been fixed in Shopify's main
branch which is targeting the not-yet-released v3.0!
Unless a new release of the 2.x line is planned this probably doesn't need further review.