fasterer 0.10.1 → 0.11.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: e46a30495d54b2fcb1f00a51b51f478e5682daa910b7adbcaeeb5930e2732f76
4
- data.tar.gz: d661217d42400a65a5ed2344dfe4b1f77ee2583c36d372833fa67c5ef7643b2a
3
+ metadata.gz: 411b46cc87653ad7048d611491cfd10eb2662ce06e35ae4e78b0b12400ba1386
4
+ data.tar.gz: c036629c9e46b9be35bd77df0a1169b79922bbd70f0f4b17229817273ef3b0ff
5
5
  SHA512:
6
- metadata.gz: 6c5a63b1789705a5f4e40896a4f26e7431e7bc65ccde7b28b353d7bbc6d53a09c320b9cba8c6a802af5d46b9f599048f5025a5d3e91fe922d2905fa35ce0c792
7
- data.tar.gz: 7cc5ec78ca1ea468f48af3793e53cc9f060cdb32a1c1f066790b88401081944f53f24c20024f9d04208c6283e79da77782f5b3a1662746e33f00c205c5a74212
6
+ metadata.gz: 18a1ec6deb132ce4e88b705f56139a3910f0d8a35beece353db71b219f3c51c3af17639cf1ba3788373058bb9eca0f7538a2270d300419a1970465941de2b1c0
7
+ data.tar.gz: 64a1197fedf11ca6c1205c43d8e13cdea940459b67d43be86a60353c458d7df8dc0e6e595f76c2e2859b3994676d79fe21ed607763736a570aded9782eb79b0f
@@ -19,10 +19,10 @@ jobs:
19
19
  runs-on: ubuntu-latest
20
20
  strategy:
21
21
  matrix:
22
- ruby-version: ['2.3.0','2.4.0','2.5.0','2.6.0','2.7.0','3.0.0','3.1.0']
22
+ ruby-version: ['2.5.0','2.6.0','2.7.0','3.0.0','3.1.0','3.2.0']
23
23
 
24
24
  steps:
25
- - uses: actions/checkout@v2
25
+ - uses: actions/checkout@v3
26
26
  - name: Set up Ruby
27
27
  uses: ruby/setup-ruby@v1
28
28
  with:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0
