revolutionhealth-metricks 0.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,22 @@
1
+ === 0.4.0 / 2008-06-13
2
+
3
+ * Implementing functionality for use as a gem
4
+ * Added Rakefile to facilitate testing
5
+
6
+ === 0.3.0 / 2008-06-11
7
+
8
+ * Generated reports now open on darwin automatically
9
+ * Generated reports reside under tmp/metricks unless otherwise specified by ENV['CC_BUILD_ARTIFACTS']
10
+ * MD5Tracker works with Flog reports for speed optimization
11
+
12
+ === 0.2.0 / 2008-06-11
13
+
14
+ * Integrated use of base directory constant
15
+ * Have all reports automatically open in a browser if platform is darwin
16
+ * Namespaced under Metricks
17
+ * Dropped use of shell md5 command in favor of Ruby's Digest::MD5 libraries
18
+
19
+ === 0.1.0 / 2008-06-10
20
+
21
+ * Initial integration of metric_fu and my enhancements to flog
22
+ * Metrics are generated but are all over the place
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2008 Sean Soper
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,28 @@
1
+ History.txt
2
+ Manifest.txt
3
+ metricks-0.4.gem
4
+ metricks.gemspec
5
+ MIT-LICENSE
6
+ Rakefile
7
+ README
8
+ TODO.txt
9
+ lib/metricks.rb
10
+ lib/metricks/flog_reporter.rb
11
+ lib/metricks/md5_tracker.rb
12
+ lib/metricks/flog_reporter/base.rb
13
+ lib/metricks/flog_reporter/flog_reporter.css
14
+ lib/metricks/flog_reporter/generator.rb
15
+ lib/metricks/flog_reporter/operator.rb
16
+ lib/metricks/flog_reporter/page.rb
17
+ lib/metricks/flog_reporter/scanned_method.rb
18
+ lib/metricks/saikuro/saikuro.rb
19
+ lib/metricks/saikuro/SAIKURO_README
20
+ lib/tasks/churn.rake
21
+ lib/tasks/coverage.rake
22
+ lib/tasks/flog.rake
23
+ lib/tasks/metricks.rake
24
+ lib/tasks/metricks.rb
25
+ lib/tasks/saikuro.rake
26
+ lib/tasks/stats.rake
27
+ test/test_helper.rb
28
+ test/test_md5_tracker.rb
data/README ADDED
@@ -0,0 +1,98 @@
1
+ Version 0.4.0
2
+ http://github.com/revolutionhealth/metricks
3
+
4
+ Metricks is a fork of the metric_fu project and is a set of rake tasks that make it easy to generate metrics reports. It uses Saikuro, Flog, Rcov, and Rails' built-in stats task to create a series of reports. It's designed to integrate easily with CruiseControl.rb by placing files in the Custom Build Artifacts folder.
5
+
6
+ *Installation
7
+ sudo gem install revolutionhealth-metricks -s http://gems.github.com
8
+
9
+ Then in your Rakefile:
10
+ require 'metricks'
11
+
12
+ *Important note:
13
+ 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:
14
+ sudo gem install rcov
15
+ sudo gem install flog
16
+
17
+
18
+ *Usage
19
+
20
+ Out of the box metricks provides these tasks:
21
+ rake metricks:all
22
+ rake metricks:all_with_migrate
23
+ rake metricks:coverage
24
+ rake metricks:saikuro
25
+ rake metricks:flog
26
+ rake metricks:stats
27
+ rake metricks:churn
28
+
29
+ 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:
30
+
31
+ project.rake_task = 'metricks:all_with_migrate'
32
+ project.scheduler.polling_interval = 24.hours
33
+
34
+ Which will check for updates every 24 hours and run all the metricks rake tasks (migrating your test db first). The output will be visible from an individual build's detail page.
35
+
36
+
37
+ *Notes on metricks:coverage
38
+
39
+ When creating a coverage report, metricks 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:
40
+
41
+ namespace :metricks do
42
+ TEST_PATHS_FOR_RCOV = ['spec/**/*_spec.rb']
43
+ end
44
+
45
+ The namespace is only there for intentional purposes and isn't necessary. If you have multiple paths to test, then you can do this:
46
+
47
+ TEST_PATHS_FOR_RCOV = ['spec/**/*_spec.rb', 'test/**/*_test.rb']
48
+
49
+ 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.
50
+
51
+ If you want to change the options that Rcov is run with, then set this constant in your Rakefile:
52
+
53
+ RCOV_OPTIONS = { "--sort" => "loc" }
54
+
55
+ 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 metricks runs, open up the metricks.rake file in the plugin.
56
+
57
+
58
+ *Notes on metricks:cyclomatic_complexity
59
+
60
+ Saikuro is bundled with metricks 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:
61
+
62
+ namespace :metricks do
63
+ SAIKURO_OPTIONS = { "--warn_cyclo" => "3", "--error_cyclo" => "4" }
64
+ end
65
+
66
+ 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.
67
+
68
+
69
+ *Notes on metricks:flog
70
+
71
+ Flog is another way of measuring complexity (or tortured code as the Flog authors like to put it). Metricksmetricks 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.
72
+
73
+
74
+ *Notes on metricks:stats
75
+
76
+ 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.
77
+
78
+
79
+ *Notes on metricks:churn
80
+
81
+ Files that change a lot in your project may be bad a sign. This task uses "svn log" to identify those files and put them in a report. The default is to start counting changes from the beginning of your project, which might be too far back so you can change like so:
82
+ metricks
83
+ namespace :metricks do
84
+ CHURN_OPTIONS = { :start_date => lambda{3.months.ago} }
85
+ end
86
+
87
+ The Proc is there because '3.months.ago' only works when after the Rails Environment is loaded (and Rails extends Fixnum) which I didn't want to do every time you run a rake task.
88
+
89
+ You can also change the minimum churn count like so:
90
+
91
+ namespace :metricks do
92
+ CHURN_OPTIONS = { :minimum_churn_count => 3 }
93
+ end
94
+
95
+
96
+ *Thanks
97
+
98
+ 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.
data/TODO.txt ADDED
@@ -0,0 +1,4 @@
1
+ == TODO list
2
+
3
+ * Integrate MD5 hashing with remainder of reports
4
+ * Update README to more accurately reflect current development
@@ -0,0 +1,59 @@
1
+ module Metricks::FlogReporter
2
+
3
+ THRESHOLD = (ENV['FLOG_THRESHOLD'] || 120)
4
+ SCORE_FORMAT = "%0.2f"
5
+
6
+ class InvalidFlog < RuntimeError
7
+ end
8
+
9
+ class Base
10
+ MODULE_NAME = "([A-Z][a-z]+)+"
11
+ METHOD_NAME = "#([a-z]+_?)+"
12
+ SCORE = "\\d+\\.\\d+"
13
+
14
+ METHOD_NAME_RE = Regexp.new("#{MODULE_NAME}#{METHOD_NAME}")
15
+ SCORE_RE = Regexp.new(SCORE)
16
+
17
+ METHOD_LINE_RE = Regexp.new("#{MODULE_NAME}#{METHOD_NAME}:\\s\\(#{SCORE}\\)")
18
+ OPERATOR_LINE_RE = Regexp.new("\\s+(#{SCORE}):\\s(.*)$")
19
+
20
+ class << self
21
+ def cycle(first_value, second_value, iteration)
22
+ return first_value if iteration % 2 == 0
23
+ return second_value
24
+ end
25
+
26
+ def load_css(css_file = nil)
27
+ filepath = css_file || File.join(File.dirname(__FILE__), 'flog_reporter.css')
28
+ css = ""
29
+ file = File.open(filepath, "r")
30
+ file.each_line { |line| css << line }
31
+ file.close
32
+ css
33
+ end
34
+
35
+ def parse(text)
36
+ score = text[/score = (\d+\.\d+)/, 1]
37
+ return nil unless score
38
+ page = Page.new(score)
39
+
40
+ text.each_line do |method_line|
41
+ if METHOD_LINE_RE =~ method_line and
42
+ method_name = method_line[METHOD_NAME_RE] and
43
+ score = method_line[SCORE_RE]
44
+ page.scanned_methods << ScannedMethod.new(method_name, score)
45
+ end
46
+
47
+ if OPERATOR_LINE_RE =~ method_line and
48
+ operator = method_line[OPERATOR_LINE_RE, 2] and
49
+ score = method_line[SCORE_RE]
50
+ raise InvalidFlog if page.scanned_methods.empty?
51
+ page.scanned_methods.last.operators << Operator.new(score, operator)
52
+ end
53
+ end
54
+
55
+ page
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,39 @@
1
+ body {
2
+ background-color: rgb(240, 240, 245);
3
+ font-family: verdana, arial, helvetica;
4
+ }
5
+
6
+ table {
7
+ border-collapse: collapse;
8
+ }
9
+
10
+ table.report {
11
+ width: 100%;
12
+ }
13
+
14
+ table th {
15
+ text-align: center;
16
+ }
17
+
18
+ table td.score {
19
+ text-align: right;
20
+ }
21
+
22
+ table th {
23
+ background: #dcecff;
24
+ border: #d0d0d0 1px solid;
25
+ font-weight: bold;
26
+ }
27
+
28
+ table td {
29
+ border: #d0d0d0 1px solid;
30
+ }
31
+
32
+ table tr.light {
33
+ background-color: rgb(240, 240, 245);
34
+ }
35
+
36
+ table tr.dark {
37
+ background-color: rgb(230, 230, 235);
38
+ }
39
+
@@ -0,0 +1,71 @@
1
+ module Metricks::FlogReporter
2
+ class Generator
3
+ class << self
4
+ def generate_report(base_dir)
5
+ flog_hashes = []
6
+ Dir.glob("#{base_dir}/**/*.txt").each do |filename|
7
+ content = ""
8
+ File.open(filename, "r").each_line do |file|
9
+ content << file
10
+ end
11
+
12
+ begin
13
+ page = Base.parse(content)
14
+ rescue InvalidFlog
15
+ puts "Invalid flog for #{filename}"
16
+ next
17
+ end
18
+
19
+ next unless page
20
+
21
+ if Metricks::MD5Tracker.file_already_counted?(filename)
22
+ flog_hashes << {
23
+ :page => page,
24
+ :path => filename.sub('.txt', '.html').sub("#{base_dir}/", "")
25
+ }
26
+ else
27
+ flog_hashes << generate_page(filename, page, base_dir)
28
+ end
29
+ end
30
+
31
+ generate_index(flog_hashes, base_dir)
32
+ end
33
+
34
+ def generate_page(filename, page, base_dir)
35
+ html_file = File.new(filename.gsub(/\.txt/, '.html'), "w")
36
+ html_file.puts page.to_html
37
+ html_file.close
38
+ return { :path => html_file.path.sub("#{base_dir}/", ''),
39
+ :page => page }
40
+ end
41
+
42
+ def generate_index(flog_hashes, base_dir)
43
+ html = "<html><head><title>Flog Reporter</title><style>"
44
+ html << Base.load_css
45
+ html << "</style></head><body>"
46
+ html << "<p><strong>Flogged files</strong></p>\n"
47
+ html << "<p>Generated on #{Time.now.localtime} with <a href='http://ruby.sadi.st/Flog.html'>flog</a></p>\n"
48
+ html << "<table class='report'>\n"
49
+ html << "<tr><th>File</th><th>Total score</th><th>Methods</th><th>Average score</th><th>Highest score</th></tr>"
50
+ count = 0
51
+ flog_hashes.each do |flog_hash|
52
+ html << <<-EOF
53
+ <tr class='#{Base.cycle("light", "dark", count)}'>
54
+ <td><a href='#{flog_hash[:path]}'>#{flog_hash[:path].sub('.html', '.rb')}</a></td>
55
+ <td class='score'>#{sprintf(SCORE_FORMAT, flog_hash[:page].score)}</td>
56
+ <td class='score'>#{flog_hash[:page].scanned_methods.length}</td>
57
+ <td class='score'>#{sprintf(SCORE_FORMAT, flog_hash[:page].average_score)}</td>
58
+ <td class='score'>#{sprintf(SCORE_FORMAT, flog_hash[:page].highest_score)}</td>
59
+ </tr>
60
+ EOF
61
+ count += 1
62
+ end
63
+ html << "</table>\n"
64
+ html << "</body></html>\n"
65
+ index = File.new("#{base_dir}/index.html", "w")
66
+ index.puts html
67
+ index.close
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,10 @@
1
+ module Metricks::FlogReporter
2
+ class Operator
3
+ attr_accessor :score, :operator
4
+
5
+ def initialize(score, operator)
6
+ @score = score.to_f
7
+ @operator = operator
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,36 @@
1
+ module Metricks::FlogReporter
2
+ class Page
3
+ attr_accessor :score, :scanned_methods
4
+
5
+ def initialize(score, scanned_methods = [])
6
+ @score = score.to_f
7
+ @scanned_methods = scanned_methods
8
+ end
9
+
10
+ def to_html
11
+ output = "<html><head><style>"
12
+ output << Base.load_css
13
+ output << "</style></head><body>"
14
+ output << "Score: #{score}\n"
15
+ scanned_methods.each do |sm|
16
+ output << sm.to_html
17
+ end
18
+ output << "</body></html>"
19
+ output
20
+ end
21
+
22
+ def average_score
23
+ sum = 0
24
+ scanned_methods.each do |m|
25
+ sum += m.score
26
+ end
27
+ sum / scanned_methods.length
28
+ end
29
+
30
+ def highest_score
31
+ scanned_methods.inject(0) do |highest, m|
32
+ m.score > highest ? m.score : highest
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,28 @@
1
+ module Metricks::FlogReporter
2
+ class ScannedMethod
3
+ attr_accessor :name, :score, :operators
4
+
5
+ def initialize(name, score, operators = [])
6
+ @name = name
7
+ @score = score.to_f
8
+ @operators = operators
9
+ end
10
+
11
+ def to_html
12
+ output = "<p><strong>#{name} (#{score})</strong></p>\n"
13
+ output << "<table>\n"
14
+ output << "<tr><th>Score</th><th>Operator</th></tr>\n"
15
+ count = 0
16
+ operators.each do |operator|
17
+ output << <<-EOF
18
+ <tr class='#{Base.cycle("light", "dark", count)}'>
19
+ <td class='score'>#{sprintf(SCORE_FORMAT, operator.score)}</td>
20
+ <td class='score'>#{operator.operator}</td>
21
+ </tr>
22
+ EOF
23
+ count += 1
24
+ end
25
+ output << "</table>\n\n"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ require File.join(File.dirname(__FILE__), 'flog_reporter', 'base')
2
+ require File.join(File.dirname(__FILE__), 'flog_reporter', 'page')
3
+ require File.join(File.dirname(__FILE__), 'flog_reporter', 'scanned_method')
4
+ require File.join(File.dirname(__FILE__), 'flog_reporter', 'operator')
5
+ require File.join(File.dirname(__FILE__), 'flog_reporter', 'generator')
@@ -0,0 +1,52 @@
1
+ require 'digest/md5'
2
+ require 'fileutils'
3
+
4
+ module Metricks
5
+ class MD5Tracker
6
+
7
+ @@unchanged_md5s = []
8
+
9
+ class << self
10
+ def md5_dir(path_to_file, base_dir)
11
+ File.join(base_dir,
12
+ path_to_file.split('/')[0..-2].join('/'))
13
+ end
14
+
15
+ def md5_file(path_to_file, base_dir)
16
+ File.join(md5_dir(path_to_file, base_dir),
17
+ path_to_file.split('/').last.sub(/\.[a-z]+/, '.md5'))
18
+ end
19
+
20
+ def track(path_to_file, base_dir)
21
+ md5 = Digest::MD5.hexdigest(File.read(path_to_file))
22
+ FileUtils.mkdir_p(md5_dir(path_to_file, base_dir), :verbose => false)
23
+ f = File.new(md5_file(path_to_file, base_dir), "w")
24
+ f.puts(md5)
25
+ f.close
26
+ md5
27
+ end
28
+
29
+ def file_changed?(path_to_file, base_dir)
30
+ orig_md5_file = md5_file(path_to_file, base_dir)
31
+ return track(path_to_file, base_dir) unless File.exist?(orig_md5_file)
32
+
33
+ current_md5 = ""
34
+ file = File.open(orig_md5_file, 'r')
35
+ file.each_line { |line| current_md5 << line }
36
+ file.close
37
+ current_md5.chomp!
38
+
39
+ new_md5 = Digest::MD5.hexdigest(File.read(path_to_file))
40
+ new_md5.chomp!
41
+
42
+ @@unchanged_md5s << path_to_file if new_md5 == current_md5
43
+
44
+ return new_md5 != current_md5
45
+ end
46
+
47
+ def file_already_counted?(path_to_file)
48
+ return @@unchanged_md5s.include?(path_to_file)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,142 @@
1
+ Version 0.2
2
+
3
+ Saikuro:
4
+ Saikuro is a Ruby cyclomatic complexity analyzer. When given Ruby
5
+ source code Saikuro will generate a report listing the cyclomatic
6
+ complexity of each method found. In addition, Saikuro counts the
7
+ number of lines per method and can generate a listing of the number of
8
+ tokens on each line of code.
9
+
10
+ License:
11
+ Saikuro uses the BSD license.
12
+
13
+ Installation:
14
+ Option 1: Using setup.rb
15
+ * login as root
16
+ * run "ruby setup.rb all"
17
+
18
+ Option 2: The manual way
19
+ Saikuro is a single Ruby file that is executable. You can run it where
20
+ you unpacked it or you can move it your preferred location such as
21
+ "/usr/local/bin" or "~/bin".
22
+
23
+ Note:
24
+ Ruby 1.8.5 has a bug in ri_options that will prevent Saikuro from
25
+ running. If you are using 1.8.5 please apply this patch :
26
+ http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/lib/rdoc/ri/ri_options.rb.diff?r1=1.2.2.13;r2=1.2.2.14
27
+
28
+
29
+ Usage:
30
+ Saikuro is a command line program.
31
+ Running "saikuro -h" will output a usage statement describing all
32
+ the various arguments you can pass to it.
33
+
34
+ "saikuro -c -p tests/samples.rb"
35
+
36
+ The above command is a simple example that generates a cyclomatic
37
+ complexity report on the samples.rb file, using the default filter,
38
+ warning and error settings. The report is saved in the current
39
+ directory.
40
+
41
+
42
+ A more detailed example is
43
+ "saikuro -c -t -i tests -y 0 -w 11 -e 16 -o out/"
44
+
45
+ This will analyze all Ruby files found in the "tests/" directory.
46
+ Saikuro will generate a token count report and a cyclomatic complexity
47
+ report in the "out" directory . The "-y 0" command will turn off
48
+ filtering and thus show the complexity of all methods. The "-w 11"
49
+ will mark all methods with a complexity of 11 or higher with a
50
+ warning. Finally, "-e 16" will flag all methods with a complexity of
51
+ 16 or higher with an error.
52
+
53
+
54
+ About Cyclomatic Complexity:
55
+
56
+ The following document provides a very good and detailed description
57
+ by the author of cyclomatic complexity.
58
+
59
+ NIST Special Publication 500-235
60
+ Structured Testing: A Testing Methodology Using the Cyclomatic
61
+ Complexity Metric
62
+
63
+ By Arthur H. Watson and Thomas J. McCabe
64
+ HTML
65
+ http://hissa.nist.gov/HHRFdata/Artifacts/ITLdoc/235/title.htm
66
+ PDF
67
+ http://www.mccabe.com/iq_research_nist.htm
68
+
69
+
70
+ How and what Saikuro counts to calculate the cyclomatic complexity:
71
+
72
+ Saikuro uses the Simplified Complexity Calculation, which is just
73
+ adding up the number of branch points in a method.
74
+
75
+ Each method starts with a complexity of 1, because there is at least
76
+ one path through the code. Then each conditional or looping operator
77
+ (if, unless, while, until, for, elsif, when) adds one point to the
78
+ complexity. Each "when" in a case statement adds one point. Also each
79
+ "rescue" statement adds one.
80
+
81
+ Saikuro also regards blocks as an addition to a method's complexity
82
+ because in many cases a block does add a path that may be traversed.
83
+ For example, invoking the "each" method of an array with a block would
84
+ only traverse the give block if the array is not empty. Thus if you
85
+ want to find the basis set to get 100% coverage of your code then a
86
+ block should add one point to the method's complexity. It is not yet
87
+ for sure however to what level the accuracy is decreased through this
88
+ measurement, as normal Ruby code uses blocks quite heavily and new
89
+ paths are not necessarily introduced by every block.
90
+
91
+ In addition, the short-circuiting "and" operators (&& and "and")
92
+ currently do not contribute to a method's complexity, although
93
+ McCabe's paper listed above suggests doing so.
94
+
95
+
96
+ #Example for "and" operator handling:
97
+
98
+ # Starting values for case 1 and 2
99
+ x = false
100
+ y = 15
101
+ r, q = nil
102
+
103
+ # case 1
104
+ puts "W" if ((r = x) && (q = y))
105
+ puts r # => false
106
+ puts q # => nil
107
+
108
+ # case 2
109
+ puts "W" if ((q = y) && (r = x))
110
+ puts r # => false
111
+ puts q # => 15
112
+
113
+ Case 1 illustrates why "and" operators should add to a method's
114
+ complexity, because the result of ( r = x ) is false the if statement
115
+ stops and returns false without evaluating the ( q = y ) branch. Thus
116
+ if a total coverage of source code is desired, one point should be
117
+ added to the method's complexity.
118
+
119
+ So why is it not added?
120
+ Mainly, because we have not gotten around to it. We are wondering if
121
+ this would increase the noise more than it should.
122
+
123
+
124
+ Tests:
125
+ In the test directory is a sample file that has examples of the
126
+ various possible cases that we examined and documented the expected
127
+ cyclomatic complexity result. If you find mistakes or missing tests
128
+ please report them.
129
+
130
+ Contact:
131
+ Saikuro is written by
132
+ Zev Blut (zb at ubit dot com)
133
+
134
+ Acknowledgments:
135
+ Thanks to Elbert Corpuz for writing the CSS for the HTML output!
136
+
137
+ Other metric tools for Ruby:
138
+ Ryan Davis has an abc metric program as an example in his ParseTree
139
+ product: http://www.zenspider.com/ZSS/Products/ParseTree/
140
+
141
+ The PMD project has a tool called CPD that can scan Ruby source code
142
+ looking for source duplication: http://pmd.sourceforge.net/