flog 4.6.6 → 4.7.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: a6889c4ee131417e7461cd689e54af4a037d36ee3a854e037c9e453e7a19dee0
4
- data.tar.gz: ee5fc40d4423a82b4b48db87b9bd02fac8006f4b5ac6e6f4701005a82412b451
3
+ metadata.gz: bde1a28d5e030ce021a8f20e9d7e877714e2c91e030b7560c3da7337a8a1e916
4
+ data.tar.gz: 6b4dffe1d2a47f688deb1665a0a31a4c9ef5b901add108aac37489c97cb8f7ee
5
5
  SHA512:
6
- metadata.gz: a6b0a38246e5869182caf800b6e1bacb4bd442c06746d8aac8c4223528d58bf8c588909689f5424f05de6cfbe1ed97f12d89025fe2d3a2b195ea6508326d8691
7
- data.tar.gz: 485e289aec33bf39a30b8361d42eaec662de13bbca5c72b3058a9f0e31375ce1b55cacb270b00551b671e59f031f9b861af50b03abeb155af4d079d0f325dbbf
6
+ metadata.gz: 56c6a3005252c00d8d61257f35f6eb9bf3d07b232acb316ebf5807dee9144c6bc76f24478ba64a000885677e1ba04d3d0af5ad8677934f90a5f8a965a2227f87
7
+ data.tar.gz: 876c48e4a05cf087fb924f5c10977870facdec0f07c3cabd09eccee03360fca82d19a3b5a708e2a9bd51cd57f109d525b29cc50d22399fac17df3062b0d3c272
checksums.yaml.gz.sig CHANGED
@@ -1 +1 @@
1
- ��c��A﷿PMt���w���?��胠�ov_:O4kDM�����1��2 ����e��(��˙�������D���l�=!ڡ��\G�_����veÙ��3��|����L�\�PU�̪;z���RoUI9l{�E۳I���6�l���#>�7��r��h�`�/2Ё�;@�2O�}N�@3Q����.-Ԡ�n~jk;[`�Wp���/İ`�T�1����,4e$�t��0�z'��fGHL"�
1
+ -�2�\��*��&�+��)� ������C���fY�v��B��g `\5; K��M�'O+������ �ns�{Je�.�dw�q{h����g� �~*������;� ���/�/ɄD�)X#�pzo��δ(������\��w���$n��zG3>3_\f�$ǘ.y��ymaeȽɰ YGW���:�>.�r�k�yh�M(���Y:�1�P��6�j��OP�/ ����i� ���~HS0L�
data/History.rdoc CHANGED
@@ -1,3 +1,11 @@
1
+ === 4.7.0 / 2023-07-18
2
+
3
+ * 3 minor enhancements:
4
+
5
+ * Extend flog to process complex numbers. (petergoldstein)
6
+ * Only penalize magic numbers if they're not assigned to a const (excludes 0/-1).
7
+ * Renamed :lit_fixnum to :magic_number.
8
+
1
9
  === 4.6.6 / 2022-07-03
2
10
 
3
11
  * 1 minor enhancement:
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.6" # :nodoc:
14
+ VERSION = "4.7.0" # :nodoc:
15
15
 
16
16
  ##
17
17
  # Cut off point where the report should stop unless --all given.
@@ -40,7 +40,7 @@ class Flog < MethodBasedSexpProcessor
40
40
  :block_pass => 1,
41
41
  :block_call => 1,
42
42
  :branch => 1,
43
- :lit_fixnum => 0.25,
43
+ :magic_number => 0.25,
44
44
  :sclass => 5,
45
45
  :super => 1,
46
46
  :to_proc_icky! => 10,
@@ -508,9 +508,9 @@ class Flog < MethodBasedSexpProcessor
508
508
  when 0, -1 then
509
509
  # ignore those because they're used as array indicies instead of
510
510
  # first/last
511
- when Integer, Rational then
512
- add_to_score :lit_fixnum
513
- when Float, Symbol, Regexp, Range then
511
+ when Integer, Float, Rational, Complex then
512
+ add_to_score :magic_number unless context[1] == :cdecl
513
+ when Symbol, Regexp, Range then
514
514
  # do nothing
515
515
  else
516
516
  raise "Unhandled lit: #{value.inspect}:#{value.class}"
data/test/test_flog.rb CHANGED
@@ -44,7 +44,7 @@ class TestFlog < FlogTest
44
44
  def test_flog
45
45
  setup_flog
46
46
 
47
- exp = { "main#none" => { :+ => 1.0, :lit_fixnum => 0.6 } }
47
+ exp = { "main#none" => { :+ => 1.0, :magic_number => 0.6 } }
48
48
  assert_equal exp, @flog.calls
49
49
 
50
50
  assert_in_epsilon 1.6, @flog.total_score unless @flog.option[:methods]
@@ -58,7 +58,7 @@ class TestFlog < FlogTest
58
58
  @flog.flog_ruby ruby, file
59
59
  @flog.calculate_total_scores
60
60
 
61
- exp = { "main#none" => { :+ => 1.0, :lit_fixnum => 0.6 } }
61
+ exp = { "main#none" => { :+ => 1.0, :magic_number => 0.6 } }
62
62
  assert_equal exp, @flog.calls
63
63
 
64
64
  assert_in_epsilon 1.6, @flog.total_score unless @flog.option[:methods]
@@ -173,7 +173,7 @@ class TestFlog < FlogTest
173
173
  s(:iter, s(:call, nil, :lambda), nil, s(:lit, 1)))
174
174
 
175
175
  assert_process(sexp, 12.316,
176
- :lit_fixnum => 0.275,
176
+ :magic_number => 0.275,
177
177
  :block_pass => 1.0,
178
178
  :lambda => 1.0,
179
179
  :block_call => 1.0,
@@ -187,7 +187,7 @@ class TestFlog < FlogTest
187
187
  s(:iter, s(:call, nil, :lambda), nil, s(:lit, 1))))
188
188
 
189
189
  assert_process(sexp, 17.333,
190
- :lit_fixnum => 0.275,
190
+ :magic_number => 0.275,
191
191
  :block_pass => 1.0,
192
192
  :lambda => 1.0,
193
193
  :assignment => 1.0,
@@ -250,7 +250,7 @@ class TestFlog < FlogTest
250
250
  s(:colon2, s(:const, :X), :Y), nil,
251
251
  s(:scope, s(:lit, 42)))
252
252
 
253
- assert_process sexp, 0.25, :lit_fixnum => 0.25
253
+ assert_process sexp, 0.25, :magic_number => 0.25
254
254
  end
255
255
 
256
256
  # TODO:
@@ -275,7 +275,7 @@ class TestFlog < FlogTest
275
275
  s(:block,
276
276
  s(:lit, 42))))
277
277
 
278
- assert_process sexp, 0.275, :lit_fixnum => 0.275
278
+ assert_process sexp, 0.275, :magic_number => 0.275
279
279
  end
280
280
 
281
281
  def test_process_defn_in_self
@@ -288,7 +288,7 @@ class TestFlog < FlogTest
288
288
  @flog.process sexp
289
289
  @flog.calculate_total_scores
290
290
 
291
- exp = {'main::x' => {:lit_fixnum => 0.375}, 'main#none' => {:sclass => 5.0}}
291
+ exp = {'main::x' => {:magic_number => 0.375}, 'main#none' => {:sclass => 5.0}}
292
292
  assert_equal exp, @flog.calls
293
293
 
294
294
  assert_in_delta 5.375, @flog.total_score
@@ -305,7 +305,7 @@ class TestFlog < FlogTest
305
305
  @flog.process sexp
306
306
  @flog.calculate_total_scores
307
307
 
308
- exp = {'main::x' => {:lit_fixnum => 0.375}, 'main#none' => {:sclass => 12.5}}
308
+ exp = {'main::x' => {:magic_number => 0.375}, 'main#none' => {:sclass => 12.5}}
309
309
  assert_equal exp, @flog.calls
310
310
 
311
311
  assert_in_delta 12.875, @flog.total_score
@@ -320,7 +320,7 @@ class TestFlog < FlogTest
320
320
  s(:block,
321
321
  s(:lit, 42))))
322
322
 
323
- assert_process sexp, 0.275, :lit_fixnum => 0.275
323
+ assert_process sexp, 0.275, :magic_number => 0.275
324
324
  end
325
325
 
326
326
  # FIX: huh? over-refactored?
@@ -386,7 +386,7 @@ class TestFlog < FlogTest
386
386
 
387
387
  @klass, @meth = "task", "#woot"
388
388
 
389
- assert_process sexp, 2.3, :something => 1.0, :task => 1.0, :lit_fixnum => 0.3
389
+ assert_process sexp, 2.3, :something => 1.0, :task => 1.0, :magic_number => 0.3
390
390
  end
391
391
 
392
392
  def test_process_iter_dsl_hash_when_hash_empty
@@ -423,7 +423,7 @@ class TestFlog < FlogTest
423
423
  hash = {
424
424
  "namespace(blah)::task#woot" => {
425
425
  :something => 1.0,
426
- :lit_fixnum => 0.3,
426
+ :magic_number => 0.3,
427
427
  :task => 1.0,
428
428
  },
429
429
  "namespace#blah" => {
@@ -446,14 +446,29 @@ class TestFlog < FlogTest
446
446
 
447
447
  def test_process_lit_int
448
448
  sexp = s(:lit, 42)
449
- assert_process sexp, 0.25, :lit_fixnum => 0.25
449
+ assert_process sexp, 0.25, :magic_number => 0.25
450
+ end
451
+
452
+ def test_process_lit_int__const
453
+ sexp = s(:cdecl, :X, s(:lit, 42))
454
+ assert_process sexp, 0.0
450
455
  end
451
456
 
452
457
  def test_process_lit_float # and other lits
453
- sexp = s(:lit, 3.1415) # TODO: consider penalizing floats if not in cdecl
458
+ sexp = s(:lit, 3.1415)
459
+ assert_process sexp, 0.25, :magic_number => 0.25
460
+ end
461
+
462
+ def test_process_lit_float__const
463
+ sexp = s(:cdecl, :X, s(:lit, 3.1415))
454
464
  assert_process sexp, 0.0
455
465
  end
456
466
 
467
+ def test_process_lit_complex
468
+ sexp = s(:lit, (0+1i))
469
+ assert_process sexp, 0.25
470
+ end
471
+
457
472
  def test_process_lit_bad
458
473
  assert_raises RuntimeError do
459
474
  @flog.process s(:lit, Object.new)
@@ -475,12 +490,12 @@ class TestFlog < FlogTest
475
490
  s(:colon2, s(:const, :X), :Y),
476
491
  s(:scope, s(:lit, 42)))
477
492
 
478
- assert_process sexp, 0.25, :lit_fixnum => 0.25
493
+ assert_process sexp, 0.25, :magic_number => 0.25
479
494
  end
480
495
 
481
496
  def test_process_sclass
482
497
  sexp = s(:sclass, s(:self), s(:scope, s(:lit, 42)))
483
- assert_process sexp, 5.375, :sclass => 5.0, :lit_fixnum => 0.375
498
+ assert_process sexp, 5.375, :sclass => 5.0, :magic_number => 0.375
484
499
  end
485
500
 
486
501
  def test_process_super
@@ -488,7 +503,7 @@ class TestFlog < FlogTest
488
503
  assert_process sexp, 1.0, :super => 1.0
489
504
 
490
505
  sexp = s(:super, s(:lit, 42))
491
- assert_process sexp, 1.25, :super => 1.0, :lit_fixnum => 0.25
506
+ assert_process sexp, 1.25, :super => 1.0, :magic_number => 0.25
492
507
  end
493
508
 
494
509
  def test_process_while
@@ -505,10 +520,10 @@ class TestFlog < FlogTest
505
520
  assert_process sexp, 1.00, :yield => 1.0
506
521
 
507
522
  sexp = s(:yield, s(:lit, 4))
508
- assert_process sexp, 1.25, :yield => 1.0, :lit_fixnum => 0.25
523
+ assert_process sexp, 1.25, :yield => 1.0, :magic_number => 0.25
509
524
 
510
525
  sexp = s(:yield, s(:lit, 42), s(:lit, 24))
511
- assert_process sexp, 1.50, :yield => 1.0, :lit_fixnum => 0.50
526
+ assert_process sexp, 1.50, :yield => 1.0, :magic_number => 0.50
512
527
  end
513
528
 
514
529
  def test_score_method
@@ -617,7 +632,7 @@ class TestFlog < FlogTest
617
632
  @flog.calculate_total_scores
618
633
  @flog.calculate
619
634
 
620
- assert_equal({ 'User#blah' => 'user.rb:3-4' }, @flog.method_locations)
635
+ assert_equal({ 'User#blah' => 'user.rb:3-5' }, @flog.method_locations)
621
636
  assert_equal({ "User#blah" => 2.2 }, @flog.totals)
622
637
  assert_in_epsilon(2.2, @flog.total_score)
623
638
  assert_in_epsilon(1.0, @flog.multiplier)
@@ -639,7 +654,7 @@ class TestFlog < FlogTest
639
654
  @flog.calculate_total_scores
640
655
  @flog.calculate
641
656
 
642
- assert_equal({ 'Coder#happy?' => 'coder.rb:3-4' }, @flog.method_locations)
657
+ assert_equal({ 'Coder#happy?' => 'coder.rb:3-5' }, @flog.method_locations)
643
658
  assert_equal({ "Coder#happy?" => 1.0 }, @flog.totals)
644
659
  assert_in_epsilon(1.0, @flog.total_score)
645
660
  assert_in_epsilon(1.0, @flog.multiplier)
@@ -135,7 +135,7 @@ class TestFlogCLI < FlogTest
135
135
 
136
136
  expected = "\n 1.6: main#none
137
137
  1.0: +
138
- 0.6: lit_fixnum
138
+ 0.6: magic_number
139
139
 
140
140
  "
141
141
 
@@ -165,7 +165,7 @@ class TestFlogCLI < FlogTest
165
165
 
166
166
  @flog.flog "-"
167
167
 
168
- exp = { "main#none" => { :+ => 1.0, :lit_fixnum => 0.6 } }
168
+ exp = { "main#none" => { :+ => 1.0, :magic_number => 0.6 } }
169
169
  assert_equal exp, @flog.calls
170
170
 
171
171
  @flog.option[:all] = true
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.6
4
+ version: 4.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBBjANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBBzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTIxMTIyMzIzMTkwNFoXDTIyMTIyMzIzMTkwNFowRTETMBEGA1UE
15
+ GRYDY29tMB4XDTIzMDEwMTA3NTExN1oXDTI0MDEwMTA3NTExN1owRTETMBEGA1UE
16
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
18
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -22,14 +22,14 @@ cert_chain:
22
22
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
23
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
24
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
25
- AQCKB5jfsuSnKb+t/Wrh3UpdkmX7TrEsjVmERC0pPqzQ5GQJgmEXDD7oMgaKXaAq
26
- x2m+KSZDrqk7c8uho5OX6YMqg4KdxehfSLqqTZGoeV78qwf/jpPQZKTf+W9gUSJh
27
- zsWpo4K50MP+QtdSbKXZwjAafpQ8hK0MnnZ/aeCsW9ov5vdXpYbf3dpg6ADXRGE7
28
- lQY2y1tJ5/chqu6h7dQmnm2ABUqx9O+JcN9hbCYoA5i/EeubUEtFIh2w3SpO6YfB
29
- JFmxn4h9YO/pVdB962BdBNNDia0kgIjI3ENnkLq0dKpYU3+F3KhEuTksLO0L6X/V
30
- YsuyUzsMz6GQA4khyaMgKNSD
25
+ AQAkg3y+PBnBAPWdxxITm5sPHqdWQgSyCpRA20o4LTuWr8BWhSXBkfQNa7cY6fOn
26
+ xyM34VPzBFbExv6XOGDfOMFBVaYTHuN9peC/5/umL7kLl+nflXzL2QA7K6LYj5Bg
27
+ sM574Onr0dZDM6Vn69bzQ7rBIFDfK/OhlPzqKZad4nsdcsVH8ODCiT+ATMIZyz5K
28
+ WCnNtqlyiWXI8tdTpahDgcUwfcN/oN7v4K8iU5IbLJX6HQ5DKgmKjfb6XyMth16k
29
+ ROfWo9Uyp8ba/j9eVG14KkYRaLydAY1MNQk2yd3R5CGfeOpD1kttxjoypoUJ2dOG
30
+ nsNBRuQJ1UfiCG97a6DNm+Fr
31
31
  -----END CERTIFICATE-----
32
- date: 2022-07-04 00:00:00.000000000 Z
32
+ date: 2023-07-18 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.24'
122
+ version: '4.0'
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.24'
129
+ version: '4.0'
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.12
178
+ rubygems_version: 3.4.10
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
@@ -1,2 +1 @@
1
- �|�f(��U��z{|��-4¡��&�/w*���TL�Ai'�(T��]�:��F���Y[R�����@����]Lɵ�AF0%_�4�����|��O���6Q%`; d��/K$&�*��|�5Ͻ�i��Mג$VG���S.xq�<��B���WZG�����D���
2
- �Y�<��.�qEN�c���j��&��������D��P�H��f�1ɤ I�[����t�B]����y�#��ؙMK�ӷl�J�>P�7�
1
+ a���M�˒zlm�e��h��ᱣ�{(�8C���m��lJ%(ߞ%��J�#�دW(�{u`B��ĩ�o7�<q�Nr��D���"�q