Skip to content
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 expects formatters to be a string #168

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/rubocop-sketchup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
# formatters. Naughty! Naughty!
class RuboCop::Formatter::FormatterSet
formatters = BUILTIN_FORMATTERS_FOR_KEYS.dup
formatters['extension_review'] =
RuboCop::Formatter::ExtensionReviewFormatter
formatters['extension_review'] = 'ExtensionReviewFormatter'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will then look for 'ExtensionReviewFormatter' in the RuboCop::Formatter namespace?

Copy link
Contributor Author

@macumber macumber Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, RuboCop::Formatter.const_get(formatter_name) at https://github.com/rubocop/rubocop/blob/master/lib/rubocop/formatter/formatter_set.rb#L102 is calling const_get on the RuboCop::Formatter module. The argument to const_get is a symbol or a string, https://www.rubydoc.info/stdlib/core/Module:const_get. Maybe this used to accept a Class in Ruby 2.x but it seems to not accept that in Ruby 3.x.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Thank you for the PR. I guess the CI tests never tests the custom formatter.

I had a quick look at RuboCop docs, and it appear to still be lacking a clear good API to add custom extensions and formatters without monkey patching some parts of RuboCop. So this has always been something that has a higher risk of breaking.


verbose = $VERBOSE
begin
$VERBOSE = nil
Expand Down
Loading