Sha256: c15baff289f6398b77a999d1beaabf0a7bd6810279319934b2242d6bad492659

Contents?: true

Size: 555 Bytes

Versions: 9

Compression:

Stored size: 555 Bytes

Contents

# encoding: utf-8

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
      def safe_assignment?(node)
        node.type == :begin && node.children.size == 1 &&
          Util::EQUALS_ASGN_NODES.include?(node.children[0].type)
      end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rubocop-0.22.0 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.21.0 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.20.1 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.20.0 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.19.1 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.19.0 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.18.1 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.18.0 lib/rubocop/cop/mixin/safe_assignment.rb
rubocop-0.17.0 lib/rubocop/cop/mixin/safe_assignment.rb