Sha256: 095f3bcc4913799f878b7081abc57c4c93001060fb5115664bf81cfa39f152c7

Contents?: true

Size: 609 Bytes

Versions: 12

Compression:

Stored size: 609 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # Common functionality for safe assignment. By safe assignment we mean
    # putting parentheses around an assignment to indicate "I know I'm using an
    # assignment as a condition. It's not a mistake."
    module SafeAssignment
      extend NodePattern::Macros

      private

      def_node_matcher :empty_condition?, '(begin)'
      def_node_matcher :safe_assignment?,
                       '(begin {equals_asgn? asgn_method_call?})'

      def safe_assignment_allowed?
        cop_config['AllowSafeAssignment']
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
rubocop-0.58.2 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.58.1 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.58.0 lib/rubocop/cop/mixin/safe_assignment.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rubocop-0.57.2/lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.57.2 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.57.1 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.57.0 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.56.0 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.55.0 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.54.0 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.53.0 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.52.1 lib/rubocop/cop/mixin/safe_assignment.rb