Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Aug 1, 2020
1 parent 14c729b commit bf972d3
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 34 deletions.
6 changes: 2 additions & 4 deletions lib/rubocop/ast/node/case_match_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ def keyword
end

# @deprecated Use `in_pattern_branches.each`
def each_in_pattern
def each_in_pattern(&block)
return in_pattern_branches.to_enum(__method__) unless block_given?

in_pattern_branches.each do |condition|
yield condition
end
in_pattern_branches.each(&block)

self
end
Expand Down
6 changes: 2 additions & 4 deletions lib/rubocop/ast/node/case_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ def keyword
end

# @deprecated Use `when_branches.each`
def each_when
def each_when(&block)
return when_branches.to_enum(__method__) unless block_given?

when_branches.each do |condition|
yield condition
end
when_branches.each(&block)

self
end
Expand Down
12 changes: 4 additions & 8 deletions lib/rubocop/ast/node/hash_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ def keys
#
# @return [self] if a block is given
# @return [Enumerator] if no block is given
def each_key
def each_key(&block)
return pairs.map(&:key).to_enum unless block_given?

pairs.map(&:key).each do |key|
yield key
end
pairs.map(&:key).each(&block)

self
end
Expand All @@ -82,12 +80,10 @@ def values
#
# @return [self] if a block is given
# @return [Enumerator] if no block is given
def each_value
def each_value(&block)
return pairs.map(&:value).to_enum unless block_given?

pairs.map(&:value).each do |value|
yield value
end
pairs.map(&:value).each(&block)

self
end
Expand Down
6 changes: 2 additions & 4 deletions lib/rubocop/ast/node/if_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,10 @@ def branches
end

# @deprecated Use `branches.each`
def each_branch
def each_branch(&block)
return branches.to_enum(__method__) unless block_given?

branches.each do |branch|
yield branch
end
branches.each(&block)
end
end
end
Expand Down
6 changes: 2 additions & 4 deletions lib/rubocop/ast/node/when_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ def conditions
end

# @deprecated Use `conditions.each`
def each_condition
def each_condition(&block)
return conditions.to_enum(__method__) unless block_given?

conditions.each do |condition|
yield condition
end
conditions.each(&block)

self
end
Expand Down
2 changes: 0 additions & 2 deletions lib/rubocop/ast/node_pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ def compile_ellipsis
[0..Float::INFINITY, 'true']
end

# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
def compile_any_order(capture_all = nil)
rest = capture_rest = nil
Expand All @@ -475,7 +474,6 @@ def compile_any_order(capture_all = nil)
end
end
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/AbcSize

def insure_same_captures(enum, what)
return to_enum __method__, enum, what unless block_given?
Expand Down
16 changes: 8 additions & 8 deletions lib/rubocop/ast/processed_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,23 @@ def checksum
end

# @deprecated Use `comments.each`
def each_comment
comments.each { |comment| yield comment }
def each_comment(&block)
comments.each(&block)
end

# @deprecated Use `comments.find`
def find_comment
comments.find { |comment| yield comment }
def find_comment(&block)
comments.find(&block)
end

# @deprecated Use `tokens.each`
def each_token
tokens.each { |token| yield token }
def each_token(&block)
tokens.each(&block)
end

# @deprecated Use `tokens.find`
def find_token
tokens.find { |token| yield token }
def find_token(&block)
tokens.find(&block)
end

def file_path
Expand Down
1 change: 1 addition & 0 deletions spec/rubocop/ast/node_pattern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,7 @@ def instance.some_function(node, arg)
describe 'funcalls' do
module RuboCop
module AST
# Add test function calls
class NodePattern
def goodmatch(_foo)
true
Expand Down
1 change: 1 addition & 0 deletions spec/rubocop/ast/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
before :all do
module RuboCop
module AST
# Patch Node
class Node
# Let's make our predicate matchers read better
def used?
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
let(:ruby_version) { 2.7 }
end

# ...
module DefaultRubyVersion
extend RSpec::SharedContext

let(:ruby_version) { 2.4 }
end

# ...
module ParseSourceHelper
def parse_source(source)
RuboCop::AST::ProcessedSource.new(source, ruby_version, nil)
Expand Down

0 comments on commit bf972d3

Please sign in to comment.