Sha256: 2bce7ff36263ad1eb97a2c5ed41edbc5bf4bb49eff0891f924cafec331d647b1

Contents?: true

Size: 645 Bytes

Versions: 3

Compression:

Stored size: 645 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # This module encapsulates the logic for autocorrect behavior for a cop.
    module AutocorrectLogic
      def autocorrect?
        autocorrect_requested? && support_autocorrect? && autocorrect_enabled?
      end

      def autocorrect_requested?
        @options.fetch(:auto_correct, false)
      end

      def support_autocorrect?
        respond_to?(:autocorrect)
      end

      def autocorrect_enabled?
        # allow turning off autocorrect on a cop by cop basis
        return true unless cop_config

        cop_config['AutoCorrect'] != false
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-0.59.2 lib/rubocop/cop/autocorrect_logic.rb
rubocop-0.59.1 lib/rubocop/cop/autocorrect_logic.rb
rubocop-0.59.0 lib/rubocop/cop/autocorrect_logic.rb