fasterer 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a1fcdb40e5f8d29edfa1cfd69a7780511a3fb7e8ebefa0ba7898f56aa6d61bb
4
- data.tar.gz: c0cef37051120e096a8dccf733381441e78f8a99423be986610fc89939e218c5
3
+ metadata.gz: 28c6c74caee7d7576f7a00820dec13feafe2390f9f77a33082ca5b719e578a52
4
+ data.tar.gz: 1c881f931ec753084298dd7d44683b55240ac9634a43a704c669768faf73f879
5
5
  SHA512:
6
- metadata.gz: 98c7ee6aeedb799da08d1269035bc4735c1ac45f6cf0cd954e8be8e81807386d7077ab3cc4c133288fdf2155a63818a804884bd31d1fddb5d7c5a39075ccd3b7
7
- data.tar.gz: e6619483f9bfcc63f9753dedf7999f8e697b84dc95043abbdc87cd7b7221fe2c9f2150fb04f879c638abdf31c89a2855df02ce2b2ce89b90888ae7c848d7ab05
6
+ metadata.gz: 920deaa8486e29b496df8578ac413eba4a2ca53fc881997b314f9904609a0c873665ab1906303889190cee2df6a5082f1324f7b3d765d81319f08ed61ff63532
7
+ data.tar.gz: b5113178addac93ccfc0fdbec2db93651f711d4fa6355eac302d34f4183b9462f05e22268ea5b1fbca8c8c84e198b6cee2364f2bd0900414d52db79939046daa
@@ -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.
@@ -32,6 +32,10 @@ module Fasterer
32
32
  call_element[3..-1] || []
33
33
  end
34
34
 
35
+ def lambda_literal?
36
+ call_element.sexp_type == :lambda
37
+ end
38
+
35
39
  private
36
40
 
37
41
  attr_reader :call_element
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Fasterer
2
- VERSION = '0.8.0'
2
+ VERSION = '0.8.1'
3
3
  end
@@ -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 7 times' do
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(7)
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
@@ -37,3 +37,7 @@ numbers.find { |number| number.even? }
37
37
 
38
38
  instance_eval { |_| method_call_without_receiver }
39
39
  instance_eval { |object| object.to_s }
40
+
41
+ proc { |rule| rule.should_use_symbol }
42
+ lambda { |rule| rule.should_use_symbol }
43
+ ->(obj) { obj.cannot_use_symbol }
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.0
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-04 00:00:00.000000000 Z
11
+ date: 2019-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize