metric_fu 4.1.3 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ### Master
2
2
 
3
+ ### MetricFu 4.2.0 / 2013-05-20
4
+
5
+ * Features
6
+ * Allow setting of the --continue flag with flog (Eric Wollesen)
7
+ *Fixes
8
+ * Allow the 2.0.x point releases (Benjamin Fleischer #75)
9
+ * Misc
10
+ * Make Location and AnalyzedProblems code more confident (Avdi Grimm)
11
+
3
12
  ### MetricFu 4.1.3 / 2013-05-13
4
13
 
5
14
  * Features
data/Rakefile CHANGED
@@ -1,6 +1,11 @@
1
1
  #!/usr/bin/env rake
2
2
  require 'bundler/setup'
3
- require 'bundler/gem_tasks'
3
+
4
+
5
+ Dir['./gem_tasks/*.rake'].each do |task|
6
+ import(task)
7
+ end
8
+
4
9
  # $LOAD_PATH << '.'
5
10
  begin
6
11
  require 'spec/rake/spectask'
data/TODO.md CHANGED
@@ -35,6 +35,10 @@ Also see [CONTRIBUTING](./CONTRIBUTING.md)
35
35
 
36
36
  ## Misc
37
37
 
38
+ ### Work on dependent libraries
39
+
40
+ * Look into getting rails_best_practices, cane, and flog to use a non-MRI-specific parser, such as [parser](https://github.com/whitequark/parser/), aka not Ripper
41
+
38
42
  ### Improvements
39
43
 
40
44
  * See TODO items in the code
File without changes
@@ -0,0 +1 @@
1
+ 9dab16044285faa2d79afc40e701fb35d7e41d658d147bb161f616676f3258e069c1e250c1d854460e67ca1674ae286265f43dcd50255416c0e6d8e9e919b516
@@ -0,0 +1,46 @@
1
+ # see http://blog.jayfields.com/2008/02/rake-task-overwriting.html
2
+ desc 'override bundler release task'
3
+ task :release => ['build'] do
4
+ STDOUT.puts "Running Bundler Release Task Override"
5
+ end
6
+ require 'bundler/gem_tasks'
7
+
8
+ GEMSPEC = Bundler::GemHelper.gemspec
9
+
10
+ # bundler-free alternative
11
+ # packaging
12
+ # https://github.com/YorickPeterse/ruby-lint/blob/master/Rakefile
13
+ # require 'rubygems/package_task'
14
+ # GEMSPEC = Gem::Specification.load('metric_fu.gemspec')
15
+ #
16
+ # Gem::PackageTask.new(GEMSPEC) do |pkg|
17
+ # pkg.need_tar = false
18
+ # pkg.need_zip = false
19
+ # end
20
+
21
+ # gem signing
22
+ # desc 'Builds and signs a new Gem'
23
+ # task :build => [:gem] do
24
+ # name = "#{GEMSPEC.name}-#{GEMSPEC.version}.gem"
25
+ # path = File.join(File.expand_path('../../pkg', __FILE__), name)
26
+ #
27
+ # sh("gem sign #{path}")
28
+ #
29
+ # Rake::Task['checksum'].invoke
30
+ # end
31
+
32
+ require 'digest/sha2'
33
+
34
+ desc 'Creates a SHA512 checksum of the current version'
35
+ task :checksum => ['build'] do
36
+ checksums = File.expand_path('../../checksum', __FILE__)
37
+ name = "#{GEMSPEC.name}-#{GEMSPEC.version}.gem"
38
+ path = File.join(File.expand_path('../../pkg', __FILE__), name)
39
+
40
+ checksum_name = File.basename(path) + '.sha512'
41
+ checksum = Digest::SHA512.new.hexdigest(File.read(path))
42
+
43
+ File.open(File.join(checksums, checksum_name), 'w') do |handle|
44
+ handle.write(checksum)
45
+ end
46
+ end
@@ -5,28 +5,21 @@ module MetricFu
5
5
  attr_accessor :class_name, :method_name, :file_path, :simple_method_name, :hash
6
6
 
7
7
  def self.get(file_path, class_name, method_name)
8
- # This could be more 'confident' using Maybe, but we want it to be as fast as possible
9
- file_path_copy = file_path == nil ? nil : file_path.clone
10
- class_name_copy = class_name == nil ? nil : class_name.clone
11
- method_name_copy = method_name == nil ? nil : method_name.clone
12
- key = [file_path_copy, class_name_copy, method_name_copy]
8
+ location = new(file_path, class_name, method_name)
13
9
  @@locations ||= {}
14
- if @@locations.has_key?(key)
15
- @@locations[key]
16
- else
17
- location = self.new(file_path_copy, class_name_copy, method_name_copy)
18
- @@locations[key] = location
19
- location.freeze # we cache a lot of method call results, so we want location to be immutable
10
+ @@locations.fetch(location.to_key) do
11
+ @@locations[location.to_key] = location
12
+ location.finalize
20
13
  location
21
14
  end
22
15
  end
23
16
 
24
17
  def initialize(file_path, class_name, method_name)
25
- @file_path = file_path
26
- @class_name = class_name
27
- @method_name = method_name
28
- @simple_method_name = @method_name.sub(@class_name,'') unless @method_name == nil
29
- @hash = [@file_path, @class_name, @method_name].hash
18
+ @file_path = file_path
19
+ @class_name = class_name
20
+ @method_name = method_name
21
+ @simple_method_name = @method_name.to_s.sub(@class_name.to_s,'')
22
+ @hash = to_key.hash
30
23
  end
31
24
 
32
25
  # TODO - we need this method (and hash accessor above) as a temporary hack where we're using Location as a hash key
@@ -69,6 +62,17 @@ module MetricFu
69
62
  [self.file_path.to_s, self.class_name.to_s, self.method_name.to_s] <=> [other.file_path.to_s, other.class_name.to_s, other.method_name.to_s]
70
63
  end
71
64
 
65
+ def to_key
66
+ [@file_path, @class_name, @method_name]
67
+ end
68
+
69
+ def finalize
70
+ @file_path &&= @file_path.clone
71
+ @class_name &&= @class_name.clone
72
+ @method_name &&= @method_name.clone
73
+ freeze # we cache a lot of method call results, so we want location to be immutable
74
+ end
75
+
72
76
  private
73
77
 
74
78
  def self.strip_modules(class_or_method_name)
@@ -25,9 +25,11 @@ module MetricFu
25
25
  dir_files = remove_excluded_files(dir_files)
26
26
  files += dir_files
27
27
  end
28
- options = ::Flog.parse_options ["--all", "--details"]
29
- # TODO determine if flogging should continue despite errors
30
- # options = ::Flog.parse_options ["--all", "--details", "--continue"]
28
+ options = ::Flog.parse_options [
29
+ "--all",
30
+ "--details",
31
+ MetricFu.flog[:continue] ? "--continue" : nil,
32
+ ].compact
31
33
 
32
34
  @flogger = ::Flog.new options
33
35
  @flogger.flog files
@@ -44,22 +44,26 @@ module MetricFu
44
44
  end
45
45
  def location(item, value)
46
46
  sub_table = get_sub_table(item, value)
47
- if(sub_table.length==0)
48
- raise MetricFu::AnalysisError, "The #{item.to_s} '#{value.to_s}' does not have any rows in the analysis table"
47
+ assert_sub_table_has_data(item, sub_table, value)
48
+ first_row = sub_table[0]
49
+ case item
50
+ when :class
51
+ MetricFu::Location.get(first_row.file_path, first_row.class_name, nil)
52
+ when :method
53
+ MetricFu::Location.get(first_row.file_path, first_row.class_name, first_row.method_name)
54
+ when :file
55
+ MetricFu::Location.get(first_row.file_path, nil, nil)
49
56
  else
50
- first_row = sub_table[0]
51
- case item
52
- when :class
53
- MetricFu::Location.get(first_row.file_path, first_row.class_name, nil)
54
- when :method
55
- MetricFu::Location.get(first_row.file_path, first_row.class_name, first_row.method_name)
56
- when :file
57
- MetricFu::Location.get(first_row.file_path, nil, nil)
58
- else
59
- raise ArgumentError, "Item must be :class, :method, or :file"
60
- end
57
+ raise ArgumentError, "Item must be :class, :method, or :file"
58
+ end
59
+ end
60
+
61
+ def assert_sub_table_has_data(item, sub_table, value)
62
+ if (sub_table.length==0)
63
+ raise MetricFu::AnalysisError, "The #{item.to_s} '#{value.to_s}' does not have any rows in the analysis table"
61
64
  end
62
65
  end
66
+
63
67
  # just for testing
64
68
  public :location, :problems_with
65
69
  def get_sub_table(item, value)
@@ -1,3 +1,3 @@
1
1
  module MetricFu
2
- VERSION = "4.1.3"
2
+ VERSION = "4.2.0"
3
3
  end
@@ -21,7 +21,7 @@ module MetricFu
21
21
  end
22
22
 
23
23
  def ruby2ruby
24
- ['= 2.0.2']
24
+ ['~> 2.0', '>= 2.0.2']
25
25
  end
26
26
  def ruby_parser
27
27
  ['~> 3.0', '>= 3.1.1']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metric_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.3
4
+ version: 4.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -19,7 +19,7 @@ authors:
19
19
  autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
- date: 2013-05-13 00:00:00.000000000 Z
22
+ date: 2013-05-20 00:00:00.000000000 Z
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: flay
@@ -144,7 +144,10 @@ dependencies:
144
144
  requirement: !ruby/object:Gem::Requirement
145
145
  none: false
146
146
  requirements:
147
- - - '='
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: '2.0'
150
+ - - ! '>='
148
151
  - !ruby/object:Gem::Version
149
152
  version: 2.0.2
150
153
  type: :runtime
@@ -152,7 +155,10 @@ dependencies:
152
155
  version_requirements: !ruby/object:Gem::Requirement
153
156
  none: false
154
157
  requirements:
155
- - - '='
158
+ - - ~>
159
+ - !ruby/object:Gem::Version
160
+ version: '2.0'
161
+ - - ! '>='
156
162
  - !ruby/object:Gem::Version
157
163
  version: 2.0.2
158
164
  - !ruby/object:Gem::Dependency
@@ -343,7 +349,6 @@ files:
343
349
  - Gemfile
344
350
  - HISTORY.md
345
351
  - MIT-LICENSE
346
- - Manifest.txt
347
352
  - README.md
348
353
  - Rakefile
349
354
  - TODO.md
@@ -355,7 +360,10 @@ files:
355
360
  - bin/mf-reek
356
361
  - bin/mf-roodi
357
362
  - bin/mf-stats
363
+ - checksum/.gitkeep
364
+ - checksum/metric_fu-4.2.0.gem.sha512
358
365
  - config/roodi_config.yml
366
+ - gem_tasks/build.rake
359
367
  - lib/metric_fu.rb
360
368
  - lib/metric_fu/cli/client.rb
361
369
  - lib/metric_fu/cli/helper.rb
@@ -549,7 +557,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
549
557
  version: 1.3.6
550
558
  requirements: []
551
559
  rubyforge_project: metric_fu
552
- rubygems_version: 1.8.24
560
+ rubygems_version: 1.8.25
553
561
  signing_key:
554
562
  specification_version: 3
555
563
  summary: A fistful of code metrics, with awesome templates and graphs
@@ -1,25 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- metric_fu-0.7.gem
4
- metric_fu.gemspec
5
- MIT-LICENSE
6
- Rakefile
7
- README
8
- TODO.txt
9
- lib/metric_fu.rb
10
- lib/metric_fu/base.rb
11
- lib/metric_fu/churn.rb
12
- lib/metric_fu/flay_reporter.rb
13
- lib/metric_fu/flog_reporter.rb
14
- lib/metric_fu/md5_tracker.rb
15
- lib/metric_fu/saikuro/saikuro.rb
16
- lib/metric_fu/saikuro/SAIKURO_README
17
- lib/tasks/churn.rake
18
- lib/tasks/coverage.rake
19
- lib/tasks/flog.rake
20
- lib/tasks/metric_fu.rake
21
- lib/tasks/metric_fu.rb
22
- lib/tasks/saikuro.rake
23
- lib/tasks/stats.rake
24
- test/test_helper.rb
25
- test/test_md5_tracker.rb