flog 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
File without changes
@@ -1,3 +1,15 @@
1
+ === 2.5.1 / 2011-02-18
2
+
3
+ * 3 minor enhancements:
4
+
5
+ * Added RegexpError to error handler.
6
+ * Improved error output and suggest --continue
7
+ * Record the flog score for the full class name, not just suffix. (dkubb)
8
+
9
+ * 1 bug fix:
10
+
11
+ * Fixed block_pass when passed a multi-level const (xavier)
12
+
1
13
  === 2.5.0 / 2010-09-01
2
14
 
3
15
  * 1 major enhancement:
@@ -4,7 +4,7 @@ require 'ruby_parser'
4
4
  require 'optparse'
5
5
 
6
6
  class Flog < SexpProcessor
7
- VERSION = '2.5.0'
7
+ VERSION = '2.5.1'
8
8
 
9
9
  THRESHOLD = 0.60
10
10
  SCORES = Hash.new 1
@@ -242,12 +242,15 @@ class Flog < SexpProcessor
242
242
  next unless ast
243
243
  mass[file] = ast.mass
244
244
  process ast
245
- rescue SyntaxError, Racc::ParseError => e
245
+ rescue RegexpError, SyntaxError, Racc::ParseError => e
246
246
  if e.inspect =~ /<%|%>/ or ruby =~ /<%|%>/ then
247
247
  warn "#{e.inspect} at #{e.backtrace.first(5).join(', ')}"
248
248
  warn "\n...stupid lemmings and their bad erb templates... skipping"
249
249
  else
250
- raise e unless option[:continue]
250
+ unless option[:continue] then
251
+ warn "ERROR! Aborting. You may want to run with --continue."
252
+ raise e
253
+ end
251
254
  warn file
252
255
  warn "#{e.inspect} at #{e.backtrace.first(5).join(', ')}"
253
256
  end
@@ -292,21 +295,24 @@ class Flog < SexpProcessor
292
295
  # none.
293
296
 
294
297
  def klass_name
295
- name = @class_stack.first || @@no_class
298
+ name = @class_stack.first
296
299
  if Sexp === name then
297
- name = case name.first
298
- when :colon2 then
299
- name = name.flatten
300
- name.delete :const
301
- name.delete :colon2
302
- name.join("::")
303
- when :colon3 then
304
- name.last.to_s
305
- else
306
- name
307
- end
300
+ case name.first
301
+ when :colon2 then
302
+ name = name.flatten
303
+ name.delete :const
304
+ name.delete :colon2
305
+ name.join("::")
306
+ when :colon3 then
307
+ name.last.to_s
308
+ else
309
+ name
310
+ end
311
+ elsif @class_stack.any?
312
+ @class_stack.reverse.join("::")
313
+ else
314
+ @@no_class
308
315
  end
309
- name
310
316
  end
311
317
 
312
318
  ##
@@ -509,7 +515,7 @@ class Flog < SexpProcessor
509
515
  add_to_score :block_pass
510
516
 
511
517
  case arg.first
512
- when :lvar, :dvar, :ivar, :cvar, :self, :const, :nil then
518
+ when :lvar, :dvar, :ivar, :cvar, :self, :const, :colon2, :nil then
513
519
  # do nothing
514
520
  when :lit, :call then
515
521
  add_to_score :to_proc_normal
@@ -20,6 +20,7 @@ class FlogTask < Rake::TaskLib
20
20
  def define
21
21
  desc "Analyze for code complexity in: #{dirs.join(', ')}"
22
22
  task name do
23
+ require "flog"
23
24
  flog = Flog.new
24
25
  flog.flog(*dirs)
25
26
  flog.report if verbose
@@ -8,16 +8,16 @@ class TestFlog < MiniTest::Unit::TestCase
8
8
 
9
9
  def test_add_to_score
10
10
  assert_empty @flog.calls
11
- @flog.class_stack << "MyKlass"
11
+ @flog.class_stack << "Base" << "MyKlass"
12
12
  @flog.method_stack << "mymethod"
13
13
  @flog.add_to_score "blah", 42
14
14
 
15
- expected = {"MyKlass#mymethod" => {"blah" => 42.0}}
15
+ expected = {"MyKlass::Base#mymethod" => {"blah" => 42.0}}
16
16
  assert_equal expected, @flog.calls
17
17
 
18
18
  @flog.add_to_score "blah", 2
19
19
 
20
- expected["MyKlass#mymethod"]["blah"] = 44.0
20
+ expected["MyKlass::Base#mymethod"]["blah"] = 44.0
21
21
  assert_equal expected, @flog.calls
22
22
  end
23
23
 
