fasterer 0.7.1 → 0.9.0

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: 5e99fc2f38833d5224d0e6875dee83fbe221c197fb452e655b20613438408abc
4
- data.tar.gz: b6289e01ed3ecb79819a2f4e59297bd83291ef10ce2b282f74918d7b4c5cf4c7
3
+ metadata.gz: 24d522bf41231bb1eff1b4faf51c4f48215d5c4b6fa2581efec4d75ce19feb1d
4
+ data.tar.gz: 5997ab2be30bb4bc96eca571d29d51f850ceefc722c6dfcbc407478e973d5aa4
5
5
  SHA512:
6
- metadata.gz: bf39d1f39d954b331d81326cff413cd7a65359b123514655639c34bc91e0c5001c8fdd6ed2f317b9f34ecb519af3efb694fdc1cdc99fdeb210d987271ce798aa
7
- data.tar.gz: 5cf1ba87677e9e3bfaa203981052961d0c12b3ea381f2af14bab4471cee7f9e147f0d88b16518d375f543da7e535c8a5883173770e8c32e536874c61a3f831a4
6
+ metadata.gz: f5ad546ff9c4e897789cf2dbfec220a44005668d47e75306a55b936c8171721c6fb207e0b471875fc7ec751ca9744da0f9f129f48edfed8e1d9538598f266690
7
+ data.tar.gz: 48eba96dd7a96967e0c7639b6e0c5d1acf031b4fa39a362a8af182a1481c9d1067e14f4fcd022eebc8ab404af728f351af111ec7ab6a7c30e5c3f46f9b828374
data/.travis.yml CHANGED
@@ -2,23 +2,13 @@ language: ruby
2
2
  before_install:
3
3
  - gem update bundler
4
4
  rvm:
5
- - 1.9.3
6
- - 2.0.0
7
- - 2.1.7
8
5
  - 2.2.3
9
6
  - 2.3.0
10
7
  - 2.4.0
11
8
  - 2.5.0
12
9
  - 2.6.0
10
+ - 2.7.0
11
+ - 3.0.0
13
12
  env:
14
13
  global:
15
14
  secure: MBTxmpWCjrsNKPlOoFwJUMHze3GPMz8YCXQFQG3zJBh3WGNQnz4z91ra/1P/DClyVCxHGSFCOswxCNe4kJ2zAnPyQLqGSinXy9uDpqZQUEdaRoQbPnh4/bguZNSJ429gtTpMdDSNOgQ+Hra2EFnWwHA+rLF6ImksMsu3XGKGxGE=
