Skip to content

Commit

Permalink
Refactor with range_type
Browse files Browse the repository at this point in the history
Follow up #6773.

This PR refactors with `range_type`.
  • Loading branch information
koic authored and bbatsov committed Apr 30, 2019
1 parent 4f05ea4 commit ee7cb90
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 1 addition & 3 deletions lib/rubocop/cop/style/redundant_parentheses.rb
Expand Up @@ -16,8 +16,6 @@ module Style
class RedundantParentheses < Cop
include Parentheses

ALLOWED_LITERALS = %i[irange erange].freeze

def_node_matcher :square_brackets?,
'(send {(send _recv _msg) str array hash} :[] ...)'
def_node_matcher :range_end?, '^^{irange erange}'
Expand Down Expand Up @@ -158,7 +156,7 @@ def only_closing_paren_before_comma?(node)

def disallowed_literal?(begin_node, node)
node.literal? &&
!ALLOWED_LITERALS.include?(node.type) &&
!node.range_type? &&
!raised_to_power_negative_numeric?(begin_node, node)
end

Expand Down
5 changes: 2 additions & 3 deletions lib/rubocop/cop/style/sample.rb
Expand Up @@ -77,10 +77,9 @@ def sample_size(method_args)
end

def sample_size_for_one_arg(arg)
case arg.type
when :erange, :irange
if arg.range_type?
range_size(arg)
when :int
elsif arg.int_type?
[0, -1].include?(arg.to_a.first) ? nil : :unknown
else
:unknown
Expand Down

0 comments on commit ee7cb90

Please sign in to comment.