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

Fix registry deprecation notice #240

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/rubocop/cop/sorbet/sigils/has_sigil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Sorbet
#
# If a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect.
class HasSigil < ValidSigil
@registry = Cop.registry # So we can properly subclass this cop
@registry = Registry.global # So we can properly subclass this cop
Copy link
Member

Choose a reason for hiding this comment

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

Is this even meaningful anymore? The comment seems to indicate that subclasses would not inherit the @registry instance variable and would thus break Cop.registry for subclass. Since we are moving to Registry.global, it feels like this should no longer be necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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


def require_sigil_on_all_files?
true
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/sorbet/sigils/valid_sigil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Sorbet
# If an `ExactStrictness` level is specified, it will be used in offense messages and autocorrect.
# Otherwise, if a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect.
class ValidSigil < RuboCop::Cop::Cop # rubocop:todo InternalAffairs/InheritDeprecatedCopClass
@registry = Cop.registry # So we can properly subclass this cop
@registry = Registry.global # So we can properly subclass this cop
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.


def investigate(processed_source)
return if processed_source.tokens.empty?
Expand Down
4 changes: 2 additions & 2 deletions tasks/cops_documentation.rake
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ task generate_cops_documentation: :yard_for_generate_documentation do
end

def main
cops = RuboCop::Cop::Cop.registry
cops = RuboCop::Cop::Registry.global
config = RuboCop::ConfigLoader.load_file("config/default.yml")

YARD::Registry.load!
Expand All @@ -302,7 +302,7 @@ task documentation_syntax_check: :yard_for_generate_documentation do

ok = true
YARD::Registry.load!
cops = RuboCop::Cop::Cop.registry
cops = RuboCop::Cop::Registry.global
cops.each do |cop|
examples = YARD::Registry.all(:class).find do |code_object|
next unless RuboCop::Cop::Badge.for(code_object.to_s) == cop.badge
Expand Down
Loading