@@ -129,8 +129,8 @@ class TestFlog < MiniTest::Unit::TestCase
129
129
  def test_in_klass
130
130
  assert_empty @flog.class_stack
131
131
 
132
- @flog.in_klass "xxx" do
133
- assert_equal ["xxx"], @flog.class_stack
132
+ @flog.in_klass "xxx::yyy" do
133
+ assert_equal ["xxx::yyy"], @flog.class_stack
134
134
  end
135
135
 
136
136
  assert_empty @flog.class_stack
@@ -152,8 +152,8 @@ class TestFlog < MiniTest::Unit::TestCase
152
152
  def test_klass_name
153
153
  assert_equal :main, @flog.klass_name
154
154
 
155
- @flog.class_stack << "whatevs"
156
- assert_equal "whatevs", @flog.klass_name
155
+ @flog.class_stack << "whatevs" << "flog"
156
+ assert_equal "flog::whatevs", @flog.klass_name
157
157
  end
158
158
 
159
159
  def test_klass_name_sexp
@@ -305,6 +305,17 @@ class TestFlog < MiniTest::Unit::TestCase
305
305
  :to_proc_normal => 6.0)
306
306
  end
307
307
 
308
+ def test_process_block_pass_colon2
309
+ sexp = s(:call, nil, :a,
310
+ s(:arglist,
311
+ s(:block_pass,
312
+ s(:colon2, s(:const, :A), :B))))
313
+
314
+ util_process(sexp, 2.2,
315
+ :a => 1.0,
316
+ :block_pass => 1.2)
317
+ end
318
+
308
319
  def test_process_block_pass_iter
309
320
  sexp = s(:block_pass,
310
321
  s(:iter, s(:call, nil, :lambda, s(:arglist)), nil, s(:lit, 1)))
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flog
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
4
+ hash: 25
5
+ prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 5
9
- - 0
10
- version: 2.5.0
9
+ - 1
10
+ version: 2.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Davis
@@ -36,7 +36,7 @@ cert_chain:
36
36
  FBHgymkyj/AOSqKRIpXPhjC6
37
37
  -----END CERTIFICATE-----
38
38
 
39
- date: 2010-09-01 00:00:00 -07:00
39
+ date: 2011-02-18 00:00:00 -08:00
40
40
  default_executable:
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
@@ -70,53 +70,37 @@ dependencies:
70
70
  type: :runtime
71
71
  version_requirements: *id002
72
72
  - !ruby/object:Gem::Dependency
73
- name: rubyforge
73
+ name: minitest
74
74
  prerelease: false
75
75
  requirement: &id003 !ruby/object:Gem::Requirement
76
76
  none: false
77
77
  requirements:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
- hash: 7
80
+ hash: 11
81
81
  segments:
82
82
  - 2
83
83
  - 0
84
- - 4
85
- version: 2.0.4
84
+ - 2
85
+ version: 2.0.2
86
86
  type: :development
87
87
  version_requirements: *id003
88
88
  - !ruby/object:Gem::Dependency
89
- name: minitest
89
+ name: hoe
90
90
  prerelease: false
91
91
  requirement: &id004 !ruby/object:Gem::Requirement
92
92
  none: false
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- hash: 9
96
+ hash: 41
97
97
  segments:
98
+ - 2
99
+ - 9
98
100
  - 1
99
- - 7
100
- - 1
101
- version: 1.7.1
101
+ version: 2.9.1
102
102
  type: :development
103
103
  version_requirements: *id004
104
- - !ruby/object:Gem::Dependency
105
- name: hoe
106
- prerelease: false
107
- requirement: &id005 !ruby/object:Gem::Requirement
108
- none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- hash: 19
113
- segments:
114
- - 2
115
- - 6
116
- - 2
117
- version: 2.6.2
118
- type: :development
119
- version_requirements: *id005
120
104
  description: |-
121
105
  Flog reports the most tortured code in an easy to read pain
122
106
  report. The higher the score, the more pain the code is in.
@@ -141,6 +125,7 @@ files:
141
125
  - lib/flog_task.rb
142
126
  - lib/gauntlet_flog.rb
143
127
  - test/test_flog.rb
128
+ - .gemtest
144
129
  has_rdoc: true
145
130
  homepage: http://ruby.sadi.st/
146
131
  licenses: []
@@ -172,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
157
  requirements: []
173
158
 
174
159
  rubyforge_project: seattlerb
175
- rubygems_version: 1.3.7
160
+ rubygems_version: 1.4.2
176
161
  signing_key:
177
162
  specification_version: 3
178
163
  summary: Flog reports the most tortured code in an easy to read pain report
metadata.gz.sig CHANGED
Binary file