flog 4.6.2 → 4.6.5

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: b0fc313dc7f3892e2ac94b838dc0b6aeaf7930e7594f182a0ddebec2c540da7b
4
- data.tar.gz: 663fc807ac517de1f01a6ac633b0a76b3a4a8f70590a2bdc76d09d0c2ef0ef5e
3
+ metadata.gz: 57b6b9d470979f410d87a27dd593d85a9c3b526f65bc519d8795a5c0703a7b74
4
+ data.tar.gz: 3d0ad63ea53a0e69f3768ef311f981239fe3397d53b7c2514d97cc453f895d88
5
5
  SHA512:
6
- metadata.gz: 7c18ca2c0517e1d9d0b618216d6385fbe1c7e28e9f10bd64455e0c70b68424a9e74f8aebe98e6487486a6d50550acf5d2210fc87378f54073e7db8d918acd398
7
- data.tar.gz: 0a19ae61b73cb0f91ccbf245aeb2853e27f0765fc10586f1b6b333e71e3d97534a030a30c68a169f2a1f4e15d1433edb3c84b07cfb5ec19d1f4845f62bce8b6a
6
+ metadata.gz: 5615430b290aa01b6fd46b0154fdec668561ec0f0c044807ea09a0373a78b74984ad68504034fd99b75d307128bf4c21e187810aba5165cc257c582bf19b1e8d
7
+ data.tar.gz: 7b862060c2c4489cd4e43e38c5be5cdfbc79afc871feee741ada47d1a45d4bd590b2fcc01c0f3982d39ef305d2b76dc7417fbcd67c66bfcad758e6611523f7bb
checksums.yaml.gz.sig CHANGED
@@ -1 +1 @@
1
- tI���bc|G�<D��݋��.݈J�a*.a,�Xf��𢯕���r�ɂ�`9!ۚMq��M>��y�y��5<7��U%��r;^��7dP�E������-�x��S�Zs`�0�Oݤj}"9���(���� !R�?��&�4F����=P��ɳAM�;Ml�-=:(C��F�#�%=�kX�f!������Մ$�u &��ts�P
1
+ �.�![m�0H�;�/�ᐘFt�s��L vʀ�����F?c�*���lMWĜ��K�ҘM�%F��>a��[T>;4$-_<�S:�m�/祼���I_I}�c����Ȟ��xr��~~oC���rR��i�:�ס� ���}��f�̞d��[�y/bw D)IF>3Dc3<�M+��qԥ�捌�%n��P( ��-y
data/History.rdoc CHANGED
@@ -1,3 +1,31 @@
1
+ === 4.6.5 / 2022-04-09
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Changed :iter scoring from branch to block_call (same score).
6
+
7
+ * 1 bug fix:
8
+
9
+ * Fixed support for ruby 3 (only affected block_pass / to_proc_normal).
10
+
11
+ === 4.6.4 / 2019-12-14
12
+
13
+ * 2 minor enhancements:
14
+
15
+ * Added basic support for safe_call (nic-potter).
16
+ * Added extra complexity penalty to safe_call processing.
17
+
18
+ === 4.6.3 / 2019-09-14
19
+
20
+ * 1 minor enhancement:
21
+
22
+ * Removed --18 and --19 options to cmdline. No real value anymore.
23
+
24
+ * 2 bug fixes:
25
+
26
+ * Fixed some sexp access under STRICT_SEXP=2.
27
+ * Fixed option / arg processing bug that caused a hang (reading from stdin).
28
+
1
29
  === 4.6.2 / 2018-02-14
2
30
 
3
31
  * 1 bug fix:
data/Rakefile CHANGED
@@ -7,12 +7,13 @@ Hoe.add_include_dirs("../../ruby_parser/dev/lib",
7
7
  "../../RubyInline/dev/lib",
8
8
  "../../sexp_processor/dev/lib",
9
9
  "../../ZenTest/dev/lib",
10
- "../../minitest/dev/lib",
11
10
  "../../path_expander/dev/lib",
12
11
  "lib")
13
12
 
14
13
  Hoe.plugin :seattlerb
14
+ Hoe.plugin :isolate
15
15
  Hoe.plugin :rdoc
16
+ Hoe.plugin :bundler
16
17
 
17
18
  Hoe.spec 'flog' do
18
19
  developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
@@ -25,6 +26,8 @@ Hoe.spec 'flog' do
25
26
  dependency "sexp_processor", "~> 4.8"
26
27
  dependency "ruby_parser", ["~> 3.1", "> 3.1.0"]
27
28
  dependency "path_expander", "~> 1.0"
29
+
30
+ dependency "minitest", "~> 5.0", :dev
28
31
  end
29
32
 
30
33
  task :debug do
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.2" # :nodoc:
14
+ VERSION = "4.6.5" # :nodoc:
15
15
 
16
16
  ##
17
17
  # Cut off point where the report should stop unless --all given.
@@ -38,6 +38,7 @@ class Flog < MethodBasedSexpProcessor
38
38
  :assignment => 1,
39
39
  :block => 1,
40
40
  :block_pass => 1,
41
+ :block_call => 1,
41
42
  :branch => 1,
42
43
  :lit_fixnum => 0.25,
43
44
  :sclass => 5,
@@ -49,10 +50,10 @@ class Flog < MethodBasedSexpProcessor
49
50
  2
50
51
  when /^1\.9/ then
51
52
  1.5
52
- when /^2\./ then
53
+ when /^[23]\./ then
53
54
  1
54
55
  else
55
- 5
56
+ raise "Unhandled version #{RUBY_VERSION}"
56
57
  end,
57
58
  :yield => 1,
58
59
  }
