Sha256: 9398c11a77c2b1d31f4cf45c28cf01da122f81f993a506548ba78ed34aa93176

Contents?: true

Size: 770 Bytes

Versions: 8

Compression:

Stored size: 770 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Discourse
      module Plugins
        # Use `require_relative` to load dependencies.
        #
        # @example
        #   # bad
        #   load File.expand_path("../lib/my_file.rb", __FILE__)
        #
        #   # good
        #   require_relative "lib/my_file"
        #
        class UseRequireRelative < Base
          MSG = "Use `require_relative` instead of `load`."
          RESTRICT_ON_SEND = [:load].freeze

          def_node_matcher :load_called?, <<~MATCHER
            (send nil? :load _)
          MATCHER

          def on_send(node)
            return unless load_called?(node)
            add_offense(node, message: MSG)
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rubocop-discourse-3.8.6 lib/rubocop/cop/discourse/plugins/use_require_relative.rb
rubocop-discourse-3.8.5 lib/rubocop/cop/discourse/plugins/use_require_relative.rb
rubocop-discourse-3.8.4 lib/rubocop/cop/discourse/plugins/use_require_relative.rb
rubocop-discourse-3.8.3 lib/rubocop/cop/discourse/plugins/use_require_relative.rb
rubocop-discourse-3.8.2 lib/rubocop/cop/discourse/plugins/use_require_relative.rb
rubocop-discourse-3.8.1 lib/rubocop/cop/discourse/plugins/use_require_relative.rb
rubocop-discourse-3.7.1 lib/rubocop/cop/discourse/plugins/use_require_relative.rb
rubocop-discourse-3.7.0 lib/rubocop/cop/discourse/plugins/use_require_relative.rb