16
- - CC_TEST_REPORTER_ID=86c5edffe4c38e16cb1467e3220a4f3dfa0a0ac8fa6ee8fddd62e200245f4b77
17
- before_script:
18
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
19
- - chmod +x ./cc-test-reporter
20
- - ./cc-test-reporter before-build
21
- script:
22
- - bundle exec rspec
23
- after_script:
24
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.0
4
+
5
+ - Ruby 3 support! Merged in [#85](https://github.com/DamirSvrtan/fasterer/pull/85), a PR that relaxed Ruby version constraints and added a minor change to support Ruby 3.0. Thanks to [swiknaba](https://github.com/swiknaba).
6
+
7
+ ## 0.8.3
8
+
9
+ - Merged in [#79](https://github.com/DamirSvrtan/fasterer/pull/79), a PR that makes sure the output is green when there are no failures.
10
+
11
+ ## 0.8.2
12
+
13
+ - Fixes [#77](https://github.com/DamirSvrtan/fasterer/issues/77). An error occurs on the symbol to proc check when somebody invokes a method with no arguments on an array or range inside of the inspected block. Seems like a bug in the inspected code, but nevertheless it is a code path we need to support.
14
+
15
+ ## 0.8.1
16
+
17
+ - 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).
18
+
19
+ ## 0.8.0
20
+
21
+ - 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.
22
+
3
23
  ## 0.7.1
4
24
 
5
25
  - Fix `check_symbol_to_proc` rule from crashing when there is no receiver [#67](https://github.com/DamirSvrtan/fasterer/pull/67)
data/README.md CHANGED
@@ -100,6 +100,10 @@ as part of a larger framework.
100
100
  [danger](https://github.com/danger/danger) framework for pull requests
101
101
  on Github, Gitlab, and BitBucket.
102
102
 
103
+ * https://github.com/vk26/action-fasterer
104
+
105
+ Github-action for running fasterer via [reviewdog](https://github.com/reviewdog/reviewdog). Reviewdog provides a way to post review comments in pull requests.
106
+
103
107
  ## Speedups TODO:
104
108
 
105
109
  4. find vs bsearch
data/fasterer.gemspec CHANGED
@@ -18,12 +18,14 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
+ spec.required_ruby_version = '>= 2.2'
22
+
21
23
  spec.add_dependency 'colorize', '~> 0.7'
22
- spec.add_dependency 'ruby_parser', '>= 3.13.0'
24
+ spec.add_dependency 'ruby_parser', '>= 3.14.1'
23
25
 
24
26
  spec.add_development_dependency 'bundler', '>= 1.6'
25
- spec.add_development_dependency 'rake', '~> 10.0'
26
- spec.add_development_dependency 'rspec', '~> 3.2'
27
27
  spec.add_development_dependency 'pry', '~> 0.10'
28
+ spec.add_development_dependency 'rake', '>= 12.3.3'
29
+ spec.add_development_dependency 'rspec', '~> 3.2'
28
30
  spec.add_development_dependency 'simplecov', '~> 0.9'
29
31
  end
@@ -155,12 +155,14 @@ module Fasterer
155
155
  end
156
156
 
157
157
  def offenses_found_output
158
+ color = @offenses_found_count.zero? ? :green : :red
158
159
  "#{@offenses_found_count} #{pluralize(@offenses_found_count, 'offense')} detected"
159
- .colorize(:red)
160
+ .colorize(color)
160
161
  end
161
162
 
162
163
  def unparsable_files_output
163
164
  return if @unparsable_files_count.zero?
165
+
164
166
  "#{@unparsable_files_count} unparsable #{pluralize(@unparsable_files_count, 'file')} found"
165
167
  .colorize(:red)
166
168
  end
@@ -29,7 +29,11 @@ module Fasterer
29
29
  end
30
30
 
31
31
  def arguments_element
32
- call_element[3..-1] || []
32
+ call_element.sexp_body(3) || []
33
+ end
34
+
35
+ def lambda_literal?
36
+ call_element.sexp_type == :lambda
33
37
  end
34
38
 
35
39
  private
@@ -125,13 +125,15 @@ 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
 
131
132
  return unless body_method_call.arguments.count.zero?
132
133
  return if body_method_call.has_block?
133
134
  return if body_method_call.receiver.nil?
134
- return unless body_method_call.receiver.name == method_call.block_argument_names.first
135
+ return if body_method_call.receiver.is_a?(Fasterer::Primitive)
136
+ return if body_method_call.receiver.name != method_call.block_argument_names.first
135
137
 
136
138
  add_offense(:block_vs_symbol_to_proc)
137
139
  end
@@ -1,3 +1,3 @@
1
1
  module Fasterer
2
- VERSION = '0.7.1'
2
+ VERSION = '0.9.0'
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
@@ -330,8 +330,8 @@ describe Fasterer::FileTraverser do
330
330
  let(:file_traverser) { Fasterer::FileTraverser.new('.') }
331
331
 
332
332
  it 'should have errors' do
333
- expect(file_traverser.parse_error_paths)
334
- .to match_array(['user.rb - RubyParser::SyntaxError - unterminated string meets end of file. near line 1: ""'])
333
+ expect(file_traverser.parse_error_paths.first)
334
+ .to start_with('user.rb - RubyParser::SyntaxError - unterminated')
335
335
  end
336
336
  end
337
337
 
@@ -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
@@ -11,6 +11,10 @@ route_sets.each do |route|
11
11
  puts route.name
12
12
  end
13
13
 
14
+ route_sets.each do |routes|
15
+ [].finalize!
16
+ end
17
+
14
18
  route_sets.each(&:finalize!)
15
19
 
16
20
  route_sets.each(:oppa) do |route|
@@ -37,3 +41,7 @@ numbers.find { |number| number.even? }
37
41
 
38
42
  instance_eval { |_| method_call_without_receiver }
39
43
  instance_eval { |object| object.to_s }
44
+
45
+ proc { |rule| rule.should_use_symbol }
46
+ lambda { |rule| rule.should_use_symbol }
47
+ ->(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.7.1
4
+ version: 0.9.0
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-09-30 00:00:00.000000000 Z
11
+ date: 2021-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 3.13.0
33
+ version: 3.14.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 3.13.0
40
+ version: 3.14.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,47 +53,47 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.6'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '0.10'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '0.10'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec
70
+ name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '3.2'
75
+ version: 12.3.3
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '3.2'
82
+ version: 12.3.3
83
83
  - !ruby/object:Gem::Dependency
84
- name: pry
84
+ name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.10'
89
+ version: '3.2'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.10'
96
+ version: '3.2'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: simplecov
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -240,14 +240,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
240
  requirements:
241
241
  - - ">="
242
242
  - !ruby/object:Gem::Version
243
- version: '0'
243
+ version: '2.2'
244
244
  required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  requirements:
246
246
  - - ">="
247
247
  - !ruby/object:Gem::Version
248
248
  version: '0'
249
249
  requirements: []
250
- rubygems_version: 3.0.1
250
+ rubyforge_project:
251
+ rubygems_version: 2.7.6.2
251
252
  signing_key:
252
253
  specification_version: 4
253
254
  summary: Run Ruby more than fast. Fasterer