@@ -143,10 +144,12 @@ class Flog < MethodBasedSexpProcessor
143
144
  def dsl_name? args
144
145
  return false unless args and not args.empty?
145
146
 
146
- first_arg = args.first
147
- first_arg = first_arg[1] if first_arg[0] == :hash
147
+ first_arg, = args
148
+ first_arg = first_arg[1] if first_arg.sexp_type == :hash
148
149
 
149
- [:lit, :str].include? first_arg[0] and first_arg[1]
150
+ type, value, * = first_arg
151
+
152
+ value if [:lit, :str].include? type
150
153
  end
151
154
 
152
155
  ##
@@ -286,7 +289,7 @@ class Flog < MethodBasedSexpProcessor
286
289
  tally.each do |cat, score|
287
290
  case cat
288
291
  when :assignment then a += score
289
- when :branch then b += score
292
+ when :branch, :block_call then b += score
290
293
  else c += score
291
294
  end
292
295
  end
@@ -362,7 +365,7 @@ class Flog < MethodBasedSexpProcessor
362
365
 
363
366
  add_to_score :block_pass
364
367
 
365
- case arg.first
368
+ case arg.sexp_type
366
369
  when :lvar, :dvar, :ivar, :cvar, :self, :const, :colon2, :nil then # f(&b)
367
370
  # do nothing
368
371
  when :lit, :call then # f(&:b)
@@ -400,6 +403,22 @@ class Flog < MethodBasedSexpProcessor
400
403
  s()
401
404
  end
402
405
 
406
+ def process_safe_call(exp)
407
+ penalize_by 0.3 do
408
+ process exp.shift # recv
409
+ end
410
+
411
+ name = exp.shift
412
+
413
+ penalize_by 0.2 do
414
+ process_until_empty exp
415
+ end
416
+
417
+ add_to_score name, SCORES[name]
418
+
419
+ s()
420
+ end
421
+
403
422
  def process_case(exp)
404
423
  add_to_score :branch
405
424
  process exp.shift # recv
@@ -455,7 +474,7 @@ class Flog < MethodBasedSexpProcessor
455
474
  exp.delete 0 # { || ... } has 0 in arg slot
456
475
 
457
476
  if context == [:block, :iter] or context == [:iter] then
458
- recv = exp.first
477
+ recv, = exp
459
478
 
460
479
  # DSL w/ names. eg task :name do ... end
461
480
  # looks like s(:call, nil, :task, s(:lit, :name))
@@ -475,7 +494,7 @@ class Flog < MethodBasedSexpProcessor
475
494
  end
476
495
  end
477
496
 
478
- add_to_score :branch
497
+ add_to_score :block_call
479
498
 
480
499
  process exp.shift # no penalty for LHS
481
500
 
data/lib/flog_cli.rb CHANGED
@@ -19,11 +19,11 @@ class FlogCLI
19
19
  expander = PathExpander.new args, "**/*.{rb,rake}"
20
20
  files = expander.process
21
21
 
22
+ options = parse_options args
23
+
22
24
  abort "no files or stdin (-) to process, aborting." if
23
25
  files.empty? and args.empty?
24
26
 
25
- options = parse_options args
26
-
27
27
  flogger = new options
28
28
  flogger.flog(*files)
29
29
  flogger.report
@@ -131,14 +131,6 @@ class FlogCLI
131
131
  option[:verbose] = true
132
132
  end
133
133
 
