p8-metric_fu 0.8.4.16 → 0.8.9
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/HISTORY +12 -0
 - data/MIT-LICENSE +1 -1
 - data/README +3 -3
 - data/lib/metric_fu/base.rb +2 -2
 - data/lib/metric_fu/flog.rb +9 -19
 - data/lib/tasks/railroad.rake +10 -7
 - data/spec/flog_spec.rb +61 -0
 - metadata +2 -2
 
    
        data/HISTORY
    CHANGED
    
    | 
         @@ -1,3 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            === MetricFu 0.8.9 / 2009-1-20
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            * Thanks to Andre Arko and Petrik de Heus for adding the following features:
         
     | 
| 
      
 4 
     | 
    
         
            +
            * The source control type is auto-detected for Churn
         
     | 
| 
      
 5 
     | 
    
         
            +
            * Moved all presentation to templates
         
     | 
| 
      
 6 
     | 
    
         
            +
            * Wrote specs for all classes
         
     | 
| 
      
 7 
     | 
    
         
            +
            * Added flay, Reek and Roodi metrics
         
     | 
| 
      
 8 
     | 
    
         
            +
            * There's now a configuration class (see README for details)
         
     | 
| 
      
 9 
     | 
    
         
            +
            * Unification of metrics reports
         
     | 
| 
      
 10 
     | 
    
         
            +
            * Metrics can be generated using one command
         
     | 
| 
      
 11 
     | 
    
         
            +
            * Adding new metrics reports has been standardized
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
       1 
13 
     | 
    
         
             
            === MetricFu 0.8.0 / 2008-10-06
         
     | 
| 
       2 
14 
     | 
    
         | 
| 
       3 
15 
     | 
    
         
             
            * Source Control Churn now supports git (thanks to Erik St Martin)
         
     | 
    
        data/MIT-LICENSE
    CHANGED
    
    
    
        data/README
    CHANGED
    
    | 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            Version 0.8. 
     | 
| 
      
 1 
     | 
    
         
            +
            Version 0.8.9
         
     | 
| 
       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.  
         
     | 
| 
         @@ -12,7 +12,7 @@ Then in your Rakefile: 
     | 
|
| 
       12 
12 
     | 
    
         
             
            require 'metric_fu'
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
            If you like to vendor gems, you can unpack metric_fu into vendor/gems and require it like so:
         
     | 
| 
       15 
     | 
    
         
            -
            require 'vendor/gems/jscruggs-metric_fu-0.8. 
     | 
| 
      
 15 
     | 
    
         
            +
            require 'vendor/gems/jscruggs-metric_fu-0.8.9/lib/metric_fu'
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
            then you don't have to install it on every box you run it on.
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
         @@ -144,4 +144,4 @@ You can also change the minimum churn count like so: 
     | 
|
| 
       144 
144 
     | 
    
         | 
| 
       145 
145 
     | 
    
         
             
            ****Thanks****
         
     | 
| 
       146 
146 
     | 
    
         | 
| 
       147 
     | 
    
         
            -
            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.
         
     | 
| 
      
 147 
     | 
    
         
            +
            I'd like to thank the authors of Saikuro, Flog, Rcov, CruiseControl.rb, Flay, Reek, Roodi and Rails for creating such excellent open source products.  Also Andre Arko, Petrik de Heus, Sean Soper, Erik St Martin, Andy Gregorowicz, Bastien, Michael Schubert, Kurtis Seebaldt, Toby Tripp, Paul Gross, and Chirdeep Shetty for their help and advice.
         
     | 
    
        data/lib/metric_fu/base.rb
    CHANGED
    
    | 
         @@ -70,9 +70,9 @@ module MetricFu 
     | 
|
| 
       70 
70 
     | 
    
         
             
                  def link_to_filename(name, line = nil)
         
     | 
| 
       71 
71 
     | 
    
         
             
                    filename = File.expand_path(name)
         
     | 
