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
I have a use case where it would be handy to have a custom cop only instantiated once for the whole Rubocop run. After reading the v1 upgrade notes and the matching API doc, I got the idea that implementing on my custom cop a #support_mulitple_source? class method that would return true should do the trick.
Unfortunately, it seems I either missed (or misunderstood) the docs or there is a bug with this feature.
It seems to have been introduced with #7868 which main point wasn't that specific feature but autocorrection API. Which could explain if there was an issue with it. Also I'm not sure it's really used that much.
I extracted a small git repo to make it easier to reproduce the issue: https://github.com/karouf/rubocop_support_multiple_source
Expected behavior
The cop is instantiated only once, therefore the @test instance variable is set when the first file is scanned and its value only displayed once.
I have a use case where it would be handy to have a custom cop only instantiated once for the whole Rubocop run. After reading the v1 upgrade notes and the matching API doc, I got the idea that implementing on my custom cop a
#support_mulitple_source?
class method that would returntrue
should do the trick.Unfortunately, it seems I either missed (or misunderstood) the docs or there is a bug with this feature.
It seems to have been introduced with #7868 which main point wasn't that specific feature but autocorrection API. Which could explain if there was an issue with it. Also I'm not sure it's really used that much.
I extracted a small git repo to make it easier to reproduce the issue: https://github.com/karouf/rubocop_support_multiple_source
Expected behavior
The cop is instantiated only once, therefore the
@test
instance variable is set when the first file is scanned and its value only displayed once.Actual behavior
The cop is instanciated for each file that Rubocop scans, and the value of
@test
is displayed twice.Steps to reproduce the problem
RuboCop version
The text was updated successfully, but these errors were encountered: