Skip to content

Commit

Permalink
Merge pull request #41 from tleish/inclusive_check_symbol_to_proc
Browse files Browse the repository at this point in the history
More inclusive check_symbol_to_proc rule which fixes #40
  • Loading branch information
DamirSvrtan authored Sep 22, 2019
2 parents 34c976d + 4bf6fb2 commit 42e5bf2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/fasterer/scanners/method_call_scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def check_offense
when :include?
check_range_include_offense
end

check_symbol_to_proc
end

def check_module_eval_offense
Expand Down Expand Up @@ -98,8 +100,6 @@ def check_each_offense
when :keys
add_offense(:keys_each_vs_each_key)
end

check_symbol_to_proc
end

def check_flatten_offense
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/fasterer/analyzer/18_block_vs_symbol_to_proc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
describe Fasterer::Analyzer do
let(:test_file_path) { RSpec.root.join('support', 'analyzer', '18_block_vs_symbol_to_proc.rb') }

it 'should block that could be called with symbol 2 times' do
it 'should block that could be called with symbol 6 times' do
analyzer = Fasterer::Analyzer.new(test_file_path)
analyzer.scan
expect(analyzer.errors[:block_vs_symbol_to_proc].count).to eq(2)
expect(analyzer.errors[:block_vs_symbol_to_proc].count).to eq(6)
end
end
6 changes: 6 additions & 0 deletions spec/support/analyzer/18_block_vs_symbol_to_proc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@
end

route_sets.each { |routes| routes.finalize! }

numbers = [1, 2, 3, 4, 5]
numbers.each { |number| number.to_s }
numbers.map { |number| number.to_s }
numbers.any? { |number| number.even? }
numbers.find { |number| number.even? }

0 comments on commit 42e5bf2

Please sign in to comment.