| 
       72 
72 
     | 
    
         
             
                    if PLATFORM['darwin']
         
     | 
| 
       73 
     | 
    
         
            -
                      %{<a href="txmt://open/?url=file://#{filename}&line=#{line}">#{name}</a>}
         
     | 
| 
      
 73 
     | 
    
         
            +
                      %{<a href="txmt://open/?url=file://#{filename}&line=#{line}">#{name}:#{line}</a>}
         
     | 
| 
       74 
74 
     | 
    
         
             
                    else
         
     | 
| 
       75 
     | 
    
         
            -
                      %{<a href="file://#{filename}">#{name}</a>}
         
     | 
| 
      
 75 
     | 
    
         
            +
                      %{<a href="file://#{filename}">#{name}:#{line}</a>}
         
     | 
| 
       76 
76 
     | 
    
         
             
                    end
         
     | 
| 
       77 
77 
     | 
    
         
             
                  end
         
     | 
| 
       78 
78 
     | 
    
         | 
    
        data/lib/metric_fu/flog.rb
    CHANGED
    
    | 
         @@ -45,15 +45,8 @@ module MetricFu 
     | 
|
| 
       45 
45 
     | 
    
         
             
                SCORE_FORMAT = "%0.2f"
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
       47 
47 
     | 
    
         
             
                class Base
         
     | 
| 
       48 
     | 
    
         
            -
                   
     | 
| 
       49 
     | 
    
         
            -
                   
     | 
| 
       50 
     | 
    
         
            -
                  SCORE = "\\d+\\.\\d+"
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                  METHOD_NAME_RE = Regexp.new("#{MODULE_NAME}#{METHOD_NAME}")
         
     | 
| 
       53 
     | 
    
         
            -
                  SCORE_RE = Regexp.new(SCORE)
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                  METHOD_LINE_RE = Regexp.new("#{MODULE_NAME}#{METHOD_NAME}:\\s\\(#{SCORE}\\)")
         
     | 
| 
       56 
     | 
    
         
            -
                  OPERATOR_LINE_RE = Regexp.new("\\s+(#{SCORE}):\\s(.*)$")
         
     | 
| 
      
 48 
     | 
    
         
            +
                  METHOD_LINE_REGEX = /([A-Za-z]+#.*):\s\((\d+\.\d+)\)/
         
     | 
| 
      
 49 
     | 
    
         
            +
                  OPERATOR_LINE_REGEX = /\s+(\d+\.\d+):\s(.*)$/
         
     | 
| 
       57 
50 
     | 
    
         | 
| 
       58 
51 
     | 
    
         
             
                  class << self
         
     | 
| 
       59 
52 
     | 
    
         | 
| 
         @@ -63,21 +56,18 @@ module MetricFu 
     | 
|
| 
       63 
56 
     | 
    
         
             
                      page = Page.new(score)
         
     | 
| 
       64 
57 
     | 
    
         | 
| 
       65 
58 
     | 
    
         
             
                      text.each_line do |method_line|
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                           score = method_line[SCORE_RE]
         
     | 
| 
       69 
     | 
    
         
            -
                           page.scanned_methods << ScannedMethod.new(method_name, score)
         
     | 
| 
      
 59 
     | 
    
         
            +
                       if match = method_line.match(METHOD_LINE_REGEX)
         
     | 
| 
      
 60 
     | 
    
         
            +
                          page.scanned_methods << ScannedMethod.new(match[1], match[2])
         
     | 
| 
       70 
61 
     | 
    
         
             
                        end
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
                        if  
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
                           return if page.scanned_methods.empty?
         
     | 
| 
       76 
     | 
    
         
            -
                           page.scanned_methods.last.operators << Operator.new(score, operator)
         
     | 
| 
      
 62 
     | 
    
         
            +
                        
         
     | 
| 
      
 63 
     | 
    
         
            +
                        if match = method_line.match(OPERATOR_LINE_REGEX)
         
     | 
| 
      
 64 
     | 
    
         
            +
                          return if page.scanned_methods.empty?
         
     | 
| 
      
 65 
     | 
    
         
            +
                          page.scanned_methods.last.operators << Operator.new(match[1], match[2])
         
     | 
| 
       77 
66 
     | 
    
         
             
                        end
         
     | 
| 
       78 
67 
     | 
    
         
             
                      end
         
     | 
| 
       79 
68 
     | 
    
         
             
                      page
         
     | 
| 
       80 
69 
     | 
    
         
             
                    end
         
     | 
| 
      
 70 
     | 
    
         
            +
                    
         
     | 
| 
       81 
71 
     | 
    
         
             
                  end
         
     | 
| 
       82 
72 
     | 
    
         
             
                end 
         
     | 
| 
       83 
73 
     | 
    
         | 
    
        data/lib/tasks/railroad.rake
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            namespace :metrics do
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
              RAILROAD_DIR = File.join(MetricFu::BASE_DIRECTORY, 'railroad')
         
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
      
 4 
     | 
    
         
            +
              RAILROAD_FILE = File.join(RAILROAD_DIR, 'index.html')
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
              task :railroad => ['railroad:all'] do
         
     | 
| 
       7 
7 
     | 
    
         
             
              end
         
     | 
| 
         @@ -15,20 +15,23 @@ namespace :metrics do 
     | 
|
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
                desc "Create a railroad models report"
         
     | 
| 
       17 
17 
     | 
    
         
             
                task :models do
         
     | 
| 
       18 
     | 
    
         
            -
                  mkdir_p(RAILROAD_DIR) unless File.directory?(RAILROAD_DIR)
         
     | 
| 
       19 
     | 
    
         
            -
                  `railroad -M -a -m -l -v | neato -Tpng > #{File.join( 
     | 
| 
      
 18 
     | 
    
         
            +
                  #mkdir_p(RAILROAD_DIR) unless File.directory?(RAILROAD_DIR)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  `railroad -M -a -m -l -v | neato -Tpng > #{File.join(MetricFu::BASE_DIRECTORY,'model-diagram.png')}`
         
     | 
| 
      
 20 
     | 
    
         
            +
                  #`echo "<a href=\"railroad/models.png\">Model diagram</a><br />" >> #{RAILROAD_FILE}`
         
     | 
| 
       20 
21 
     | 
    
         
             
                end
         
     | 
| 
       21 
22 
     | 
    
         | 
| 
       22 
23 
     | 
    
         
             
                desc "Create a railroad controllers report"
         
     | 
| 
       23 
24 
     | 
    
         
             
                task :controllers do
         
     | 
| 
       24 
     | 
    
         
            -
                  mkdir_p(RAILROAD_DIR) unless File.directory?(RAILROAD_DIR)
         
     | 
| 
       25 
     | 
    
         
            -
                  `railroad -C -l -v | neato -Tpng > #{File.join( 
     | 
| 
      
 25 
     | 
    
         
            +
                  #mkdir_p(RAILROAD_DIR) unless File.directory?(RAILROAD_DIR)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  `railroad -C -l -v | neato -Tpng > #{File.join(MetricFu::BASE_DIRECTORY,'controller-diagram.png')}`
         
     | 
| 
      
 27 
     | 
    
         
            +
                  #`echo "<a href=\"railroad/controllers.png\">Controller diagram</a><br />" >> #{RAILROAD_FILE}`
         
     | 
| 
       26 
28 
     | 
    
         
             
                end
         
     | 
| 
       27 
29 
     | 
    
         | 
| 
       28 
30 
     | 
    
         
             
                desc "Create a railroad acts_as_state_machine report"
         
     | 
| 
       29 
31 
     | 
    
         
             
                task :aasm do
         
     | 
| 
       30 
     | 
    
         
            -
                  mkdir_p(RAILROAD_DIR) unless File.directory?(RAILROAD_DIR)
         
     | 
| 
       31 
     | 
    
         
            -
                  `railroad -A -l -v | neato -Tpng > #{File.join( 
     | 
| 
      
 32 
     | 
    
         
            +
                  #mkdir_p(RAILROAD_DIR) unless File.directory?(RAILROAD_DIR)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  `railroad -A -l -v | neato -Tpng > #{File.join(MetricFu::BASE_DIRECTORY,'aasm-diagram.png')}`
         
     | 
| 
      
 34 
     | 
    
         
            +
                  #`echo "<a href=\"railroad/aasm.png\">State machine diagram</a><br />" >> #{RAILROAD_FILE}`
         
     | 
| 
       32 
35 
     | 
    
         
             
                end
         
     | 
| 
       33 
36 
     | 
    
         | 
| 
       34 
37 
     | 
    
         
             
              end
         
     | 
    
        data/spec/flog_spec.rb
    CHANGED
    
    | 
         @@ -45,6 +45,67 @@ BM 
     | 
|
| 
       45 
45 
     | 
    
         
             
                     1.1: entryRelationship
         
     | 
| 
       46 
46 
     | 
    
         
             
            IM
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
      
 48 
     | 
    
         
            +
                @assignment_method = <<-MTHD
         
     | 
| 
      
 49 
     | 
    
         
            +
                Total Flog = 21.6 (5.4 +/- 3.3 flog / method)
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                ActivityReport#existing_measure_attributes=: (8.5)
         
     | 
| 
      
 52 
     | 
    
         
            +
                     4.1: assignment
         
     | 
| 
      
 53 
     | 
    
         
            +
                     1.8: id
         
     | 
| 
      
 54 
     | 
    
         
            +
                     1.6: to_s
         
     | 
| 
      
 55 
     | 
    
         
            +
                     1.4: []
         
     | 
| 
      
 56 
     | 
    
         
            +
                     1.4: activity_report_measures
         
     | 
| 
      
 57 
     | 
    
         
            +
                     1.2: each
         
     | 
| 
      
 58 
     | 
    
         
            +
                     1.2: branch
         
     | 
| 
      
 59 
     | 
    
         
            +
                MTHD
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                @class_methods_grouped_together = <<-MTHD
         
     | 
| 
      
 62 
     | 
    
         
            +
                Total Flog = 61.8 (7.7 +/- 95.3 flog / method)
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                User#none: (32.8)
         
     | 
| 
      
 65 
     | 
    
         
            +
                     7.2: include
         
     | 
| 
      
 66 
     | 
    
         
            +
                     3.6: validates_length_of
         
     | 
| 
      
 67 
     | 
    
         
            +
                     3.6: validates_format_of
         
     | 
| 
      
 68 
     | 
    
         
            +
                     2.4: validates_presence_of
         
     | 
| 
      
 69 
     | 
    
         
            +
                     2.4: validates_uniqueness_of
         
     | 
| 
      
 70 
     | 
    
         
            +
                     1.4: bad_login_message
         
     | 
| 
      
 71 
     | 
    
         
            +
                     1.4: name_regex
         
     | 
| 
      
 72 
     | 
    
         
            +
                     1.4: bad_email_message
         
     | 
| 
      
 73 
     | 
    
         
            +
                     1.4: bad_name_message
         
     | 
| 
      
 74 
     | 
    
         
            +
                     1.4: login_regex
         
     | 
| 
      
 75 
     | 
    
         
            +
                     1.4: email_regex
         
     | 
| 
      
 76 
     | 
    
         
            +
                     1.2: private
         
     | 
| 
      
 77 
     | 
    
         
            +
                     1.2: has_and_belongs_to_many
         
     | 
| 
      
 78 
     | 
    
         
            +
                     1.2: before_create
         
     | 
| 
      
 79 
     | 
    
         
            +
                     1.2: attr_accessible
         
     | 
| 
      
 80 
     | 
    
         
            +
                     0.4: lit_fixnum
         
     | 
| 
      
 81 
     | 
    
         
            +
                MTHD
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
              
         
     | 
| 
      
 84 
     | 
    
         
            +
              it "should be able to parse class_methods_grouped_together" do
         
     | 
| 
      
 85 
     | 
    
         
            +
                page = Base.parse(@class_methods_grouped_together)
         
     | 
| 
      
 86 
     | 
    
         
            +
                page.should_not be_nil
         
     | 
| 
      
 87 
     | 
    
         
            +
                page.score.should == 61.8
         
     | 
| 
      
 88 
     | 
    
         
            +
                page.scanned_methods.size.should == 1
         
     | 
| 
      
 89 
     | 
    
         
            +
                sm = page.scanned_methods.first
         
     | 
| 
      
 90 
     | 
    
         
            +
                sm.name.should == 'User#none'
         
     | 
| 
      
 91 
     | 
    
         
            +
                sm.score.should == 32.8
         
     | 
| 
      
 92 
     | 
    
         
            +
                
         
     | 
| 
      
 93 
     | 
    
         
            +
                sm.operators.size.should == 16
         
     | 
| 
      
 94 
     | 
    
         
            +
                sm.operators.first.score.should == 7.2
         
     | 
| 
      
 95 
     | 
    
         
            +
                sm.operators.first.operator.should == "include"
         
     | 
| 
      
 96 
     | 
    
         
            +
                
         
     | 
| 
      
 97 
     | 
    
         
            +
                sm.operators.last.score.should == 0.4
         
     | 
| 
      
 98 
     | 
    
         
            +
                sm.operators.last.operator.should == "lit_fixnum"
         
     | 
| 
      
 99 
     | 
    
         
            +
              end
         
     | 
| 
      
 100 
     | 
    
         
            +
              
         
     | 
| 
      
 101 
     | 
    
         
            +
              it "should be able to parse an assignment method" do
         
     | 
| 
      
 102 
     | 
    
         
            +
                page = Base.parse(@assignment_method)
         
     | 
| 
      
 103 
     | 
    
         
            +
                page.should_not be_nil
         
     | 
| 
      
 104 
     | 
    
         
            +
                page.score.should == 21.6
         
     | 
| 
      
 105 
     | 
    
         
            +
                page.scanned_methods.size.should == 1
         
     | 
| 
      
 106 
     | 
    
         
            +
                sm = page.scanned_methods.first
         
     | 
| 
      
 107 
     | 
    
         
            +
                sm.name.should == 'ActivityReport#existing_measure_attributes='
         
     | 
| 
      
 108 
     | 
    
         
            +
                sm.score.should == 8.5
         
     | 
| 
       48 
109 
     | 
    
         
             
              end
         
     | 
| 
       49 
110 
     | 
    
         | 
| 
       50 
111 
     | 
    
         
             
              it "should be able to parse an alpha only method" do
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: p8-metric_fu
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.8. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.8.9
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Jake Scruggs
         
     | 
| 
         @@ -69,7 +69,7 @@ dependencies: 
     | 
|
| 
       69 
69 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
       70 
70 
     | 
    
         
             
                    version: 0.0.0
         
     | 
| 
       71 
71 
     | 
    
         
             
                version: 
         
     | 
| 
       72 
     | 
    
         
            -
            description: Code metrics from Flog, Flay, RCov, Saikuro, Churn, and Rails' stats task
         
     | 
| 
      
 72 
     | 
    
         
            +
            description: Code metrics from Flog, Flay, RCov, Saikuro, Churn, Reek, Roodi and Rails' stats task
         
     | 
| 
       73 
73 
     | 
    
         
             
            email: jake.scruggs@gmail.com
         
     | 
| 
       74 
74 
     | 
    
         
             
            executables: []
         
     | 
| 
       75 
75 
     | 
    
         |