jscruggs-metric_fu 0.7.1 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === MetricFu 0.7.5 / 2008-09-12
2
+
3
+ * Flog can now flog any set of directories you like (see README).
4
+ * Saikuro can now look at any set of directories you like (see README).
5
+
1
6
  === MetricFu 0.7.1 / 2008-09-12
2
7
 
3
8
  * Fixed filename bugs pointed out by Bastien
data/README CHANGED
@@ -1,4 +1,4 @@
1
- Version 0.7.1
1
+ Version 0.7.5
2
2
  http://github.com/jscruggs/metric_fu
3
3
 
4
4
  Metric_fu began its life as a plugin for Rails that generated code metrics reports. As of version 0.7.0, metric_fu is a gem owing to the excellent work done by Sean Soper.
@@ -11,22 +11,35 @@ sudo gem install jscruggs-metric_fu -s http://gems.github.com
11
11
  Then in your Rakefile:
12
12
  require 'metric_fu'
13
13
 
14
+ If you like to vendor gems, you can unpack metric_fu into vendor/gems and require it like so:
15
+ require 'my_app/vendor/gems/jscruggs-metric_fu-0.7.1/lib/metric_fu'
16
+
17
+ then you don't have to install it on every box you run it on.
18
+
19
+
14
20
  *Important note:
15
- You must have Rcov and Flog installed to get coverage and flog reports. You can do this through ruby gems at the command line like so:
16
- sudo gem install rcov
17
- sudo gem install flog
21
+ You must have Rcov and Flog installed to get coverage and flog reports. Metric_fu requires both of these gems so they will be installed when you install the metric_fu gem.
18
22
 
19
23
 
20
24
  *Usage
21
25
 
22
26
  Out of the box metrics provides these tasks:
23
- rake metrics:all
24
- rake metrics:all_with_migrate
25
- rake metrics:coverage
26
- rake metrics:saikuro
27
- rake metrics:flog
28
- rake metrics:stats
29
- rake metrics:churn
27
+ rake metrics:all
28
+ rake metrics:all_with_migrate # Useful for continuous integration
29
+ rake metrics:churn # Which files change the most
30
+ rake metrics:coverage # Generate and open coverage report
31
+ rake metrics:coverage:clean # Delete aggregate coverage data.
32
+ rake metrics:coverage:clobber_do # Remove rcov products for do
33
+ rake metrics:coverage:do # RCov task to generate report
34
+ rake metrics:flog:all # Generate and open flog report
35
+ rake metrics:flog:clean # Delete aggregate flog data.
36
+ rake metrics:flog:controllers # Flog code in app/controllers
37
+ rake metrics:flog:custom # Generate a flog report from specified directories
38
+ rake metrics:flog:helpers # Flog code in app/helpers
39
+ rake metrics:flog:lib # Flog code in lib
40
+ rake metrics:flog:models # Flog code in app/models
41
+ rake metrics:saikuro # A cyclomatic complexity report using Saikuro
42
+ rake metrics:stats # A stats report
30
43
 
31
44
  See below for more detail on the individual tasks. It's recommended to use CruiseControl.rb to set up a metrics build. See the CruiseControl.rb online docs for more info on how to set up cc.rb and, once you've got that figured out, change the cruise_config.rb file inside your project to have these lines:
32
45
 
