rails_code_qa 0.2.3 → 0.3
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.
- data/README +19 -3
- data/lib/task_helpers.rb +22 -0
- data/lib/tasks/rails_code_qa.rake +25 -1
- metadata +27 -3
data/README
CHANGED
@@ -1,8 +1,24 @@
|
|
1
|
-
|
1
|
+
Rails Code QA
|
2
2
|
|
3
|
-
Currently
|
3
|
+
Currently does the following:
|
4
|
+
- Runs unit and functional tests with rcov for code coverage
|
5
|
+
- Runs integration tests
|
6
|
+
- Runs Flog
|
7
|
+
- Runs Flay
|
4
8
|
|
5
9
|
Usage:
|
6
|
-
|
10
|
+
|
11
|
+
Everything:
|
12
|
+
rake rcqa
|
13
|
+
|
14
|
+
Just tests and coverage:
|
15
|
+
rake rcqa:test
|
16
|
+
|
17
|
+
Just Flog:
|
18
|
+
rake rcqa:flog
|
19
|
+
|
20
|
+
Just Flay:
|
21
|
+
rake rcqa:flay
|
22
|
+
|
7
23
|
|
8
24
|
Copyright (c) 2009-2010 Nathan Humbert, released under the MIT license
|
data/lib/task_helpers.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
def flog_runner(threshold, dirs)
|
2
|
+
flog = Flog.new
|
3
|
+
flog.flog dirs
|
4
|
+
average_threshold = threshold / 3.0
|
5
|
+
puts "=============================================="
|
6
|
+
puts "Flog output for #{dirs.join(", ")}:"
|
7
|
+
puts "Method threshold: %4.1f \nAverage threshold: %4.1f" % [threshold, average_threshold]
|
8
|
+
puts "Flog total: %17.1f" % [flog.total]
|
9
|
+
puts "Flog method average: %8.1f" % [flog.average]
|
10
|
+
puts ""
|
11
|
+
bad_methods = flog.totals.select do |name,score|
|
12
|
+
score > threshold
|
13
|
+
end
|
14
|
+
bad_methods.sort { |a,b| a[1] <=> b[1] }.each do |name, score|
|
15
|
+
puts "%8.1f: %s" % [score, name]
|
16
|
+
end
|
17
|
+
|
18
|
+
puts "#{bad_methods.size} methods have a flog complexity > #{threshold}" unless bad_methods.empty?
|
19
|
+
puts "Average flog complexity > #{average_threshold}" unless flog.average < average_threshold
|
20
|
+
puts "=============================================="
|
21
|
+
puts ""
|
22
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'rcov/rcovtask'
|
2
|
+
require 'task_helpers'
|
3
|
+
require 'flog'
|
2
4
|
|
3
5
|
desc 'Run all Rails Code QA tests'
|
4
6
|
task :rcqa => ["rcqa:default"]
|
@@ -11,7 +13,7 @@ namespace :rcqa do
|
|
11
13
|
"integration" => {}
|
12
14
|
}
|
13
15
|
|
14
|
-
task :default => [:test]
|
16
|
+
task :default => [:test, :flog, :flay]
|
15
17
|
|
16
18
|
desc "Run all Rails tests with rcov on units and functionals"
|
17
19
|
task(:test) do
|
@@ -39,6 +41,28 @@ namespace :rcqa do
|
|
39
41
|
end
|
40
42
|
|
41
43
|
task :integration => ["test:integration"]
|
44
|
+
|
45
|
+
desc "Run Flog"
|
46
|
+
task(:flog) do
|
47
|
+
flog_runner(30, ['app/models', 'app/helpers', 'lib'])
|
48
|
+
flog_runner(45, ['app/controllers'])
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "Run Flay"
|
52
|
+
task(:flay) do
|
53
|
+
require 'flay'
|
54
|
+
puts "=============================================="
|
55
|
+
puts "Flay output: "
|
56
|
+
threshold = 25
|
57
|
+
flay = Flay.new({:fuzzy => false, :verbose => false, :mass => threshold})
|
58
|
+
flay.process(*Flay.expand_dirs_to_files(['app/models', 'app/helpers', 'lib']))
|
59
|
+
flay.report
|
60
|
+
|
61
|
+
puts "#{flay.masses.size} chunks of code have a duplicate mass > #{threshold}" unless flay.masses.empty?
|
62
|
+
puts "=============================================="
|
63
|
+
puts ""
|
64
|
+
end
|
65
|
+
|
42
66
|
end
|
43
67
|
|
44
68
|
|
metadata
CHANGED
@@ -4,9 +4,8 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
- 2
|
8
7
|
- 3
|
9
|
-
version: 0.
|
8
|
+
version: "0.3"
|
10
9
|
platform: ruby
|
11
10
|
authors:
|
12
11
|
- Nathan Humbert
|
@@ -14,7 +13,7 @@ autorequire:
|
|
14
13
|
bindir: bin
|
15
14
|
cert_chain: []
|
16
15
|
|
17
|
-
date: 2010-04
|
16
|
+
date: 2010-06-04 00:00:00 -07:00
|
18
17
|
default_executable:
|
19
18
|
dependencies:
|
20
19
|
- !ruby/object:Gem::Dependency
|
@@ -31,6 +30,30 @@ dependencies:
|
|
31
30
|
version: 0.9.8
|
32
31
|
type: :runtime
|
33
32
|
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: flog
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
version: "0"
|
43
|
+
type: :runtime
|
44
|
+
version_requirements: *id002
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: flay
|
47
|
+
prerelease: false
|
48
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
version: "0"
|
55
|
+
type: :runtime
|
56
|
+
version_requirements: *id003
|
34
57
|
description: This gem uses several different methods to help QA the code in your rails app
|
35
58
|
email:
|
36
59
|
- nathan.humbert+rcqa@gmail.com
|
@@ -46,6 +69,7 @@ files:
|
|
46
69
|
- lib/tasks/rails_code_qa.rake
|
47
70
|
- lib/rails_code_qa.rb
|
48
71
|
- lib/rails_code_qa/railtie.rb
|
72
|
+
- lib/task_helpers.rb
|
49
73
|
has_rdoc: true
|
50
74
|
homepage: http://github.com/nathanhumbert/rails_code_qa
|
51
75
|
licenses: []
|