@@ -138,9 +138,32 @@ task generate_cops_documentation: :yard_for_generate_documentation do
138138 end
139139 # rubocop:enable Metrics/MethodLength
140140
141+ def cop_urls ( config , cop )
142+ rubocop_version = Gem ::Version . new ( RuboCop ::Version ::STRING )
143+
144+ # Since Rubocop v0.75.0 and above, MessageAnnotator#new changed from:
145+ # def initialize(config, cop_config, options)
146+ # to:
147+ # def initialize(config, cop_name, cop_config, options)
148+ #
149+ # Since this library has a loose Rubocop dependency, we select the
150+ # right arguments based on the installed version.
151+ #
152+ # TODO: When Rubocop < 0.75 is no longer supported, remove the second half
153+ # of this condition.
154+
155+ if rubocop_version >= Gem ::Version . new ( '0.75.0' )
156+ RuboCop ::Cop ::MessageAnnotator . new (
157+ config , cop . name , config . for_cop ( cop ) , { }
158+ ) . urls
159+ else
160+ RuboCop ::Cop ::MessageAnnotator . new ( config , config . for_cop ( cop ) , { } ) . urls
161+ end
162+ end
163+
141164 def references ( config , cop )
142- cop_config = config . for_cop ( cop )
143- urls = RuboCop :: Cop :: MessageAnnotator . new ( config , cop_config , { } ) . urls
165+ urls = cop_urls ( config , cop )
166+
144167 return '' if urls . empty?
145168
146169 content = h3 ( 'References' )
0 commit comments