File: rubocop_compatibility.rb

package info (click to toggle)
ruby-rubocop-ast 1.24.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,256 kB
  • sloc: ruby: 15,071; yacc: 90; makefile: 9
file content (31 lines) | stat: -rw-r--r-- 918 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

module RuboCop
  # ...
  module AST
    # Responsible for compatibility with main gem
    # @api private
    module RuboCopCompatibility
      INCOMPATIBLE_COPS = {
        '0.89.0' => 'Layout/LineLength',
        '0.92.0' => 'Style/MixinUsage'
      }.freeze
      def rubocop_loaded
        loaded = Gem::Version.new(RuboCop::Version::STRING)
        incompatible = INCOMPATIBLE_COPS.select do |k, _v|
          loaded < Gem::Version.new(k)
        end.values
        return if incompatible.empty?

        warn <<~WARNING
          *** WARNING – Incompatible versions of `rubocop` and `rubocop-ast`
          You may encounter issues with the following \
          Cop#{'s' if incompatible.size > 1}: #{incompatible.join(', ')}
          Please upgrade rubocop to at least v#{INCOMPATIBLE_COPS.keys.last}
        WARNING
      end
    end

    extend RuboCopCompatibility
  end
end