Sha256: 7b323cc3127269587d41cc8f7bfafac9ab2a79d6a19e627e33e090336ed7ec63

Contents?: true

Size: 640 Bytes

Versions: 2

Compression:

Stored size: 640 Bytes

Contents

# encoding: utf-8

module RuboCop
  module Cop
    # This module encapsulates the logic for autocorrect behaviour 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, true)
      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

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.30.1 lib/rubocop/cop/autocorrect_logic.rb
rubocop-0.30.0 lib/rubocop/cop/autocorrect_logic.rb