diff --git a/lib/pronto/rubocop/offense_line.rb b/lib/pronto/rubocop/offense_line.rb index b07cb9d..f1c2ff3 100644 --- a/lib/pronto/rubocop/offense_line.rb +++ b/lib/pronto/rubocop/offense_line.rb @@ -56,12 +56,23 @@ def original_lines end def autocorrect_team - @autocorrect_team ||= ::RuboCop::Cop::Team.new( - ::RuboCop::Cop::Registry.new([cop]), - patch_cop.rubocop_config, - auto_correct: true, - stdin: true, - ) + @autocorrect_team ||= + if ::RuboCop::Cop::Team.respond_to?(:mobilize) + # rubocop v0.85.0 and later + ::RuboCop::Cop::Team.mobilize( + ::RuboCop::Cop::Registry.new([cop]), + patch_cop.rubocop_config, + auto_correct: true, + stdin: true, + ) + else + ::RuboCop::Cop::Team.new( + ::RuboCop::Cop::Registry.new([cop]), + patch_cop.rubocop_config, + auto_correct: true, + stdin: true, + ) + end end def cop diff --git a/lib/pronto/rubocop/patch_cop.rb b/lib/pronto/rubocop/patch_cop.rb index ef098f4..b4d9aac 100644 --- a/lib/pronto/rubocop/patch_cop.rb +++ b/lib/pronto/rubocop/patch_cop.rb @@ -60,7 +60,13 @@ def offenses end def team - @team ||= ::RuboCop::Cop::Team.new(registry, rubocop_config) + @team ||= + if ::RuboCop::Cop::Team.respond_to?(:mobilize) + # rubocop v0.85.0 and later + ::RuboCop::Cop::Team.mobilize(registry, rubocop_config) + else + ::RuboCop::Cop::Team.new(registry, rubocop_config) + end end end end