4
+
5
+ - There have been multiple issues filed with the colorize gem, such as licencing, gem versions etc. Due to the easy implementation, fasterer will now leverage an internal implementation of this so we don't need to get issues tracked bc of colorize. There might be other issues that arise (perhaps somebody leveraging Windows might have issues), but that's okay, we'll solve it.
6
+
7
+ - There has been a [bug report #102](https://github.com/DamirSvrtan/fasterer/issues/102) that the Redis `#keys` method shouldn't trigger `Hash#each_key` recommendation. It's not possible to detect that what is the receiver of the keys method call, but the keys method called on the Hash doesn't accept arguments while the redis one does. So not an ideal solution, but should fix any issues for now.
8
+
9
+
3
10
  ## 0.10.1
4
11
 
5
12
  - There has been a [bug report #99](https://github.com/DamirSvrtan/fasterer/issues/99) that the `select_first_vs_detect` reports false positives when first gets an argument passed in. If there is an argument passed in, the detect method is not suitable, since it always returns the first element matching (can't return multiple items).
data/fasterer.gemspec CHANGED
@@ -20,7 +20,6 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = '>= 2.3'
22
22
 
23
- spec.add_dependency 'colorize', '~> 0.7'
24
23
  spec.add_dependency 'ruby_parser', '>= 3.19.1'
25
24
 
26
25
  spec.add_development_dependency 'bundler', '>= 1.6'
@@ -1,9 +1,9 @@
1
1
  require 'pathname'
2
- require 'colorize'
3
2
  require 'English'
4
3
 
5
4
  require_relative 'analyzer'
6
5
  require_relative 'config'
6
+ require_relative 'painter'
7
7
 
8
8
  module Fasterer
9
9
  class FileTraverser
@@ -83,7 +83,7 @@ module Fasterer
83
83
  offenses_grouped_by_type(analyzer).each do |error_group_name, error_occurences|
84
84
  error_occurences.map(&:line_number).each do |line|
85
85
  file_and_line = "#{analyzer.file_path}:#{line}"
86
- print "#{file_and_line.colorize(:red)} #{Fasterer::Offense::EXPLANATIONS[error_group_name]}.\n"
86
+ print "#{Painter.paint(file_and_line, :red)} #{Fasterer::Offense::EXPLANATIONS[error_group_name]}.\n"
87
87
  end
88
88
  end
89
89
 
@@ -112,7 +112,7 @@ module Fasterer
112
112
  end
113
113
 
114
114
  def output_unable_to_find_file(path)
115
- puts "No such file or directory - #{path}".colorize(:red)
115
+ puts Painter.paint("No such file or directory - #{path}", :red)
116
116
  end
117
117
 
118
118
  def ignored_speedups
@@ -150,21 +150,19 @@ module Fasterer
150
150
  end
151
151
 
152
152
  def inspected_files_output
153
- "#{@files_inspected_count} #{pluralize(@files_inspected_count, 'file')} inspected"
154
- .colorize(:green)
153
+ Painter.paint("#{@files_inspected_count} #{pluralize(@files_inspected_count, 'file')} inspected", :green)
155
154
  end
156
155
 
157
156
  def offenses_found_output
158
157
  color = @offenses_found_count.zero? ? :green : :red
159
- "#{@offenses_found_count} #{pluralize(@offenses_found_count, 'offense')} detected"
160
- .colorize(color)
158
+
159
+ Painter.paint("#{@offenses_found_count} #{pluralize(@offenses_found_count, 'offense')} detected", color)
161
160
  end
162
161
 
163
162
  def unparsable_files_output
164
163
  return if @unparsable_files_count.zero?
165
164
 
166
- "#{@unparsable_files_count} unparsable #{pluralize(@unparsable_files_count, 'file')} found"
167
- .colorize(:red)
165
+ Painter.paint("#{@unparsable_files_count} unparsable #{pluralize(@unparsable_files_count, 'file')} found", :red)
168
166
  end
169
167
 
170
168
  def pluralize(n, singular, plural = nil)
@@ -0,0 +1,20 @@
1
+ module Fasterer
2
+ module Painter
3
+ COLOR_CODES = {
4
+ red: 31,
5
+ green: 32,
6
+ }
7
+
8
+ def self.paint(string, color)
9
+ color_code = COLOR_CODES[color.to_sym]
10
+ if color_code.nil?
11
+ raise ArgumentError, "Color #{color} is not supported. Allowed colors are #{COLOR_CODES.keys.join(', ')}"
12
+ end
13
+ paint_with_code(string, color_code)
14
+ end
15
+
16
+ def self.paint_with_code(string, color_code)
17
+ "\e[#{color_code}m#{string}\e[0m"
18
+ end
19
+ end
20
+ end
@@ -99,7 +99,9 @@ module Fasterer
99
99
  when :reverse
100
100
  add_offense(:reverse_each_vs_reverse_each)
101
101
  when :keys
102
- add_offense(:keys_each_vs_each_key)
102
+ if method_call.receiver.arguments.count.zero?
103
+ add_offense(:keys_each_vs_each_key)
104
+ end
103
105
  end
104
106
  end
105
107
 
@@ -1,3 +1,3 @@
1
1
  module Fasterer
2
- VERSION = '0.10.1'
2
+ VERSION = '0.11.0'
3
3
  end
@@ -348,7 +348,7 @@ describe Fasterer::FileTraverser do
348
348
  let(:explanation) { Fasterer::Offense::EXPLANATIONS[:for_loop_vs_each] }
349
349
 
350
350
  it 'should print offense' do
351
- match = "\e[0;31;49m#{test_file_path}:1\e[0m #{explanation}.\n\n"
351
+ match = "\e[31m#{test_file_path}:1\e[0m #{explanation}.\n\n"
352
352
 
353
353
  expect { file_traverser.send(:output, analyzer) }.to output(match).to_stdout
354
354
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fasterer::Statistics do
4
+ let(:traverser_mock) do
5
+ traverser = OpenStruct.new
6
+ traverser.scannable_files = []
7
+ traverser.offenses_total_count = 0
8
+ traverser.parse_error_paths = []
9
+ traverser
10
+ end
11
+
12
+ let(:statistics) { Fasterer::Statistics.new(traverser_mock) }
13
+
14
+ describe 'inspected_files_output' do
15
+ it 'should be green' do
16
+ expect(statistics.inspected_files_output)
17
+ .to eq("\e[32m0 files inspected\e[0m")
18
+ end
19
+ end
20
+ end
@@ -13,3 +13,7 @@ HASH.keys.each do |key|
13
13
  end
14
14
 
15
15
  HASH.each_key(&:to_sym)
16
+
17
+ @redis.keys('queue:*').each do |queue_name|
18
+ puts queue_name
19
+ end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fasterer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.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: 2023-03-14 00:00:00.000000000 Z
11
+ date: 2023-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: colorize
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.7'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.7'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: ruby_parser
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +123,7 @@ files:
137
123
  - lib/fasterer/method_definition.rb
138
124
  - lib/fasterer/offense.rb
139
125
  - lib/fasterer/offense_collector.rb
126
+ - lib/fasterer/painter.rb
140
127
  - lib/fasterer/parser.rb
141
128
  - lib/fasterer/rescue_call.rb
142
129
  - lib/fasterer/scanners/method_call_scanner.rb
@@ -172,6 +159,7 @@ files:
172
159
  - spec/lib/fasterer/method_call_spec.rb
173
160
  - spec/lib/fasterer/method_definition_spec.rb
174
161
  - spec/lib/fasterer/rescue_call_spec.rb
162
+ - spec/lib/fasterer/statistics_spec.rb
175
163
  - spec/spec_helper.rb
176
164
  - spec/support/analyzer/02_rescue_vs_respond_to.rb
177
165
  - spec/support/analyzer/03_module_eval.rb
@@ -279,6 +267,7 @@ test_files:
279
267
  - spec/lib/fasterer/method_call_spec.rb
280
268
  - spec/lib/fasterer/method_definition_spec.rb
281
269
  - spec/lib/fasterer/rescue_call_spec.rb
270
+ - spec/lib/fasterer/statistics_spec.rb
282
271
  - spec/spec_helper.rb
283
272
  - spec/support/analyzer/02_rescue_vs_respond_to.rb
284
273
  - spec/support/analyzer/03_module_eval.rb