flog 2.5.3 → 3.0.0.b1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.autotest +4 -1
- data/History.txt +14 -0
- data/README.txt +1 -1
- data/Rakefile +2 -2
- data/lib/flog.rb +25 -6
- data/test/test_flog.rb +3 -3
- metadata +47 -25
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/.autotest
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
|
3
3
|
require 'autotest/restart'
|
4
|
-
require 'autotest/rcov'
|
4
|
+
require 'autotest/rcov' if ENV['RCOV']
|
5
5
|
|
6
6
|
Autotest.add_hook :initialize do |at|
|
7
7
|
at.order = :random
|
8
8
|
|
9
|
+
at.libs << ":../../ruby_parser/dev/lib"
|
10
|
+
at.libs << ":../../sexp_processor/dev/lib"
|
11
|
+
|
9
12
|
at.add_mapping(/^spec\/.*_spec\.rb$/) do |filename, _|
|
10
13
|
filename
|
11
14
|
end
|
data/History.txt
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
=== 3.0.0.b1 / 2012-07-26
|
2
|
+
|
3
|
+
* 4 minor enhancements:
|
4
|
+
|
5
|
+
* Added --18 and --19 flags to specify parser. Defaults to hybrid.
|
6
|
+
* Explicitly use Ruby18Parser to remove deprecation warnings.
|
7
|
+
* Modified processor to deal with cleaner sexps from RP 3.x.
|
8
|
+
* Use File.binread (File.read in 1.8) to bypass encoding errors
|
9
|
+
|
10
|
+
* 2 bug fixes:
|
11
|
+
|
12
|
+
* Cleaned up some 1.9 warnings.
|
13
|
+
* Fixed failing tests against ruby_parser 3
|
14
|
+
|
1
15
|
=== 2.5.3 / 2011-09-21
|
2
16
|
|
3
17
|
* 1 minor enhancement:
|
data/README.txt
CHANGED
data/Rakefile
CHANGED
@@ -17,8 +17,8 @@ Hoe.spec 'flog' do
|
|
17
17
|
|
18
18
|
self.rubyforge_name = 'seattlerb'
|
19
19
|
|
20
|
-
extra_deps << ['sexp_processor', '~>
|
21
|
-
extra_deps << ['ruby_parser', '~>
|
20
|
+
extra_deps << ['sexp_processor', '~> 4.0']
|
21
|
+
extra_deps << ['ruby_parser', '~> 3.0.0.a4']
|
22
22
|
end
|
23
23
|
|
24
24
|
# vim: syntax=ruby
|
data/lib/flog.rb
CHANGED
@@ -3,8 +3,16 @@ require 'sexp_processor'
|
|
3
3
|
require 'ruby_parser'
|
4
4
|
require 'optparse'
|
5
5
|
|
6
|
+
class File
|
7
|
+
RUBY19 = "<3".respond_to? :encoding
|
8
|
+
|
9
|
+
class << self
|
10
|
+
alias :binread :read unless RUBY19
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
6
14
|
class Flog < SexpProcessor
|
7
|
-
VERSION = '
|
15
|
+
VERSION = '3.0.0.b1'
|
8
16
|
|
9
17
|
THRESHOLD = 0.60
|
10
18
|
SCORES = Hash.new 1
|
@@ -125,6 +133,7 @@ class Flog < SexpProcessor
|
|
125
133
|
option = {
|
126
134
|
:quiet => true,
|
127
135
|
:continue => false,
|
136
|
+
:parser => RubyParser,
|
128
137
|
}
|
129
138
|
|
130
139
|
OptionParser.new do |opts|
|
@@ -177,6 +186,14 @@ class Flog < SexpProcessor
|
|
177
186
|
option[:verbose] = true
|
178
187
|
end
|
179
188
|
|
189
|
+
opts.on("--18", "Use a ruby 1.8 parser.") do
|
190
|
+
option[:parser] = Ruby18Parser
|
191
|
+
end
|
192
|
+
|
193
|
+
opts.on("--19", "Use a ruby 1.9 parser.") do
|
194
|
+
option[:parser] = Ruby19Parser
|
195
|
+
end
|
196
|
+
|
180
197
|
next if self.plugins.empty?
|
181
198
|
opts.separator "Plugin options:"
|
182
199
|
|
@@ -235,7 +252,7 @@ class Flog < SexpProcessor
|
|
235
252
|
files.each do |file|
|
236
253
|
begin
|
237
254
|
# TODO: replace File.open to deal with "-"
|
238
|
-
ruby = file == '-' ? $stdin.read : File.
|
255
|
+
ruby = file == '-' ? $stdin.read : File.binread(file)
|
239
256
|
warn "** flogging #{file}" if option[:verbose]
|
240
257
|
|
241
258
|
ast = @parser.process(ruby, file)
|
@@ -243,7 +260,7 @@ class Flog < SexpProcessor
|
|
243
260
|
mass[file] = ast.mass
|
244
261
|
process ast
|
245
262
|
rescue RegexpError, SyntaxError, Racc::ParseError => e
|
246
|
-
if e.inspect =~
|
263
|
+
if e.inspect =~ /<\%|%\>/ or ruby =~ /<\%|%\>/ then
|
247
264
|
warn "#{e.inspect} at #{e.backtrace.first(5).join(', ')}"
|
248
265
|
warn "\n...stupid lemmings and their bad erb templates... skipping"
|
249
266
|
else
|
@@ -300,7 +317,7 @@ class Flog < SexpProcessor
|
|
300
317
|
@method_stack = []
|
301
318
|
@method_locations = {}
|
302
319
|
@mass = {}
|
303
|
-
@parser =
|
320
|
+
@parser = option[:parser].new
|
304
321
|
self.auto_shift_type = true
|
305
322
|
self.reset
|
306
323
|
end
|
@@ -506,7 +523,7 @@ class Flog < SexpProcessor
|
|
506
523
|
add_to_score :assignment
|
507
524
|
process exp.shift # lhs
|
508
525
|
exp.shift # name
|
509
|
-
|
526
|
+
process_until_empty exp # rhs
|
510
527
|
s()
|
511
528
|
end
|
512
529
|
|
@@ -544,9 +561,11 @@ class Flog < SexpProcessor
|
|
544
561
|
penalize_by 0.2 do
|
545
562
|
process exp.shift # recv
|
546
563
|
end
|
564
|
+
|
547
565
|
name = exp.shift
|
566
|
+
|
548
567
|
penalize_by 0.2 do
|
549
|
-
|
568
|
+
process_until_empty exp
|
550
569
|
end
|
551
570
|
|
552
571
|
add_to_score name, SCORES[name]
|
data/test/test_flog.rb
CHANGED
@@ -3,7 +3,7 @@ require 'flog'
|
|
3
3
|
|
4
4
|
class TestFlog < MiniTest::Unit::TestCase
|
5
5
|
def setup
|
6
|
-
@flog = Flog.new
|
6
|
+
@flog = Flog.new :parser => RubyParser
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_add_to_score
|
@@ -106,7 +106,7 @@ class TestFlog < MiniTest::Unit::TestCase
|
|
106
106
|
assert_equal exp, @flog.calls
|
107
107
|
|
108
108
|
assert_equal 1.6, @flog.total unless @flog.option[:methods]
|
109
|
-
assert_equal
|
109
|
+
assert_equal 3, @flog.mass["-"]
|
110
110
|
ensure
|
111
111
|
$stdin = old_stdin
|
112
112
|
end
|
@@ -562,7 +562,7 @@ class TestFlog < MiniTest::Unit::TestCase
|
|
562
562
|
@flog.option[:all] = true
|
563
563
|
|
564
564
|
assert_equal 1.6, @flog.total unless @flog.option[:methods]
|
565
|
-
assert_equal
|
565
|
+
assert_equal 3, @flog.mass["-"]
|
566
566
|
|
567
567
|
o = StringIO.new
|
568
568
|
@flog.report o
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 1257799903
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
|
-
- 2
|
8
|
-
- 5
|
9
7
|
- 3
|
10
|
-
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
- b
|
11
|
+
- 1
|
12
|
+
version: 3.0.0.b1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Ryan Davis
|
@@ -36,7 +38,7 @@ cert_chain:
|
|
36
38
|
FBHgymkyj/AOSqKRIpXPhjC6
|
37
39
|
-----END CERTIFICATE-----
|
38
40
|
|
39
|
-
date:
|
41
|
+
date: 2012-07-27 00:00:00 Z
|
40
42
|
dependencies:
|
41
43
|
- !ruby/object:Gem::Dependency
|
42
44
|
name: sexp_processor
|
@@ -46,11 +48,11 @@ dependencies:
|
|
46
48
|
requirements:
|
47
49
|
- - ~>
|
48
50
|
- !ruby/object:Gem::Version
|
49
|
-
hash:
|
51
|
+
hash: 27
|
50
52
|
segments:
|
51
|
-
-
|
53
|
+
- 4
|
52
54
|
- 0
|
53
|
-
version: "
|
55
|
+
version: "4.0"
|
54
56
|
type: :runtime
|
55
57
|
version_requirements: *id001
|
56
58
|
- !ruby/object:Gem::Dependency
|
@@ -61,11 +63,14 @@ dependencies:
|
|
61
63
|
requirements:
|
62
64
|
- - ~>
|
63
65
|
- !ruby/object:Gem::Version
|
64
|
-
hash:
|
66
|
+
hash: 1257782997
|
65
67
|
segments:
|
66
|
-
-
|
68
|
+
- 3
|
69
|
+
- 0
|
67
70
|
- 0
|
68
|
-
|
71
|
+
- a
|
72
|
+
- 4
|
73
|
+
version: 3.0.0.a4
|
69
74
|
type: :runtime
|
70
75
|
version_requirements: *id002
|
71
76
|
- !ruby/object:Gem::Dependency
|
@@ -76,28 +81,43 @@ dependencies:
|
|
76
81
|
requirements:
|
77
82
|
- - ~>
|
78
83
|
- !ruby/object:Gem::Version
|
79
|
-
hash:
|
84
|
+
hash: 3
|
80
85
|
segments:
|
86
|
+
- 3
|
81
87
|
- 2
|
82
|
-
|
83
|
-
version: "2.6"
|
88
|
+
version: "3.2"
|
84
89
|
type: :development
|
85
90
|
version_requirements: *id003
|
86
91
|
- !ruby/object:Gem::Dependency
|
87
|
-
name:
|
92
|
+
name: rdoc
|
88
93
|
prerelease: false
|
89
94
|
requirement: &id004 !ruby/object:Gem::Requirement
|
90
95
|
none: false
|
91
96
|
requirements:
|
92
97
|
- - ~>
|
93
98
|
- !ruby/object:Gem::Version
|
94
|
-
hash:
|
99
|
+
hash: 19
|
95
100
|
segments:
|
96
|
-
-
|
97
|
-
-
|
98
|
-
version: "
|
101
|
+
- 3
|
102
|
+
- 10
|
103
|
+
version: "3.10"
|
99
104
|
type: :development
|
100
105
|
version_requirements: *id004
|
106
|
+
- !ruby/object:Gem::Dependency
|
107
|
+
name: hoe
|
108
|
+
prerelease: false
|
109
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ~>
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
hash: 7
|
115
|
+
segments:
|
116
|
+
- 3
|
117
|
+
- 0
|
118
|
+
version: "3.0"
|
119
|
+
type: :development
|
120
|
+
version_requirements: *id005
|
101
121
|
description: |-
|
102
122
|
Flog reports the most tortured code in an easy to read pain
|
103
123
|
report. The higher the score, the more pain the code is in.
|
@@ -144,16 +164,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
165
|
none: false
|
146
166
|
requirements:
|
147
|
-
- - "
|
167
|
+
- - ">"
|
148
168
|
- !ruby/object:Gem::Version
|
149
|
-
hash:
|
169
|
+
hash: 25
|
150
170
|
segments:
|
151
|
-
-
|
152
|
-
|
171
|
+
- 1
|
172
|
+
- 3
|
173
|
+
- 1
|
174
|
+
version: 1.3.1
|
153
175
|
requirements: []
|
154
176
|
|
155
177
|
rubyforge_project: seattlerb
|
156
|
-
rubygems_version: 1.8.
|
178
|
+
rubygems_version: 1.8.24
|
157
179
|
signing_key:
|
158
180
|
specification_version: 3
|
159
181
|
summary: Flog reports the most tortured code in an easy to read pain report
|
metadata.gz.sig
CHANGED
Binary file
|