134
- opts.on("--18", "Use a ruby 1.8 parser.") do
135
- option[:parser] = Ruby18Parser
136
- end
137
-
138
- opts.on("--19", "Use a ruby 1.9 parser.") do
139
- option[:parser] = Ruby19Parser
140
- end
141
-
142
134
  next if self.plugins.empty?
143
135
  opts.separator "Plugin options:"
144
136
 
data/test/test_flog.rb CHANGED
@@ -135,7 +135,7 @@ class TestFlog < FlogTest
135
135
  bonus = case RUBY_VERSION
136
136
  when /^1\.8\.7/ then 0.4
137
137
  when /^1\.9/ then 0.3
138
- when /^2\./ then 0.2
138
+ when /^[23]\./ then 0.2
139
139
  else raise "Unhandled version #{RUBY_VERSION}"
140
140
  end
141
141
 
@@ -166,7 +166,7 @@ class TestFlog < FlogTest
166
166
  :lit_fixnum => 0.275,
167
167
  :block_pass => 1.0,
168
168
  :lambda => 1.0,
169
- :branch => 1.0,
169
+ :block_call => 1.0,
170
170
  :to_proc_icky! => 10.0)
171
171
  end
172
172
 
@@ -181,15 +181,36 @@ class TestFlog < FlogTest
181
181
  :block_pass => 1.0,
182
182
  :lambda => 1.0,
183
183
  :assignment => 1.0,
184
- :branch => 1.0,
184
+ :block_call => 1.0,
185
185
  :to_proc_lasgn => 15.0)
186
186
  end
187
187
 
188
188
  def test_process_call
189
- sexp = s(:call, nil, :a)
189
+ sexp = s(:call, nil, :a) # a
190
190
  assert_process sexp, 1.0, :a => 1.0
191
191
  end
192
192
 
193
+ def test_process_call2
194
+ sexp = s(:call, s(:call, nil, :a), :b) # a.b
195
+ assert_process sexp, 2.2, :a => 1.2, :b => 1.0
196
+ end
197
+
198
+ def test_process_call3
199
+ sexp = s(:call, s(:call, s(:call, nil, :a), :b), :c) # a.b.c
200
+ assert_process sexp, 3.6, :a => 1.4, :b => 1.2, :c => 1.0
201
+ end
202
+
203
+ def test_process_safe_call2
204
+ sexp = s(:safe_call, s(:call, nil, :a), :b) # a&.b
205
+ assert_process sexp, 2.3, :a => 1.3, :b => 1.0
206
+ end
207
+
208
+ def test_process_safe_call3
209
+ sexp = s(:safe_call, s(:safe_call, s(:call, nil, :a), :b), :c) # a&.b&.c
210
+
211
+ assert_process sexp, 3.9, :a => 1.6, :b => 1.3, :c => 1.0
212
+ end
213
+
193
214
  def test_process_case
194
215
  case :a
195
216
  when :a
@@ -303,7 +324,7 @@ class TestFlog < FlogTest
303
324
  s(:call, nil, :loop), nil,
304
325
  s(:if, s(:true), s(:break), nil))
305
326
 
306
- assert_process sexp, 2.326, :loop => 1.0, :branch => 2.1
327
+ assert_process sexp, 2.326, :loop => 1.0, :branch => 1.1, :block_call => 1
307
328
  end
308
329
 
309
330
  def test_process_iter_dsl
@@ -351,6 +372,19 @@ class TestFlog < FlogTest
351
372
  assert_process sexp, 2.3, :something => 1.0, :task => 1.0, :lit_fixnum => 0.3
352
373
  end
353
374
 
375
+ def test_process_iter_dsl_hash_when_hash_empty
376
+ # task({}) do
377
+ # something
378
+ # end
379
+
380
+ sexp = s(:iter,
381
+ s(:call, nil, :task, s(:hash)),
382
+ nil,
383
+ s(:call, nil, :something))
384
+
385
+ assert_process sexp, 2.326, :something => 1.1, :task => 1.0, :block_call => 1
386
+ end
387
+
354
388
  def test_process_iter_dsl_namespaced
355
389
  # namespace :blah do
356
390
  # task :woot => 42 do
@@ -1,4 +1,4 @@
1
- require "test/test_flog"
1
+ require "test_flog"
2
2
  require "flog_cli"
3
3
 
4
4
  class FlogCLI
