flog 4.9.3 → 4.10.0
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 +4 -4
- checksums.yaml.gz.sig +2 -2
- data/History.rdoc +21 -0
- data/README.rdoc +7 -1
- data/Rakefile +2 -2
- data/lib/flog.rb +41 -12
- data/lib/flog_cli.rb +5 -0
- data/test/test_flog.rb +167 -7
- data/test/test_flog_cli.rb +2 -1
- data.tar.gz.sig +0 -0
- metadata +34 -20
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 047dd2034a9a7363af7474e2ec42c541eb08a8460ef065da5ec9cc7ba295e903
|
|
4
|
+
data.tar.gz: 252c85c2e6c942a45cfc8b199c50f1102730cc6f97a3761d8a1f98599c64b78f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 16a8677d306e6a716df1009600aef984fedf97edb8273b142d467464cac4ac0c951654fda938a975469e250ba6779dce9c73bad18117c41f110a610e8f671957
|
|
7
|
+
data.tar.gz: 458fcfd0cb26ca5adb5ea05fd3b2ae83a1fa90343a9248fe1141923acd506caf45de846a5e125540a37b5dcde0bb61202b4a157fd0add02d9ed0b0d2d546a039
|
checksums.yaml.gz.sig
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
ss*����̓�|QI�KO��~���~c���^�I�e=��7:8�x�����Dܕ��d��k��y�;
|
|
2
|
+
���Um/��vg~`bt�Xg}m#�X�i�bL1��ʹnM��j�v�[F�b����\�����1��@�/;���|�¸���V1nV��쁧H�}.�!���C>B�ჭ�� e����셻�o�
|
data/History.rdoc
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
=== 4.10.0 / 2026-11-25
|
|
2
|
+
|
|
3
|
+
* 1 minor enhancement:
|
|
4
|
+
|
|
5
|
+
* Added --timeout=<n> flag. (olbrich)
|
|
6
|
+
|
|
7
|
+
* 5 bug fixes:
|
|
8
|
+
|
|
9
|
+
* Bump prism version to include 2.x.
|
|
10
|
+
* Fix #penalize_by to avoid round-off errors processing deeply nested code. (ThaSMorato)
|
|
11
|
+
* Fixed lvar processing for _1, _2, etc.
|
|
12
|
+
* Fixed processing of absolutely bonkers `call(&obj&.method)` construct.
|
|
13
|
+
* Fixed scoring of const assignments to be counted as a namespace. (chrobo)
|
|
14
|
+
|
|
15
|
+
=== 4.9.4 / 2026-01-06
|
|
16
|
+
|
|
17
|
+
* 2 bug fixes:
|
|
18
|
+
|
|
19
|
+
* Namespace NotRubyParser to avoid problems with bundler's horrid eager loading. (nateberkopec)
|
|
20
|
+
* Patch prism to recognize `it` as a local. (faisal)
|
|
21
|
+
|
|
1
22
|
=== 4.9.3 / 2026-01-05
|
|
2
23
|
|
|
3
24
|
* 1 bug fix:
|
data/README.rdoc
CHANGED
|
@@ -29,10 +29,16 @@ report. The higher the score, the more pain the code is in.
|
|
|
29
29
|
53.7: Flog#parse_options
|
|
30
30
|
...
|
|
31
31
|
|
|
32
|
+
== AI Policy:
|
|
33
|
+
|
|
34
|
+
AI is not allowed. Not in PRs, not in issues... just NO. See {my AI
|
|
35
|
+
policy}[https://zenspider.com/ruby/2026/07/my-ai-policy.html] for more
|
|
36
|
+
details. If it "smells of AI", it will be rejected.
|
|
37
|
+
|
|
32
38
|
== REQUIREMENTS:
|
|
33
39
|
|
|
34
40
|
* ruby2ruby (soft dependency: only for -v)
|
|
35
|
-
* ruby_parser
|
|
41
|
+
* prism (can also still use ruby_parser with --legacy, but why??)
|
|
36
42
|
* path_expander
|
|
37
43
|
|
|
38
44
|
== INSTALL:
|
data/Rakefile
CHANGED
|
@@ -22,7 +22,7 @@ Hoe.spec 'flog' do
|
|
|
22
22
|
license "MIT"
|
|
23
23
|
|
|
24
24
|
dependency "sexp_processor", "~> 4.8"
|
|
25
|
-
dependency "prism",
|
|
25
|
+
dependency "prism", [">= 1.9", "< 3"]
|
|
26
26
|
dependency "path_expander", "~> 2.0"
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -38,7 +38,7 @@ task :debug do
|
|
|
38
38
|
details = ENV["D"]
|
|
39
39
|
continue = ENV["C"]
|
|
40
40
|
|
|
41
|
-
flog = FlogCLI.new
|
|
41
|
+
flog = FlogCLI.new
|
|
42
42
|
|
|
43
43
|
flog.option[:details] = true if details
|
|
44
44
|
flog.option[:continue] = true if continue
|
data/lib/flog.rb
CHANGED
|
@@ -4,7 +4,18 @@ require "prism/translation/ruby_parser"
|
|
|
4
4
|
require "timeout"
|
|
5
5
|
require "racc" # for Racc::ParseError
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
class Prism::Translation::RubyParser
|
|
8
|
+
module TweakIt
|
|
9
|
+
def visit_it_local_variable_read_node(node) # TODO: upstream
|
|
10
|
+
s(node, :lvar, :it)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def visit_local_variable_read_node(node)
|
|
14
|
+
s(node, :lvar, node.name)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
Compiler.prepend TweakIt
|
|
18
|
+
end
|
|
8
19
|
|
|
9
20
|
##
|
|
10
21
|
# Flog is a SexpProcessor that calculates a ABC (assignments,
|
|
@@ -16,15 +27,15 @@ NotRubyParser = Class.new Prism::Translation::RubyParser
|
|
|
16
27
|
# thoroughly test.
|
|
17
28
|
|
|
18
29
|
class Flog < MethodBasedSexpProcessor
|
|
19
|
-
VERSION = "4.
|
|
30
|
+
VERSION = "4.10.0" # :nodoc:
|
|
31
|
+
|
|
32
|
+
NotRubyParser = Class.new Prism::Translation::RubyParser # compatibility layer :nodoc:
|
|
20
33
|
|
|
21
34
|
##
|
|
22
35
|
# Cut off point where the report should stop unless --all given.
|
|
23
36
|
|
|
24
37
|
DEFAULT_THRESHOLD = 0.60
|
|
25
38
|
|
|
26
|
-
THRESHOLD = DEFAULT_THRESHOLD # :nodoc:
|
|
27
|
-
|
|
28
39
|
##
|
|
29
40
|
# The scoring system hash. Maps node type to score.
|
|
30
41
|
|
|
@@ -175,7 +186,7 @@ class Flog < MethodBasedSexpProcessor
|
|
|
175
186
|
|
|
176
187
|
ruby = file == "-" ? $stdin.read : File.binread(file)
|
|
177
188
|
|
|
178
|
-
flog_ruby ruby, file
|
|
189
|
+
flog_ruby ruby, file, option[:timeout]
|
|
179
190
|
end
|
|
180
191
|
|
|
181
192
|
calculate_total_scores
|
|
@@ -255,14 +266,14 @@ class Flog < MethodBasedSexpProcessor
|
|
|
255
266
|
|
|
256
267
|
##
|
|
257
268
|
# For the duration of the block the complexity factor is increased
|
|
258
|
-
# by #bonus This allows the complexity of sub-expressions to be
|
|
259
|
-
# influenced by the expressions in which they are found.
|
|
260
|
-
# to the supplied block.
|
|
269
|
+
# by #bonus. This allows the complexity of sub-expressions to be
|
|
270
|
+
# influenced by the expressions in which they are found.
|
|
261
271
|
|
|
262
272
|
def penalize_by bonus
|
|
273
|
+
old = @multiplier
|
|
263
274
|
@multiplier += bonus
|
|
264
275
|
yield
|
|
265
|
-
@multiplier
|
|
276
|
+
@multiplier = old
|
|
266
277
|
end
|
|
267
278
|
|
|
268
279
|
##
|
|
@@ -284,9 +295,9 @@ class Flog < MethodBasedSexpProcessor
|
|
|
284
295
|
a, b, c = 0, 0, 0
|
|
285
296
|
tally.each do |cat, score|
|
|
286
297
|
case cat
|
|
287
|
-
when :assignment
|
|
298
|
+
when :assignment then a += score
|
|
288
299
|
when :branch, :block_call then b += score
|
|
289
|
-
else
|
|
300
|
+
else c += score
|
|
290
301
|
end
|
|
291
302
|
end
|
|
292
303
|
Math.sqrt(a*a + b*b + c*c)
|
|
@@ -372,12 +383,13 @@ class Flog < MethodBasedSexpProcessor
|
|
|
372
383
|
# do nothing -- I don't like the indirection, but that's already scored
|
|
373
384
|
when :lasgn then # f(&l=b)
|
|
374
385
|
add_to_score :to_proc_lasgn
|
|
375
|
-
when :iter, :dsym, :dstr, :hash, *BRANCHING then
|
|
386
|
+
when :iter, :dsym, :dstr, :hash, :safe_call, *BRANCHING then # below
|
|
376
387
|
# f(&proc { ... })
|
|
377
388
|
# f(&"#{...}")
|
|
378
389
|
# f(&:"#{...}")
|
|
379
390
|
# f(&if ... then ... end") and all other branching forms
|
|
380
391
|
# f(&{ a: 42 }) WHY?!?
|
|
392
|
+
# f(&obj&.meth) WHY?!?
|
|
381
393
|
add_to_score :to_proc_icky!
|
|
382
394
|
else
|
|
383
395
|
raise({:block_pass_even_ickier! => arg}.inspect)
|
|
@@ -429,6 +441,23 @@ class Flog < MethodBasedSexpProcessor
|
|
|
429
441
|
s()
|
|
430
442
|
end
|
|
431
443
|
|
|
444
|
+
def process_cdecl exp
|
|
445
|
+
name = exp.shift
|
|
446
|
+
val = exp.shift
|
|
447
|
+
|
|
448
|
+
if val.sexp_type == :iter then # eg X = Class.new do ... end
|
|
449
|
+
in_klass name do
|
|
450
|
+
add_to_score :assignment # inside in_klass keeps distance correct
|
|
451
|
+
process val
|
|
452
|
+
end
|
|
453
|
+
else
|
|
454
|
+
add_to_score :assignment
|
|
455
|
+
process val
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
s()
|
|
459
|
+
end
|
|
460
|
+
|
|
432
461
|
def process_class(exp)
|
|
433
462
|
super do
|
|
434
463
|
penalize_by 1.0 do
|
data/lib/flog_cli.rb
CHANGED
|
@@ -78,6 +78,7 @@ class FlogCLI
|
|
|
78
78
|
:quiet => false,
|
|
79
79
|
:continue => false,
|
|
80
80
|
:parser => nil,
|
|
81
|
+
:timeout => 10,
|
|
81
82
|
}.merge extra_options
|
|
82
83
|
|
|
83
84
|
OptionParser.new do |opts|
|
|
@@ -143,6 +144,10 @@ class FlogCLI
|
|
|
143
144
|
option[:verbose] = true
|
|
144
145
|
end
|
|
145
146
|
|
|
147
|
+
opts.on("--timeout=N", Float, "Set the timeout (in sec) for parsing (default: 10s)") do |n|
|
|
148
|
+
option[:timeout] = n
|
|
149
|
+
end
|
|
150
|
+
|
|
146
151
|
next if self.plugins.empty?
|
|
147
152
|
opts.separator "Plugin options:"
|
|
148
153
|
|
data/test/test_flog.rb
CHANGED
|
@@ -3,6 +3,21 @@ require "flog"
|
|
|
3
3
|
|
|
4
4
|
class Flog
|
|
5
5
|
attr_writer :calls
|
|
6
|
+
|
|
7
|
+
class NotRubyParser # TODO: remove once upstreamed
|
|
8
|
+
attr_accessor :scopes
|
|
9
|
+
|
|
10
|
+
def initialize scopes:nil
|
|
11
|
+
super()
|
|
12
|
+
self.scopes = [scopes] if scopes
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# overridden from prism to add scopes arg
|
|
16
|
+
def parse(source, filepath = "(string)")
|
|
17
|
+
translate(Prism.parse(source, filepath:, partial_script: true, scopes:), filepath)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
6
21
|
end
|
|
7
22
|
|
|
8
23
|
class FlogTest < Minitest::Test
|
|
@@ -19,7 +34,7 @@ end
|
|
|
19
34
|
|
|
20
35
|
class TestFlog < FlogTest
|
|
21
36
|
def setup
|
|
22
|
-
@flog = Flog.new
|
|
37
|
+
@flog = Flog.new
|
|
23
38
|
end
|
|
24
39
|
|
|
25
40
|
def test_add_to_score
|
|
@@ -88,6 +103,81 @@ class TestFlog < FlogTest
|
|
|
88
103
|
assert_in_epsilon 1, @flog.multiplier
|
|
89
104
|
end
|
|
90
105
|
|
|
106
|
+
def test_penalize_by__underflow_does_not_change_score
|
|
107
|
+
assert_equal 1.0, @flog.multiplier # floats=immediates, so equal will work
|
|
108
|
+
|
|
109
|
+
n = 1000
|
|
110
|
+
compound_penalty = -> {
|
|
111
|
+
@flog.penalize_by 0.1 do
|
|
112
|
+
n -= 1
|
|
113
|
+
if n.zero? then
|
|
114
|
+
assert_in_epsilon 101, @flog.multiplier
|
|
115
|
+
else
|
|
116
|
+
compound_penalty.call
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
compound_penalty.call
|
|
122
|
+
|
|
123
|
+
assert_equal 1.0, @flog.multiplier
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def test_process__iter_lasgn
|
|
127
|
+
# x = Hash.new { |h, k| h[k] = 1.0 }
|
|
128
|
+
sexp = s(:lasgn, :x,
|
|
129
|
+
s(:iter, s(:call, s(:const, :Hash), :new), s(:args, :h, :k),
|
|
130
|
+
s(:attrasgn, s(:lvar, :h), :[]=, s(:lvar, :k), s(:lit, 1.0))))
|
|
131
|
+
|
|
132
|
+
assert_process(sexp, 2.65,
|
|
133
|
+
block_call: 1.0, new: 1.0, assignment: 2.1, magic_number: 0.275)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_process__iter_cdecl
|
|
137
|
+
# X = Hash.new { |h, k| h[k] = 1.0 }
|
|
138
|
+
sexp = s(:cdecl, :X,
|
|
139
|
+
s(:iter, s(:call, s(:const, :Hash), :new), s(:args, :h, :k),
|
|
140
|
+
s(:attrasgn, s(:lvar, :h), :[]=, s(:lvar, :k), s(:lit, 1.0))))
|
|
141
|
+
|
|
142
|
+
@klass = "X"
|
|
143
|
+
assert_process(sexp, 2.65,
|
|
144
|
+
block_call: 1.0, new: 1.0, assignment: 2.1, magic_number: 0.275)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def test_process__iter_cdecl_methods
|
|
148
|
+
ruby = <<~RUBY
|
|
149
|
+
module A
|
|
150
|
+
B = Data.define(:b) do
|
|
151
|
+
def to_s = ""
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
C = Struct.new(:c) do
|
|
155
|
+
def to_s = ""
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
RUBY
|
|
159
|
+
|
|
160
|
+
sexp = s(:module, :A,
|
|
161
|
+
s(:cdecl, :B,
|
|
162
|
+
s(:iter, s(:call, s(:const, :Data), :define, s(:lit, :b)), 0,
|
|
163
|
+
s(:defn, :to_s, s(:args), s(:str, "")))),
|
|
164
|
+
s(:cdecl, :C,
|
|
165
|
+
s(:iter, s(:call, s(:const, :Struct), :new, s(:lit, :c)), 0,
|
|
166
|
+
s(:defn, :to_s, s(:args), s(:str, "")))))
|
|
167
|
+
|
|
168
|
+
sexp = assert_parse sexp, ruby # now with line numbers!
|
|
169
|
+
|
|
170
|
+
assert_process(sexp, 3.464,
|
|
171
|
+
"A::B#none" => {assignment: 1.0, block_call: 1.0, define: 1.0},
|
|
172
|
+
"A::C#none" => {assignment: 1.0, block_call: 1.0, new: 1.0})
|
|
173
|
+
|
|
174
|
+
exp = {
|
|
175
|
+
"A::B#to_s" => "file.rb:3-3",
|
|
176
|
+
"A::C#to_s" => "file.rb:7-7",
|
|
177
|
+
}
|
|
178
|
+
assert_equal exp, @flog.method_locations
|
|
179
|
+
end
|
|
180
|
+
|
|
91
181
|
def test_process_alias
|
|
92
182
|
sexp = s(:alias, s(:lit, :a), s(:lit, :b))
|
|
93
183
|
|
|
@@ -217,6 +307,42 @@ class TestFlog < FlogTest
|
|
|
217
307
|
assert_process sexp, 3.6, :a => 1.4, :b => 1.2, :c => 1.0
|
|
218
308
|
end
|
|
219
309
|
|
|
310
|
+
def test_process_call__block_arg # a(&b)
|
|
311
|
+
ruby = "a(&b)"
|
|
312
|
+
sexp = s(:call, nil, :a, s(:block_pass, s(:lvar, :b)))
|
|
313
|
+
|
|
314
|
+
assert_parse sexp, ruby
|
|
315
|
+
|
|
316
|
+
assert_process(sexp, 2.2,
|
|
317
|
+
:a => 1,
|
|
318
|
+
:block_pass => 1.2)
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
def test_process_call__block_arg_call # a(&b.c)
|
|
322
|
+
ruby = "a(&b.c)"
|
|
323
|
+
sexp = s(:call, nil, :a, s(:block_pass, s(:call, s(:lvar, :b), :c)))
|
|
324
|
+
|
|
325
|
+
assert_parse sexp, ruby
|
|
326
|
+
|
|
327
|
+
assert_process(sexp, 3.4,
|
|
328
|
+
:a => 1,
|
|
329
|
+
:c => 1.2,
|
|
330
|
+
:block_pass => 1.2)
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
def test_process_call__block_arg_safe_call # a(&b&.c)
|
|
334
|
+
ruby = "a(&b&.c)"
|
|
335
|
+
sexp = s(:call, nil, :a, s(:block_pass, s(:safe_call, s(:lvar, :b), :c)))
|
|
336
|
+
|
|
337
|
+
assert_parse sexp, ruby
|
|
338
|
+
|
|
339
|
+
assert_process(sexp, 15.40,
|
|
340
|
+
:a => 1,
|
|
341
|
+
:block_pass => 1.2,
|
|
342
|
+
:c => 1.2,
|
|
343
|
+
:to_proc_icky! => 12)
|
|
344
|
+
end
|
|
345
|
+
|
|
220
346
|
def test_process_safe_call2
|
|
221
347
|
sexp = s(:safe_call, s(:call, nil, :a), :b) # a&.b
|
|
222
348
|
assert_process sexp, 2.3, :a => 1.3, :b => 1.0
|
|
@@ -344,6 +470,30 @@ class TestFlog < FlogTest
|
|
|
344
470
|
assert_process sexp, 2.326, :loop => 1.0, :branch => 1.1, :block_call => 1
|
|
345
471
|
end
|
|
346
472
|
|
|
473
|
+
def test_process_iter__it
|
|
474
|
+
skip "n/a" if RUBY_VERSION < "3.4"
|
|
475
|
+
|
|
476
|
+
ruby = "blah { puts it }"
|
|
477
|
+
sexp = s(:iter,
|
|
478
|
+
s(:call, nil, :blah), 0,
|
|
479
|
+
s(:call, nil, :puts, s(:lvar, :it)))
|
|
480
|
+
|
|
481
|
+
assert_parse sexp, ruby
|
|
482
|
+
|
|
483
|
+
assert_process sexp, 2.326, blah: 1, block_call: 1, puts: 1.1
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
def test_process_iter__lvar__1
|
|
487
|
+
ruby = "blah { puts _1 }"
|
|
488
|
+
sexp = s(:iter,
|
|
489
|
+
s(:call, nil, :blah), 0,
|
|
490
|
+
s(:call, nil, :puts, s(:lvar, :_1)))
|
|
491
|
+
|
|
492
|
+
assert_parse sexp, ruby
|
|
493
|
+
|
|
494
|
+
assert_process sexp, 2.326, blah: 1, block_call: 1, puts: 1.1
|
|
495
|
+
end
|
|
496
|
+
|
|
347
497
|
def test_process_iter_dsl
|
|
348
498
|
# task :blah do
|
|
349
499
|
# something
|
|
@@ -451,7 +601,7 @@ class TestFlog < FlogTest
|
|
|
451
601
|
|
|
452
602
|
def test_process_lit_int__const
|
|
453
603
|
sexp = s(:cdecl, :X, s(:lit, 42))
|
|
454
|
-
assert_process sexp,
|
|
604
|
+
assert_process sexp, 1.0
|
|
455
605
|
end
|
|
456
606
|
|
|
457
607
|
def test_process_lit_float # and other lits
|
|
@@ -461,11 +611,11 @@ class TestFlog < FlogTest
|
|
|
461
611
|
|
|
462
612
|
def test_process_lit_float__const
|
|
463
613
|
sexp = s(:cdecl, :X, s(:lit, 3.1415))
|
|
464
|
-
assert_process sexp,
|
|
614
|
+
assert_process sexp, 1.0
|
|
465
615
|
end
|
|
466
616
|
|
|
467
617
|
def test_process_lit_complex
|
|
468
|
-
sexp = s(:lit,
|
|
618
|
+
sexp = eval 's(:lit, 0+1i)' # stupid emacs is borking on the complex
|
|
469
619
|
assert_process sexp, 0.25
|
|
470
620
|
end
|
|
471
621
|
|
|
@@ -564,13 +714,21 @@ class TestFlog < FlogTest
|
|
|
564
714
|
end
|
|
565
715
|
|
|
566
716
|
def assert_hash_in_epsilon exp, act
|
|
567
|
-
assert_equal exp.keys.
|
|
717
|
+
assert_equal exp.keys.sort, act.keys.sort
|
|
568
718
|
|
|
569
719
|
exp.keys.each do |k|
|
|
570
720
|
assert_in_epsilon exp[k], act[k], 0.001, "key = #{k.inspect}"
|
|
571
721
|
end
|
|
572
722
|
end
|
|
573
723
|
|
|
724
|
+
def assert_parse sexp, ruby
|
|
725
|
+
parser = Flog::NotRubyParser.new scopes: %i[a b c d]
|
|
726
|
+
|
|
727
|
+
act = parser.process ruby, "file.rb"
|
|
728
|
+
assert_equal sexp, act
|
|
729
|
+
act
|
|
730
|
+
end
|
|
731
|
+
|
|
574
732
|
def assert_process sexp, score = -1, hash = {}
|
|
575
733
|
setup
|
|
576
734
|
@flog.process sexp
|
|
@@ -582,8 +740,10 @@ class TestFlog < FlogTest
|
|
|
582
740
|
key = "#{@klass}#{@meth}"
|
|
583
741
|
act = @flog.calls
|
|
584
742
|
|
|
585
|
-
|
|
586
|
-
|
|
743
|
+
# cheat?
|
|
744
|
+
hash = { key => hash } if hash.keys.all? { |x| Symbol === x }
|
|
745
|
+
|
|
746
|
+
assert_equal hash, act # also cheat: needs recursive assert_hash_in_epsilon
|
|
587
747
|
end
|
|
588
748
|
|
|
589
749
|
@flog.calculate_total_scores
|
data/test/test_flog_cli.rb
CHANGED
|
@@ -9,7 +9,7 @@ end
|
|
|
9
9
|
|
|
10
10
|
class TestFlogCLI < FlogTest
|
|
11
11
|
def setup
|
|
12
|
-
@flog = FlogCLI.new
|
|
12
|
+
@flog = FlogCLI.new
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def test_cls_parse_options
|
|
@@ -39,6 +39,7 @@ class TestFlogCLI < FlogTest
|
|
|
39
39
|
"--score" => :score,
|
|
40
40
|
"-t" => [:threshold, "75", 0.75],
|
|
41
41
|
"--threshold" => [:threshold, "75", 0.75],
|
|
42
|
+
"--timeout" => [:timeout, "1.5", 1.5],
|
|
42
43
|
"-v" => :verbose,
|
|
43
44
|
"--verbose" => :verbose,
|
|
44
45
|
# TODO: (maybe)
|
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.
|
|
4
|
+
version: 4.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Davis
|
|
@@ -9,9 +9,9 @@ bindir: bin
|
|
|
9
9
|
cert_chain:
|
|
10
10
|
- |
|
|
11
11
|
-----BEGIN CERTIFICATE-----
|
|
12
|
-
|
|
12
|
+
MIIDPjCCAiagAwIBAgIBCjANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
|
13
13
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
|
14
|
-
|
|
14
|
+
GRYDY29tMB4XDTI2MDEwNzAxMDkxNFoXDTI3MDEwNzAxMDkxNFowRTETMBEGA1UE
|
|
15
15
|
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
|
16
16
|
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
|
17
17
|
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
|
@@ -21,12 +21,12 @@ cert_chain:
|
|
|
21
21
|
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
|
22
22
|
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
|
23
23
|
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
AQA/X8/PKTTc/IkYQEUL6XWtfK8fAfbuLJzmLcz6f2ZWrtBvPsYvqRuwI1bWUtil
|
|
25
|
+
2ibJEfIuSIHX6BsUTX18+hlaIussf6EWq/YkE7e2BKmgQE42vSOZMce0kCEAPbx0
|
|
26
|
+
rQtqonfWTHQ8UbQ7GqCL3gDQ0QDD2B+HUlb4uaCZ2icxqa/eOtxMvHC2tj+h0xKY
|
|
27
|
+
xL84ipM5kr0bHGf9/MRZJWcw51urueNycBXu1Xh+pEN8qBmYsFRR4SIODLClybAO
|
|
28
|
+
6cbm2PyPQgKNiqE4H+IQrDVHd9bJs1XgLElk3qoaJBWXc/5fy0J1imYb25UqmiHG
|
|
29
|
+
snGe1hrppvBRdcyEzvhfIPjI
|
|
30
30
|
-----END CERTIFICATE-----
|
|
31
31
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
32
32
|
dependencies:
|
|
@@ -48,16 +48,22 @@ dependencies:
|
|
|
48
48
|
name: prism
|
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
|
-
- - "
|
|
51
|
+
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '1.
|
|
53
|
+
version: '1.9'
|
|
54
|
+
- - "<"
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '3'
|
|
54
57
|
type: :runtime
|
|
55
58
|
prerelease: false
|
|
56
59
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
60
|
requirements:
|
|
58
|
-
- - "
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '1.9'
|
|
64
|
+
- - "<"
|
|
59
65
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '
|
|
66
|
+
version: '3'
|
|
61
67
|
- !ruby/object:Gem::Dependency
|
|
62
68
|
name: path_expander
|
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -78,37 +84,45 @@ dependencies:
|
|
|
78
84
|
requirements:
|
|
79
85
|
- - ">="
|
|
80
86
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '
|
|
87
|
+
version: '7.0'
|
|
82
88
|
- - "<"
|
|
83
89
|
- !ruby/object:Gem::Version
|
|
84
|
-
version: '
|
|
90
|
+
version: '9'
|
|
85
91
|
type: :development
|
|
86
92
|
prerelease: false
|
|
87
93
|
version_requirements: !ruby/object:Gem::Requirement
|
|
88
94
|
requirements:
|
|
89
95
|
- - ">="
|
|
90
96
|
- !ruby/object:Gem::Version
|
|
91
|
-
version: '
|
|
97
|
+
version: '7.0'
|
|
92
98
|
- - "<"
|
|
93
99
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: '
|
|
100
|
+
version: '9'
|
|
95
101
|
- !ruby/object:Gem::Dependency
|
|
96
102
|
name: hoe
|
|
97
103
|
requirement: !ruby/object:Gem::Requirement
|
|
98
104
|
requirements:
|
|
99
105
|
- - "~>"
|
|
100
106
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: '4.
|
|
107
|
+
version: '4.7'
|
|
102
108
|
type: :development
|
|
103
109
|
prerelease: false
|
|
104
110
|
version_requirements: !ruby/object:Gem::Requirement
|
|
105
111
|
requirements:
|
|
106
112
|
- - "~>"
|
|
107
113
|
- !ruby/object:Gem::Version
|
|
108
|
-
version: '4.
|
|
114
|
+
version: '4.7'
|
|
109
115
|
description: |-
|
|
110
116
|
Flog reports the most tortured code in an easy to read pain
|
|
111
117
|
report. The higher the score, the more pain the code is in.
|
|
118
|
+
|
|
119
|
+
== Features/Problems:
|
|
120
|
+
|
|
121
|
+
* Easy to read reporting of complexity/pain.
|
|
122
|
+
* Uses path_expander, so you can use:
|
|
123
|
+
* dir_arg -- expand a directory automatically
|
|
124
|
+
* @file_of_args -- persist arguments in a file
|
|
125
|
+
* -path_to_subtract -- ignore intersecting subsets of files/directories
|
|
112
126
|
email:
|
|
113
127
|
- ryand-ruby@zenspider.com
|
|
114
128
|
executables:
|
|
@@ -116,7 +130,6 @@ executables:
|
|
|
116
130
|
extensions: []
|
|
117
131
|
extra_rdoc_files:
|
|
118
132
|
- History.rdoc
|
|
119
|
-
- Manifest.txt
|
|
120
133
|
- README.rdoc
|
|
121
134
|
files:
|
|
122
135
|
- ".autotest"
|
|
@@ -137,6 +150,7 @@ licenses:
|
|
|
137
150
|
metadata:
|
|
138
151
|
homepage_uri: http://ruby.sadi.st/
|
|
139
152
|
source_code_uri: https://github.com/seattlerb/flog
|
|
153
|
+
documentation_uri: http://docs.seattlerb.org/flog
|
|
140
154
|
rdoc_options:
|
|
141
155
|
- "--main"
|
|
142
156
|
- README.rdoc
|
metadata.gz.sig
CHANGED
|
Binary file
|