fasterer 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fasterer/method_call.rb +4 -5
- data/lib/fasterer/scanners/method_call_scanner.rb +2 -0
- data/lib/fasterer/version.rb +1 -1
- data/spec/lib/fasterer/analyzer/12_select_first_vs_detect_spec.rb +1 -1
- data/spec/lib/fasterer/method_call_spec.rb +13 -0
- data/spec/support/analyzer/12_select_first_vs_detect.rb +4 -0
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 917099eee3733d73079d7cb3add928d81880351e
|
4
|
+
data.tar.gz: 8de26edcf41f8919a38dc34d16f16d796f57ca2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9db9bedccb3ffb027fdfce9dade3ca0ef33cd114e25c23f46491afb2bda5db1ef3af7b0e35655472a0219f4aef46acfd7545ff1270c22be23f189bc0d0662a34
|
7
|
+
data.tar.gz: a71ed2ece3272ec0c027b9fc2b1f625a7406073a99284b4ed2c940b96b7b9f7813b8157a65625657531bfc656f527453627c894040cb1d9c8bc0191e67b1e98f
|
data/lib/fasterer/method_call.rb
CHANGED
@@ -58,7 +58,7 @@ module Fasterer
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def set_block_presence
|
61
|
-
if element.sexp_type == :iter
|
61
|
+
if element.sexp_type == :iter || (arguments.last && arguments.last.type == :block_pass)
|
62
62
|
@block_present = true
|
63
63
|
end
|
64
64
|
end
|
@@ -71,9 +71,9 @@ module Fasterer
|
|
71
71
|
|
72
72
|
# TODO: write specs for lambdas and procs
|
73
73
|
def set_block_argument_names
|
74
|
-
@block_argument_names = if has_block?
|
75
|
-
|
76
|
-
|
74
|
+
@block_argument_names = if has_block? && element[2].is_a?(Sexp) # hack for lambdas
|
75
|
+
element[2].drop(1).map { |argument| argument }
|
76
|
+
end || []
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -102,7 +102,6 @@ module Fasterer
|
|
102
102
|
end
|
103
103
|
|
104
104
|
class Argument
|
105
|
-
|
106
105
|
attr_reader :element
|
107
106
|
|
108
107
|
def initialize(element)
|
data/lib/fasterer/version.rb
CHANGED
@@ -7,6 +7,6 @@ describe Fasterer::Analyzer do
|
|
7
7
|
it 'should detect sort once' do
|
8
8
|
analyzer = Fasterer::Analyzer.new(test_file_path)
|
9
9
|
analyzer.scan
|
10
|
-
expect(analyzer.errors[:select_first_vs_detect].count).to eq(
|
10
|
+
expect(analyzer.errors[:select_first_vs_detect].count).to eq(3)
|
11
11
|
end
|
12
12
|
end
|
@@ -466,6 +466,19 @@ describe Fasterer::MethodCall do
|
|
466
466
|
|
467
467
|
end
|
468
468
|
|
469
|
+
describe 'method call with symbol to proc argument' do
|
470
|
+
let(:code) { '[].select(&:zero?)' }
|
471
|
+
|
472
|
+
let(:call_element) { ripper }
|
473
|
+
|
474
|
+
it 'should detect block pass argument' do
|
475
|
+
expect(method_call.method_name).to eq(:select)
|
476
|
+
expect(method_call.arguments.count).to eq(1)
|
477
|
+
expect(method_call.arguments[0].type).to eq(:block_pass)
|
478
|
+
expect(method_call.has_block?).to be
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
469
482
|
describe 'method call with equals operator' do
|
470
483
|
|
471
484
|
let(:code) { 'method_call_with_equals.rb' }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fasterer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damir Svrtan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04
|
11
|
+
date: 2015-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -321,4 +321,3 @@ test_files:
|
|
321
321
|
- spec/support/rescue_call/rescue_with_multiple_classes.rb
|
322
322
|
- spec/support/rescue_call/rescue_with_multiple_classes_and_variable.rb
|
323
323
|
- spec/support/rescue_call/rescue_with_variable.rb
|
324
|
-
has_rdoc:
|