data.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- N�X��<~��x9ז���،:0�(Ԧ��o�=���o}D��)��X\���?��HEw���W��\��D OB��Q͝V����{R��4��V��-F�Ԫ�8�p�-b�q[�1�l_z��v-�0�<�|�S�Q�[��I��Ou:S �8�Z�0]�=?��љ��H�"I����6�� 3��&��Esl�������u]o�+k�>��ߴ�6'h�;�U!y7HS�c����s�M��ws�
1
+  �&�ȣ�#�X�M�����b�����=���֭+h_���1����(yb1�F W@V�!��r*fp?0(.O�9'��KK<M�����6m�N�D���nJ��n����y]cfxSI�����N����)D7/���+b���QW:������LDE��%��v>��"8S�T���C�����f��a��0-���sJ]Lz� X'c5t ��(C��jY3n�λC���aqE�ˑ��^1�Qi�
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flog
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.2
4
+ version: 4.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBAjANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBBjANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTE3MTEyMTIxMTExMFoXDTE4MTEyMTIxMTExMFowRTETMBEGA1UE
15
+ GRYDY29tMB4XDTIxMTIyMzIzMTkwNFoXDTIyMTIyMzIzMTkwNFowRTETMBEGA1UE
16
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
18
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -21,15 +21,15 @@ cert_chain:
21
21
  GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
22
22
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
23
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
- HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBBQUAA4IB
25
- AQAfAXSQpsW7YSxd1csRtA/M4Zt0AMXFMd76GJ8Lgtg8G0+VFbdChRyDuDb0kPlW
26
- h9QQX/YABfCW8vxmssbMGrP+VGBAn7BbdTcfTlgCWrvMX1uL5aRL74nA4urKXqdW
27
- a0nP70K4958P3GffBdtE3KGkU5xstFnXGajxuBRnL66E15KU0BNehVxdG258bdPu
28
- EKN6MqBPftFiev3tuwqDV11r2GquDpniYcT+Mi8/PgeAgVT/afBeVgbB3KaZeTRR
29
- AhXhF6Wi2GTMezlj5jlI5XV7WsJUSwTp/YiVvcmT74ZaCRvexm6EnNhkrvJJ1Xeu
30
- V+HB+LYYhXWitInO/eXxDrFB
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
31
31
  -----END CERTIFICATE-----
32
- date: 2018-02-14 00:00:00.000000000 Z
32
+ date: 2022-04-09 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: sexp_processor
@@ -80,33 +80,53 @@ dependencies:
80
80
  - !ruby/object:Gem::Version
81
81
  version: '1.0'
82
82
  - !ruby/object:Gem::Dependency
83
- name: rdoc
83
+ name: minitest
84
84
  requirement: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '4.0'
88
+ version: '5.0'
89
89
  type: :development
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '5.0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rdoc
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
94
101
  - !ruby/object:Gem::Version
95
102
  version: '4.0'
103
+ - - "<"
104
+ - !ruby/object:Gem::Version
105
+ version: '7'
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '4.0'
113
+ - - "<"
114
+ - !ruby/object:Gem::Version
115
+ version: '7'
96
116
  - !ruby/object:Gem::Dependency
97
117
  name: hoe
98
118
  requirement: !ruby/object:Gem::Requirement
99
119
  requirements:
100
120
  - - "~>"
101
121
  - !ruby/object:Gem::Version
102
- version: '3.16'
122
+ version: '3.23'
103
123
  type: :development
104
124
  prerelease: false
105
125
  version_requirements: !ruby/object:Gem::Requirement
106
126
  requirements:
107
127
  - - "~>"
108
128
  - !ruby/object:Gem::Version
109
- version: '3.16'
129
+ version: '3.23'
110
130
  description: |-
111
131
  Flog reports the most tortured code in an easy to read pain
112
132
  report. The higher the score, the more pain the code is in.
@@ -135,8 +155,10 @@ files:
135
155
  homepage: http://ruby.sadi.st/
136
156
  licenses:
137
157
  - MIT
138
- metadata: {}
139
- post_install_message:
158
+ metadata:
159
+ homepage_uri: http://ruby.sadi.st/
160
+ source_code_uri: https://github.com/seattlerb/flog
161
+ post_install_message:
140
162
  rdoc_options:
141
163
  - "--main"
142
164
  - README.rdoc
@@ -153,9 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
175
  - !ruby/object:Gem::Version
154
176
  version: '0'
155
177
  requirements: []
156
- rubyforge_project:
157
- rubygems_version: 2.7.3
158
- signing_key:
178
+ rubygems_version: 3.3.3
179
+ signing_key:
159
180
  specification_version: 4
160
181
  summary: Flog reports the most tortured code in an easy to read pain report
161
182
  test_files: []
metadata.gz.sig CHANGED
Binary file