flog 4.6.5 → 4.6.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57b6b9d470979f410d87a27dd593d85a9c3b526f65bc519d8795a5c0703a7b74
4
- data.tar.gz: 3d0ad63ea53a0e69f3768ef311f981239fe3397d53b7c2514d97cc453f895d88
3
+ metadata.gz: a6889c4ee131417e7461cd689e54af4a037d36ee3a854e037c9e453e7a19dee0
4
+ data.tar.gz: ee5fc40d4423a82b4b48db87b9bd02fac8006f4b5ac6e6f4701005a82412b451
5
5
  SHA512:
6
- metadata.gz: 5615430b290aa01b6fd46b0154fdec668561ec0f0c044807ea09a0373a78b74984ad68504034fd99b75d307128bf4c21e187810aba5165cc257c582bf19b1e8d
7
- data.tar.gz: 7b862060c2c4489cd4e43e38c5be5cdfbc79afc871feee741ada47d1a45d4bd590b2fcc01c0f3982d39ef305d2b76dc7417fbcd67c66bfcad758e6611523f7bb
6
+ metadata.gz: a6b0a38246e5869182caf800b6e1bacb4bd442c06746d8aac8c4223528d58bf8c588909689f5424f05de6cfbe1ed97f12d89025fe2d3a2b195ea6508326d8691
7
+ data.tar.gz: 485e289aec33bf39a30b8361d42eaec662de13bbca5c72b3058a9f0e31375ce1b55cacb270b00551b671e59f031f9b861af50b03abeb155af4d079d0f325dbbf
checksums.yaml.gz.sig CHANGED
@@ -1 +1 @@
1
- �.�![m�0H�;�/�ᐘFt�s��L� vʀ�����F?c�*���lMWĜ��K�ҘM�%F��>a��[T>;4$-_<�S:�m�/祼���I_I}�c����Ȟ��x�r��~~oC���rR��i�:�ס� ���}��f�̞d��[�y/bw D)IF>3Dc3<�M+��qԥ�捌�%n��P( ��-y
1
+ ��c��A﷿PMt���w���?��胠�ov_:O4kDM�����1��2 ����e��(��˙�������D���l�=!ڡ��\G�_����veÙ��3��|����L�\�PU�̪;z���RoUI9�l{�E۳I���6�l���#>�7��r��h�`�/2Ё�;@�2O�}N�@3Q����.-Ԡ�n~j�k;[`�Wp���/İ`�T�1����,4e$�t��0�z'��fGHL"�
data/History.rdoc CHANGED
@@ -1,3 +1,14 @@
1
+ === 4.6.6 / 2022-07-03
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Added support for to_proc w/ hash(?!?). (t-kinoshita)
6
+
7
+ * 2 bug fixes:
8
+
9
+ * Removed to_proc_normal (eg &:sym/call) as benchmarks are much better.
10
+ * ruby3: Fixed anonymous block pass. (prtngn)
11
+
1
12
  === 4.6.5 / 2022-04-09
2
13
 
3
14
  * 1 minor enhancement:
data/Rakefile CHANGED
@@ -54,9 +54,12 @@ task :debug do
54
54
  exit 0
55
55
  end
56
56
  flog.flog file
57
- else
57
+ elsif ruby
58
58
  flog.flog_ruby ruby, "-"
59
59
  flog.calculate_total_scores
60
+ else
61
+ flog.flog
62
+ flog.calculate_total_scores
60
63
  end
61
64
 
62
65
  flog.report
data/lib/flog.rb CHANGED
@@ -11,7 +11,7 @@ class File
11
11
  end
12
12
 
13
13
  class Flog < MethodBasedSexpProcessor
14
- VERSION = "4.6.5" # :nodoc:
14
+ VERSION = "4.6.6" # :nodoc:
15
15
 
16
16
  ##
17
17
  # Cut off point where the report should stop unless --all given.
@@ -45,16 +45,6 @@ class Flog < MethodBasedSexpProcessor
45
45
  :super => 1,
46
46
  :to_proc_icky! => 10,
47
47
  :to_proc_lasgn => 15,
48
- :to_proc_normal => case RUBY_VERSION
49
- when /^1\.8\.7/ then
50
- 2
51
- when /^1\.9/ then
52
- 1.5
53
- when /^[23]\./ then
54
- 1
55
- else
56
- raise "Unhandled version #{RUBY_VERSION}"
57
- end,
58
48
  :yield => 1,
59
49
  }
60
50
 
@@ -176,9 +166,9 @@ class Flog < MethodBasedSexpProcessor
176
166
 
177
167
  def flog(*files)
178
168
  files.each do |file|
179
- next unless file == '-' or File.readable? file
169
+ next unless file == "-" or File.readable? file
180
170
 
181
- ruby = file == '-' ? $stdin.read : File.binread(file)
171
+ ruby = file == "-" ? $stdin.read : File.binread(file)
182
172
 
183
173
  flog_ruby ruby, file
184
174
  end
@@ -199,7 +189,7 @@ class Flog < MethodBasedSexpProcessor
199
189
  q = option[:quiet]
200
190
  if e.inspect =~ /<\%|%\>/ or ruby =~ /<\%|%\>/ then
201
191
  return if q
202
- warn "#{e.inspect} at #{e.backtrace.first(5).join(', ')}"
192
+ warn "#{e.inspect} at #{e.backtrace.first(5).join(", ")}"
203
193
  warn "\n...stupid lemmings and their bad erb templates... skipping"
204
194
  else
205
195
  warn "ERROR: parsing ruby file #{file}" unless q
@@ -365,18 +355,23 @@ class Flog < MethodBasedSexpProcessor
365
355
 
366
356
  add_to_score :block_pass
367
357
 
358
+ return s() unless arg
359
+
368
360
  case arg.sexp_type
369
361
  when :lvar, :dvar, :ivar, :cvar, :self, :const, :colon2, :nil then # f(&b)
370
362
  # do nothing
371
- when :lit, :call then # f(&:b)
372
- add_to_score :to_proc_normal
363
+ when :lit then # f(&:b)
364
+ # do nothing -- this now costs about the same as a block
365
+ when :call then # f(&x.b)
366
+ # do nothing -- I don't like the indirection, but that's already scored
373
367
  when :lasgn then # f(&l=b)
374
368
  add_to_score :to_proc_lasgn
375
- when :iter, :dsym, :dstr, *BRANCHING then # below
369
+ when :iter, :dsym, :dstr, :hash, *BRANCHING then # below
376
370
  # f(&proc { ... })
377
371
  # f(&"#{...}")
378
372
  # f(&:"#{...}")
379
373
  # f(&if ... then ... end") and all other branching forms
374
+ # f(&{ a: 42 }) WHY?!?
380
375
  add_to_score :to_proc_icky!
381
376
  else
382
377
  raise({:block_pass_even_ickier! => arg}.inspect)
data/test/test_flog.rb CHANGED
@@ -127,25 +127,24 @@ class TestFlog < FlogTest
127
127
  assert_process sexp, 1.1, :branch => 1.1 # 10% penalty over process_and
128
128
  end
129
129
 
130
- def test_process_block_pass
130
+ def test_process_block_pass__call
131
131
  sexp = s(:call, nil, :a,
132
132
  s(:block_pass,
133
133
  s(:call, nil, :b)))
134
134
 
135
- bonus = case RUBY_VERSION
136
- when /^1\.8\.7/ then 0.4
137
- when /^1\.9/ then 0.3
138
- when /^[23]\./ then 0.2
139
- else raise "Unhandled version #{RUBY_VERSION}"
140
- end
135
+ assert_process(sexp, 3.4,
136
+ :a => 1.0,
137
+ :block_pass => 1.2,
138
+ :b => 1.2)
139
+ end
141
140
 
142
- bonus += Flog::OTHER_SCORES[:to_proc_normal]
141
+ def test_process_block_pass__to_proc
142
+ sexp = s(:call, nil, :a,
143
+ s(:block_pass, s(:lit, :to_i)))
143
144
 
144
- assert_process(sexp, 3.4 + bonus,
145
+ assert_process(sexp, 2.2,
145
146
  :a => 1.0,
146
- :block_pass => 1.2,
147
- :b => 1.2,
148
- :to_proc_normal => 0.0 + bonus)
147
+ :block_pass => 1.2)
149
148
  end
150
149
 
151
150
  def test_process_block_pass_colon2
@@ -158,6 +157,17 @@ class TestFlog < FlogTest
158
157
  :block_pass => 1.2)
159
158
  end
160
159
 
160
+ def test_process_block_pass__hash_wtf
161
+ sexp = s(:call, nil, :a,
162
+ s(:block_pass,
163
+ s(:hash, s(:lit, :a), s(:lit, :b))))
164
+
165
+ assert_process(sexp, 14.2,
166
+ :a => 1.0,
167
+ :block_pass => 1.2,
168
+ :to_proc_icky! => 12.0)
169
+ end
170
+
161
171
  def test_process_block_pass_iter
162
172
  sexp = s(:block_pass,
163
173
  s(:iter, s(:call, nil, :lambda), nil, s(:lit, 1)))
@@ -185,6 +195,13 @@ class TestFlog < FlogTest
185
195
  :to_proc_lasgn => 15.0)