@@ -38,26 +51,10 @@ Which will check for updates every 24 hours and run all the metrics rake tasks (
38
51
 
39
52
  *Notes on metrics:coverage
40
53
 
41
- When creating a coverage report, metric_fu runs all the tests in the test folder using Rcov. If you use RSpec you can change the default by putting this in your Rakefile:
42
-
43
- namespace :metrics do
44
- TEST_PATHS_FOR_RCOV = ['spec/**/*_spec.rb']
45
- end
46
-
47
- The namespace is only there for intentional purposes and isn't necessary. If you have multiple paths to test, then you can do this:
54
+ When creating a coverage report, metric_fu runs all the tests in the test folder using Rcov. This task used to support RSpec, but currently that doesn't work. This will be fixed in the near future (claims Jake on 9/12/2008).
48
55
 
49
- TEST_PATHS_FOR_RCOV = ['spec/**/*_spec.rb', 'test/**/*_test.rb']
50
56
 
51
- The coverage task will iterate over all the paths and aggregate the results into one report. You'll see a coverage.data file in the root of your project.
52
-
53
- If you want to change the options that Rcov is run with, then set this constant in your Rakefile:
54
-
55
- RCOV_OPTIONS = { "--sort" => "loc" }
56
-
57
- It's a hash that gets merged with the default options. This particular change will sort the coverage report by lines of code (loc). Check out the Rcov documentation for more options. If you want to see the default options metric_fu runs, open up the rake files in the plugin.
58
-
59
-
60
- *Notes on metrics:cyclomatic_complexity
57
+ *Notes on metrics:saikuro
61
58
 
62
59
  Saikuro is bundled with metric_fu so you don't have to install it. Look at the SAIKURO_README (or the internet) for more documentation on Saikuro. If you wish to change the options Saikuro is run with, then set this constant in your Rakefile:
63
60
 
@@ -67,15 +64,20 @@ end
67
64
 
68
65
  Like RCOV_OPTIONS, SAIKURO_OPTIONS is a hash that gets merged with the default options hash. The above example will set the warn_cyclo to 3 and the error_cyclo to 4 (which is way too low -- it's just an example) instructing Saikuro to flag methods with a higher cyclomatic complexity in it's report.
69
66
 
67
+ If you want to have Saikuro look at multiple folders you can put something like this in you rakefile:
68
+ SAIKURO_OPTIONS = {"--input_directory" => '"cms/app | cms/lib"'}
69
+
70
70
 
71
71
  *Notes on metrics:flog
72
72
 
73
- Flog is another way of measuring complexity (or tortured code as the Flog authors like to put it). Metric_fu takes the output of Flog run on the 'app' folder, puts it in between some <pre> tags, calculates the average Flog score per method, and jams all that into an index.html file. You should check out the awesome, and a little scary, Flog website for more info.
73
+ Flog is another way of measuring complexity (or tortured code as the Flog authors like to put it). You should check out the awesome, and a little scary, Flog website for more info.
74
74
 
75
+ 'rake metrics:flog:custom' allows you to specify a custom set of directories to Flog (in your rakefile) like so:
76
+ MetricFu::DIRECTORIES_TO_FLOG = ['cms/app', 'cms/lib']
75
77
 
76
78
  *Notes on metrics:stats
77
79
 
78
- This is just 'rake stats' put into a file. On my projects I like to be able to look at CruiseControl and get stats about the app at different points in time.
80
+ This is just 'rake stats' for Rails put into a file. On my projects I like to be able to look at CruiseControl and get stats about the app at different points in time.
79
81
 
80
82
 
81
83
  *Notes on metrics:churn
@@ -97,4 +99,4 @@ end
97
99
 
98
100
  *Thanks
99
101
 
100
- I'd like to thank the authors of Saikuro, Flog, Rcov, CruiseControl.rb, and Rails for creating such excellent open source products. Also Michael Schubert, Kurtis Seebaldt, Toby Tripp, Paul Gross, and Chirdeep Shetty for their help and advice.
102
+ I'd like to thank the authors of Saikuro, Flog, Rcov, CruiseControl.rb, and Rails for creating such excellent open source products. Also Sean Soper, Michael Schubert, Kurtis Seebaldt, Toby Tripp, Paul Gross, and Chirdeep Shetty for their help and advice.
@@ -1120,13 +1120,11 @@ if __FILE__ == $0
1120
1120
  end
1121
1121
  end
1122
1122
 
1123
- def get_ruby_files(path)
1123
+ def get_ruby_files(input_path)
1124
1124
  files = Array.new
1125
- Find.find(path) do |f|
1126
- if !FileTest.directory?(f)
1127
- if f =~ /\.rb$/
1128
- files<< f
1129
- end
1125
+ input_path.split("|").each do |path|
1126
+ Find.find(path.strip) do |f|
1127
+ files << f if !FileTest.directory?(f) && f =~ /\.rb$/
1130
1128
  end
1131
1129
  end
1132
1130
  files
data/lib/tasks/flog.rake CHANGED
@@ -46,6 +46,13 @@ begin
46
46
  MetricFu::FlogReporter::Generator.generate_report(FLOG_DIR)
47
47
  system("open #{FLOG_DIR}/index.html") if PLATFORM['darwin']
48
48
  end
49
+
50
+ desc "Generate a flog report from specified directories"
51
+ task :custom do
52
+ raise "You must define MetricFu::DIRECTORIES_TO_FLOG in your Rakefile" unless defined?(MetricFu::DIRECTORIES_TO_FLOG)
53
+ MetricFu::DIRECTORIES_TO_FLOG.each { |directory| flog(directory, directory) }
54
+ MetricFu::FlogReporter::Generator.generate_report(FLOG_DIR)
55
+ end
49
56
  end
50
57
 
51
58
  end
data/metric_fu.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "metric_fu"
3
- s.version = "0.7.1"
3
+ s.version = "0.7.5"
4
4
  s.date = "2008-09-12"
5
5
  s.summary = "Generates project metrics using Flog, RCov, Saikuro and more"
6
6
  s.email = "jake.scruggs@gmail.com"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jscruggs-metric_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Scruggs