fasterer 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/fasterer/method_call.rb +4 -0
- data/lib/fasterer/scanners/method_call_scanner.rb +1 -0
- data/lib/fasterer/version.rb +1 -1
- data/spec/lib/fasterer/analyzer/18_block_vs_symbol_to_proc_spec.rb +2 -2
- data/spec/lib/fasterer/method_call_spec.rb +32 -0
- data/spec/support/analyzer/18_block_vs_symbol_to_proc.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28c6c74caee7d7576f7a00820dec13feafe2390f9f77a33082ca5b719e578a52
|
4
|
+
data.tar.gz: 1c881f931ec753084298dd7d44683b55240ac9634a43a704c669768faf73f879
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 920deaa8486e29b496df8578ac413eba4a2ca53fc881997b314f9904609a0c873665ab1906303889190cee2df6a5082f1324f7b3d765d81319f08ed61ff63532
|
7
|
+
data.tar.gz: b5113178addac93ccfc0fdbec2db93651f711d4fa6355eac302d34f4183b9462f05e22268ea5b1fbca8c8c84e198b6cee2364f2bd0900414d52db79939046daa
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.8.1
|
4
|
+
|
5
|
+
- Ignore lambda literals when checking symbol to proc. Thanks to [kiyot](https://github.com/kiyot) for his fix in PR [#74](https://github.com/DamirSvrtan/fasterer/pull/74).
|
6
|
+
|
3
7
|
## 0.8.0
|
4
8
|
|
5
9
|
- Dropped support for ruby versions below 2.2.0 and locks ruby_parser to be above or equal to 1.14.1. The new ruby_parser version 1.14.1 explicitly [requires ruby versions above 2.2.0](https://github.com/seattlerb/ruby_parser/issues/298#issuecomment-539795933), so this affects fasterer as well.
|
data/lib/fasterer/method_call.rb
CHANGED
@@ -125,6 +125,7 @@ module Fasterer
|
|
125
125
|
return if method_call.block_body.nil?
|
126
126
|
return unless method_call.block_body.sexp_type == :call
|
127
127
|
return if method_call.arguments.count > 0
|
128
|
+
return if method_call.lambda_literal?
|
128
129
|
|
129
130
|
body_method_call = MethodCall.new(method_call.block_body)
|
130
131
|
|
data/lib/fasterer/version.rb
CHANGED
@@ -3,9 +3,9 @@ require 'spec_helper'
|
|
3
3
|
describe Fasterer::Analyzer do
|
4
4
|
let(:test_file_path) { RSpec.root.join('support', 'analyzer', '18_block_vs_symbol_to_proc.rb') }
|
5
5
|
|
6
|
-
it 'should block that could be called with symbol
|
6
|
+
it 'should block that could be called with symbol 9 times' do
|
7
7
|
analyzer = Fasterer::Analyzer.new(test_file_path)
|
8
8
|
analyzer.scan
|
9
|
-
expect(analyzer.errors[:block_vs_symbol_to_proc].count).to eq(
|
9
|
+
expect(analyzer.errors[:block_vs_symbol_to_proc].count).to eq(9)
|
10
10
|
end
|
11
11
|
end
|
@@ -437,4 +437,36 @@ describe Fasterer::MethodCall do
|
|
437
437
|
# expect(method_call.receiver.name).to eq('hi')
|
438
438
|
end
|
439
439
|
end
|
440
|
+
|
441
|
+
describe '#lambda_literal?' do
|
442
|
+
describe 'lambda literal without arguments' do
|
443
|
+
let(:code) { '-> {}' }
|
444
|
+
|
445
|
+
let(:call_element) { ripper }
|
446
|
+
|
447
|
+
it 'should be true' do
|
448
|
+
expect(method_call).to be_lambda_literal
|
449
|
+
end
|
450
|
+
end
|
451
|
+
|
452
|
+
describe 'lambda literal with an argument' do
|
453
|
+
let(:code) { '->(_) {}' }
|
454
|
+
|
455
|
+
let(:call_element) { ripper }
|
456
|
+
|
457
|
+
it 'should be true' do
|
458
|
+
expect(method_call).to be_lambda_literal
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
describe 'lambda method' do
|
463
|
+
let(:code) { 'lambda {}' }
|
464
|
+
|
465
|
+
let(:call_element) { ripper }
|
466
|
+
|
467
|
+
it 'should be false' do
|
468
|
+
expect(method_call).not_to be_lambda_literal
|
469
|
+
end
|
470
|
+
end
|
471
|
+
end
|
440
472
|
end
|
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.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damir Svrtan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|