186
196
  end
187
197
 
198
+ def test_process_block_pass__nil
199
+ sexp = s(:block_pass)
200
+
201
+ assert_process(sexp, 1.0,
202
+ :block_pass => 1.0)
203
+ end
204
+
188
205
  def test_process_call
189
206
  sexp = s(:call, nil, :a) # a
190
207
  assert_process sexp, 1.0, :a => 1.0
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flog
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.5
4
+ version: 4.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -29,7 +29,7 @@ cert_chain:
29
29
  JFmxn4h9YO/pVdB962BdBNNDia0kgIjI3ENnkLq0dKpYU3+F3KhEuTksLO0L6X/V
30
30
  YsuyUzsMz6GQA4khyaMgKNSD
31
31
  -----END CERTIFICATE-----
32
- date: 2022-04-09 00:00:00.000000000 Z
32
+ date: 2022-07-04 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: sexp_processor
@@ -119,14 +119,14 @@ dependencies:
119
119
  requirements:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: '3.23'
122
+ version: '3.24'
123
123
  type: :development
124
124
  prerelease: false
125
125
  version_requirements: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '3.23'
129
+ version: '3.24'
130
130
  description: |-
131
131
  Flog reports the most tortured code in an easy to read pain
132
132
  report. The higher the score, the more pain the code is in.
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0'
177
177
  requirements: []
178
- rubygems_version: 3.3.3
178
+ rubygems_version: 3.3.12
179
179
  signing_key:
180
180
  specification_version: 4
181
181
  summary: Flog reports the most tortured code in an easy to read pain report
metadata.gz.sig CHANGED
Binary file