metric_fu 4.11.2 → 4.11.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5a9b2b2a4948535584eff46f652281508cc5de5
4
- data.tar.gz: 033ea94132c02ae98f68a8338f860bd0d065e0a8
3
+ metadata.gz: 86d7cdbfdb266e8b71ce314e9df37175d082cb9c
4
+ data.tar.gz: 4bf5f06e2f788fb99e0020708e1461bd70e74f46
5
5
  SHA512:
6
- metadata.gz: 2ab4c65b33b1238dbd9d0d49aa1c88da8f2e46d77c27afd39109cb17d5404a4e741589b0ed11ef9860209f641257fc5a47d88decc5c1ab7f92004cb07b64e989
7
- data.tar.gz: 8082172a72b8001f5c6b0b5aacf8572922db6eda66ebe00ba554d7a7084e1a7ebd8d1c86c7f5f8a0543fe8ec7967f4f9cf89531a31afa2a64952b095f26fa9c7
6
+ metadata.gz: 01a4610aafa426d5aa0b4ecbab018d03ec861c39ec69fa10d2af4ce2b7ac4d9cc3dd5f3ae9a67d4fbd6ac21f5188cb73cfb7135c74be2fed6f9b368d2c8beb14
7
+ data.tar.gz: 3cb4ce3bfe160270989eb7f4aa6dc21d6a4b3161cdb2f2748fdef9bb96a02303ac3aa941868c54d2a65b4845538a5b83100719d78b0d19052185e5d9336ff6aa
Binary file
data.tar.gz.sig CHANGED
Binary file
data/.simplecov CHANGED
@@ -1,5 +1,7 @@
1
1
  # https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config
2
2
  # see https://github.com/colszowka/simplecov/blob/master/lib/simplecov/defaults.rb
3
+ # vim: set ft=ruby
4
+ @minimum_coverage = ENV.fetch("COVERAGE_MINIMUM") { 87.8 }.to_f.round(2)
3
5
  if SimpleCov.respond_to?(:profiles)
4
6
  SimpleCov.profiles
5
7
  else
@@ -31,12 +33,42 @@ end.define 'metric_fu' do
31
33
 
32
34
  # Exclude these paths from analysis
33
35
  add_filter 'bundle'
36
+ add_filter 'vendor/bundle'
34
37
  add_filter 'bin'
35
38
  add_filter 'lib/metric_fu/tasks'
39
+
40
+ # https://github.com/colszowka/simplecov/blob/v0.9.1/lib/simplecov/defaults.rb#L60
41
+ # minimum_coverage @minimum_coverage
36
42
  end
37
- SimpleCov.at_exit do
38
- File.open(File.join(SimpleCov.coverage_path, 'coverage_percent.txt'), 'w') do |f|
39
- f.write SimpleCov.result.covered_percent
43
+
44
+ ## RUN SIMPLECOV
45
+ if defined?(@running_tests)
46
+ @running_tests = false
47
+ else
48
+ @running_tests = caller.any? {|line| line =~ /exe\/rspec/ }
49
+ end
50
+ if ENV["COVERAGE"] =~ /\Atrue\z/i
51
+ puts "[COVERAGE] Running with SimpleCov HTML Formatter"
52
+ formatters = [SimpleCov::Formatter::HTMLFormatter]
53
+ begin
54
+ puts '[COVERAGE] Running with SimpleCov HTML Formatter'
55
+ require 'metric_fu/metrics/rcov/simplecov_formatter'
56
+ formatters << SimpleCov::Formatter::MetricFu
57
+ puts '[COVERAGE] Running with SimpleCov MetricFu Formatter'
58
+ rescue LoadError
59
+ puts '[COVERAGE] SimpleCov MetricFu formatter could not be loaded'
40
60
  end
61
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ *formatters ]
62
+ SimpleCov.start "metric_fu" if @running_tests
63
+ else
64
+ SimpleCov.formatters = []
65
+ end
66
+ SimpleCov.at_exit do
41
67
  SimpleCov.result.format!
68
+ percent = Float(SimpleCov.result.covered_percent)
69
+ if percent < @minimum_coverage
70
+ abort "Spec coverage was not high enough: #{percent.round(2)} is < #{@minimum_coverage}%"
71
+ else
72
+ puts "Nice job! Spec coverage is still above #{@minimum_coverage}%"
73
+ end
42
74
  end
@@ -1,20 +1,23 @@
1
+ sudo: false
1
2
  language: ruby
2
- bundler_args: --path vendor/bundle
3
+ bundler_args: --path vendor/bundle --jobs=3 --retry=3
3
4
  script: bundle exec rspec
4
5
  cache: bundler
6
+
5
7
  before_install:
6
8
  - gem install bundler
7
9
  - bundle config --local without local_development yard guard
8
10
  rvm:
9
11
  # 2.1, not 2.1.0 until fixed https://github.com/travis-ci/travis-ci/issues/2220
12
+ - 2.2
10
13
  - 2.1
11
14
  - 2.0.0
12
- - 1.9.3
13
15
  - 1.9.2
16
+ - 1.9.3
14
17
  - jruby
15
18
  - "rbx-2"
16
19
  matrix:
17
20
  allow_failures:
18
21
  - rvm: rbx-2
19
- - rvm: 2.1
22
+ - rvm: 2.2
20
23
  fast_finish: true
data/Gemfile CHANGED
@@ -26,7 +26,6 @@ end
26
26
  # Added by devtools
27
27
  group :development do
28
28
  gem 'rake', '~> 10.1.0'
29
- gem 'rspec', '~> 3.0.0.beta2'
30
29
  gem 'yard', '~> 0.8.7', group: :yard
31
30
  end
32
31
 
data/HISTORY.md CHANGED
@@ -4,13 +4,18 @@ Each change should fall into categories that would affect whether the release is
4
4
 
5
5
  As such, a _Feature_ would map to either major (breaking change) or minor. A _bug fix_ to a patch. And _misc_ is either minor or patch, the difference being kind of fuzzy for the purposes of history. Adding tests would be patch level.
6
6
 
7
- ### Master [changes](https://github.com/metricfu/metric_fu/compare/v4.11.2...master)
7
+ ### Master [changes](https://github.com/metricfu/metric_fu/compare/v4.11.3...master)
8
8
 
9
9
  * Breaking Changes
10
10
  * Features
11
11
  * Fixes
12
12
  * Misc
13
13
 
14
+ ### [4.11.3](https://github.com/metricfu/metric_fu/compare/v4.11.2...v4.11.3)
15
+
16
+ * Fixes
17
+ * Fix incorrectly passing --config option to reek. (Martin Gotink, #243, fixes #242)
18
+
14
19
  ### [4.11.2](https://github.com/metricfu/metric_fu/compare/v4.11.1...v4.11.2)
15
20
 
16
21
  * Fixes
data/Rakefile CHANGED
@@ -4,6 +4,7 @@ if using_git
4
4
  require 'bundler/setup'
5
5
  end
6
6
  require 'rake'
7
+ require 'simplecov'
7
8
 
8
9
  Dir['./gem_tasks/*.rake'].each do |task|
9
10
  import(task)
@@ -23,19 +24,4 @@ end
23
24
 
24
25
  require File.expand_path File.join(File.dirname(__FILE__),'lib/metric_fu')
25
26
 
26
- # Borrowed from vcr
27
- desc "Checks the spec coverage and fails if it is less than 100%"
28
- task :check_code_coverage do
29
- if RUBY_VERSION.to_f < 1.9 || RUBY_ENGINE != 'ruby'
30
- puts "Cannot check code coverage--simplecov is not supported on this platform"
31
- else
32
- percent = Float(File.read("./coverage/coverage_percent.txt"))
33
- if percent < 98.0
34
- abort "Spec coverage was not high enough: #{percent.round(2)}%"
35
- else
36
- puts "Nice job! Spec coverage is still above 98%"
37
- end
38
- end
39
- end
40
-
41
27
  task :default => :spec
@@ -0,0 +1 @@
1
+ c31f9343f44972b7b614d97cf33d457ad11518b408fb5e8e009eff8ee3c88353bd1dab14ac143a313433b7920b96f89d34753a0cd910364a70396ead3dc39980
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'rubygems'
3
3
  require 'digest/sha2'
4
+ require 'rake/tasklib'
4
5
  # require 'bundler/gem_helper'
5
6
  # Bundler::GemHelper.install_tasks
6
7
 
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ begin
4
+ require "yard"
5
+ rescue LoadError
6
+ else
7
+ namespace :yard do
8
+ YARD::Rake::YardocTask.new(:doc) do |t|
9
+ t.stats_options = ["--list-undoc"]
10
+ end
11
+
12
+ desc "start a gem server"
13
+ task :server do
14
+ sh "bundle exec yard server --gems"
15
+ end
16
+
17
+ desc "use Graphviz to generate dot graph"
18
+ task :graph do
19
+ output_file = "doc/erd.dot"
20
+ sh "bundle exec yard graph --protected --full --dependencies > #{output_file}"
21
+ puts "open doc/erd.dot if you have graphviz installed"
22
+ end
23
+ end
24
+ end
@@ -105,7 +105,7 @@ module MetricFu
105
105
  [
106
106
  disable_line_number_option,
107
107
  turn_off_color,
108
- config_option,
108
+ *config_option,
109
109
  *files
110
110
  ].reject(&:empty?)
111
111
  end
@@ -114,9 +114,9 @@ module MetricFu
114
114
  def config_option
115
115
  config_file_pattern = options[:config_file_pattern]
116
116
  if config_file_pattern.to_s.empty?
117
- ''
117
+ ['']
118
118
  else
119
- "--config #{config_file_pattern}"
119
+ ['--config', config_file_pattern]
120
120
  end
121
121
  end
122
122
 
@@ -1,3 +1,3 @@
1
1
  module MetricFu
2
- VERSION = '4.11.2'
2
+ VERSION = '4.11.3'
3
3
  end
@@ -62,10 +62,11 @@ Gem::Specification.new do |s|
62
62
  # open browser support
63
63
  s.add_runtime_dependency 'launchy', '~> 2.0'
64
64
 
65
+ s.add_development_dependency 'rspec', '~> 3.1'
65
66
  # temporary filesystem to act on
66
67
  s.add_development_dependency 'test_construct'
67
68
  # ensure we have a JSON parser
68
69
  s.add_development_dependency 'json'
69
- s.add_development_dependency 'simplecov'
70
+ s.add_development_dependency 'simplecov', '~> 0.9'
70
71
 
71
72
  end
@@ -1,15 +1,18 @@
1
1
  # https://raw.githubusercontent.com/metric_fu/metric_fu/master/spec/capture_warnings.rb
2
- require 'rubygems' if RUBY_VERSION =~ /^1\.8/
3
- require 'bundler/setup'
4
- require 'rspec/core'
5
- require 'rspec/expectations'
6
- require 'tempfile'
7
-
8
- stderr_file = Tempfile.new("metric_fu.stderr")
9
- current_dir = Dir.pwd
2
+ require "rubygems" if RUBY_VERSION =~ /^1\.8/
3
+ require "bundler/setup"
4
+ require "rspec/core"
5
+ require "rspec/expectations"
6
+ require "tempfile"
7
+ require "fileutils"
8
+
9
+ stderr_file = Tempfile.new("app.stderr")
10
+ app_dir = File.expand_path("../..", __FILE__)
11
+ output_dir = File.join(app_dir, "tmp")
12
+ FileUtils.mkdir_p(output_dir)
13
+ bundle_dir = File.join(app_dir, "bundle")
10
14
 
11
15
  RSpec.configure do |config|
12
-
13
16
  config.before(:suite) do
14
17
  $stderr.reopen(stderr_file.path)
15
18
  $VERBOSE = true
@@ -22,27 +25,28 @@ RSpec.configure do |config|
22
25
 
23
26
  $stderr.reopen(STDERR)
24
27
 
25
- metric_fu_warnings, other_warnings = lines.partition { |line| line.include?(current_dir) }
28
+ app_warnings, other_warnings = lines.partition do |line|
29
+ line.include?(app_dir) && !line.include?(bundle_dir)
30
+ end
26
31
 
27
- if metric_fu_warnings.any?
28
- puts
29
- puts "-" * 30 + " metric_fu warnings: " + "-" * 30
30
- puts
31
- puts metric_fu_warnings.join("\n")
32
- puts
33
- puts "-" * 75
34
- puts
32
+ if app_warnings.any?
33
+ puts <<-WARNINGS
34
+ #{'-' * 30} app warnings: #{'-' * 30}
35
+
36
+ #{app_warnings.join("\n")}
37
+
38
+ #{'-' * 75}
39
+ WARNINGS
35
40
  end
36
41
 
37
42
  if other_warnings.any?
38
- File.open('tmp/warnings.txt', 'w') { |f| f.write(other_warnings.join("\n")) }
43
+ File.write(File.join(output_dir, "warnings.txt"), other_warnings.join("\n") << "\n")
39
44
  puts
40
- puts "Non-metric_fu warnings written to tmp/warnings.txt"
45
+ puts "Non-app warnings written to tmp/warnings.txt"
41
46
  puts
42
47
  end
43
48
 
44
49
  # fail the build...
45
- raise "Failing build due to metric_fu warnings" if metric_fu_warnings.any?
50
+ abort "Failing build due to app warnings: #{app_warnings.inspect}" if app_warnings.any?
46
51
  end
47
-
48
52
  end
@@ -1,32 +1,32 @@
1
1
  require "spec_helper"
2
- require 'shared/configured'
2
+ require "shared/configured"
3
3
 
4
4
  describe MetricFu::Configuration do
5
5
 
6
- it_behaves_like 'configured' do
6
+ it_behaves_like "configured" do
7
7
 
8
- describe "#is_cruise_control_rb? " do
8
+ describe "#is_cruise_control_rb?" do
9
9
 
10
10
  before(:each) { get_new_config }
11
11
  describe "when the CC_BUILD_ARTIFACTS env var is not nil" do
12
12
 
13
13
  before(:each) do
14
- ENV['CC_BUILD_ARTIFACTS'] = 'is set'
14
+ ENV["CC_BUILD_ARTIFACTS"] = "is set"
15
15
  end
16
16
 
17
- it 'should return true' do
17
+ it "should return true" do
18
18
  expect(@config.is_cruise_control_rb?).to be_truthy
19
19
  end
20
20
 
21
21
  after(:each) do
22
- ENV['CC_BUILD_ARTIFACTS'] = nil
23
- FileUtils.rm_rf(File.join(MetricFu.root_dir, 'is set'))
22
+ ENV["CC_BUILD_ARTIFACTS"] = nil
23
+ FileUtils.rm_rf(File.join(MetricFu.root_dir, "is set"))
24
24
  end
25
25
 
26
26
  end
27
27
 
28
28
  describe "when the CC_BUILD_ARTIFACTS env var is nil" do
29
- before(:each) { ENV['CC_BUILD_ARTIFACTS'] = nil }
29
+ before(:each) { ENV["CC_BUILD_ARTIFACTS"] = nil }
30
30
 
31
31
  it "should return false" do
32
32
  expect(@config.is_cruise_control_rb?).to be_falsey
@@ -39,47 +39,47 @@ it_behaves_like 'configured' do
39
39
  describe "when there is a CC_BUILD_ARTIFACTS environment variable" do
40
40
 
41
41
  before do
42
- ENV['CC_BUILD_ARTIFACTS'] = 'foo'
42
+ ENV["CC_BUILD_ARTIFACTS"] = "foo"
43
43
  @config = MetricFu.configuration
44
44
  @config.reset
45
45
  MetricFu.configure
46
46
  end
47
47
  it "should return the CC_BUILD_ARTIFACTS environment variable" do
48
- compare_paths(base_directory, ENV['CC_BUILD_ARTIFACTS'])
48
+ compare_paths(base_directory, ENV["CC_BUILD_ARTIFACTS"])
49
49
  end
50
50
  after do
51
- ENV['CC_BUILD_ARTIFACTS'] = nil
52
- FileUtils.rm_rf(File.join(MetricFu.root_dir, 'foo'))
51
+ ENV["CC_BUILD_ARTIFACTS"] = nil
52
+ FileUtils.rm_rf(File.join(MetricFu.root_dir, "foo"))
53
53
  end
54
54
  end
55
55
 
56
56
  describe "when there is no CC_BUILD_ARTIFACTS environment variable" do
57
57
 
58
58
  before(:each) do
59
- ENV['CC_BUILD_ARTIFACTS'] = nil
59
+ ENV["CC_BUILD_ARTIFACTS"] = nil
60
60
  get_new_config
61
61
  end
62
62
  it "should return 'tmp/metric_fu'" do
63
63
  expect(base_directory).to eq(MetricFu.artifact_dir)
64
64
  end
65
65
 
66
- it 'should set @metric_fu_root_directory to the base of the '+
67
- 'metric_fu application' do
68
- app_root = File.join(File.dirname(__FILE__), '..', '..')
66
+ it "should set @metric_fu_root_directory to the base of the "\
67
+ "metric_fu application" do
68
+ app_root = File.join(File.dirname(__FILE__), "..", "..")
69
69
  app_root_absolute_path = File.expand_path(app_root)
70
70
  metric_fu_absolute_path = File.expand_path(metric_fu_root)
71
71
  expect(metric_fu_absolute_path).to eq(app_root_absolute_path)
72
72
  expect(MetricFu.root.to_s).to eq(app_root_absolute_path)
73
73
  end
74
74
 
75
- it 'should set @scratch_directory to scratch relative '+
76
- 'to @base_directory' do
75
+ it "should set @scratch_directory to scratch relative "\
76
+ "to @base_directory" do
77
77
  scratch_dir = MetricFu.scratch_dir
78
78
  expect(scratch_directory).to eq(scratch_dir)
79
79
  end
80
80
 
81
- it 'should set @output_directory to output relative '+
82
- 'to @base_directory' do
81
+ it "should set @output_directory to output relative "\
82
+ "to @base_directory" do
83
83
  output_dir = MetricFu.output_dir
84
84
  expect(output_directory).to eq(output_dir)
85
85
  end
@@ -1,15 +1,15 @@
1
- require 'spec_helper'
2
- require 'shared/configured'
1
+ require "spec_helper"
2
+ require "shared/configured"
3
3
 
4
- describe MetricFu::Configuration, 'for cane' do
5
- it_behaves_like 'configured' do
4
+ describe MetricFu::Configuration, "for cane" do
5
+ it_behaves_like "configured" do
6
6
  if MetricFu.configuration.mri?
7
- it 'should set @cane to ' +
8
- %q(:dirs_to_cane => @code_dirs, :abc_max => 15, :line_length => 80, :no_doc => 'n', :no_readme => 'y') do
9
- load_metric 'cane'
7
+ it "should set @cane to " +
8
+ %q(:dirs_to_cane => @code_dirs, :abc_max => 15, :line_length => 80, :no_doc => "n", :no_readme => "y") do
9
+ load_metric "cane"
10
10
  expect(MetricFu::Metric.get_metric(:cane).run_options).to eq(
11
11
  {
12
- :dirs_to_cane => directory('code_dirs'),
12
+ :dirs_to_cane => directory("code_dirs"),
13
13
  :filetypes => ["rb"],
14
14
  :abc_max => 15,
15
15
  :line_length => 80,
@@ -14,7 +14,7 @@ describe MetricFu::ReekGenerator do
14
14
  it "includes config file pattern into reek parameters when specified" do
15
15
  options.merge!({:config_file_pattern => 'lib/config/*.reek' })
16
16
  expect(reek).to receive(:run!) do |args|
17
- expect(args).to include('--config lib/config/*.reek')
17
+ expect(args).to include('--config', 'lib/config/*.reek')
18
18
  end.and_return('')
19
19
  reek.emit
20
20
  end
@@ -1,20 +1,20 @@
1
- require 'spec_helper'
2
- require 'shared/configured'
1
+ require "spec_helper"
2
+ require "shared/configured"
3
3
 
4
- describe MetricFu::Configuration, 'for saikuro' do
5
- it_behaves_like 'configured' do
4
+ describe MetricFu::Configuration, "for saikuro" do
5
+ it_behaves_like "configured" do
6
6
 
7
- it 'should set @saikuro to { :output_directory => @scratch_directory + "/saikuro",
7
+ it "should set @saikuro to { :output_directory => @scratch_directory + '/saikuro',
8
8
  :input_directory => @code_dirs,
9
- :cyclo => "",
10
- :filter_cyclo => "0",
11
- :warn_cyclo => "5",
12
- :error_cyclo => "7",
13
- :formater => "text" }' do
14
- load_metric 'saikuro'
9
+ :cyclo => '',
10
+ :filter_cyclo => '0',
11
+ :warn_cyclo => '5',
12
+ :error_cyclo => '7',
13
+ :formater => 'text' }" do
14
+ load_metric "saikuro"
15
15
  expect(MetricFu::Metric.get_metric(:saikuro).run_options).to eq(
16
16
  { :output_directory => "#{scratch_directory}/saikuro",
17
- :input_directory => ['lib'],
17
+ :input_directory => ["lib"],
18
18
  :cyclo => "",
19
19
  :filter_cyclo => "0",
20
20
  :warn_cyclo => "5",
@@ -1,18 +1,18 @@
1
- require 'spec_helper'
2
- require 'shared/configured'
1
+ require "spec_helper"
2
+ require "shared/configured"
3
3
 
4
- describe MetricFu::Configuration, 'for templates' do
5
- it_behaves_like 'configured' do
4
+ describe MetricFu::Configuration, "for templates" do
5
+ it_behaves_like "configured" do
6
6
  describe "when there is no CC_BUILD_ARTIFACTS environment variable" do
7
7
 
8
8
  before(:each) do
9
- ENV['CC_BUILD_ARTIFACTS'] = nil
9
+ ENV["CC_BUILD_ARTIFACTS"] = nil
10
10
  get_new_config
11
11
  end
12
12
 
13
- it 'should set @template_directory to the lib/templates relative '+
14
- 'to @metric_fu_root_directory' do
15
- expected_template_dir = MetricFu.root.join('lib','templates').to_s
13
+ it "should set @template_directory to the lib/templates relative "+
14
+ "to @metric_fu_root_directory" do
15
+ expected_template_dir = MetricFu.root.join("lib","templates").to_s
16
16
  expect(template_directory).to eq(expected_template_dir)
17
17
  end
18
18
 
@@ -28,7 +28,7 @@ describe MetricFu::Configuration, 'for templates' do
28
28
 
29
29
  @config.templates_configuration do |config|
30
30
  config.template_class = DummyTemplate
31
- config.link_prefix = 'http:/'
31
+ config.link_prefix = "http:/"
32
32
  config.syntax_highlighting = false
33
33
  config.darwin_txmt_protocol_no_thanks = false
34
34
  end
@@ -39,15 +39,15 @@ describe MetricFu::Configuration, 'for templates' do
39
39
  end
40
40
 
41
41
  it "should set given link_prefix" do
42
- expect(MetricFu::Formatter::Templates.option('link_prefix')).to eq('http:/')
42
+ expect(MetricFu::Formatter::Templates.option("link_prefix")).to eq("http:/")
43
43
  end
44
44
 
45
45
  it "should set given darwin_txmt_protocol_no_thanks" do
46
- expect(MetricFu::Formatter::Templates.option('darwin_txmt_protocol_no_thanks')).to be_falsey
46
+ expect(MetricFu::Formatter::Templates.option("darwin_txmt_protocol_no_thanks")).to be_falsey
47
47
  end
48
48
 
49
49
  it "should set given syntax_highlighting" do
50
- expect(MetricFu::Formatter::Templates.option('syntax_highlighting')).to be_falsey
50
+ expect(MetricFu::Formatter::Templates.option("syntax_highlighting")).to be_falsey
51
51
  end
52
52
 
53
53
  end
@@ -7,40 +7,51 @@ if defined?(Encoding) && Encoding.default_external != "UTF-8"
7
7
  Encoding.default_external = "UTF-8"
8
8
  end
9
9
 
10
- describe "The library itself" do
11
-
10
+ RSpec.describe "The library itself" do
12
11
  def check_for_spec_defs_with_single_quotes(filename)
13
12
  failing_lines = []
14
13
 
15
- File.readlines(filename).each_with_index do |line,number|
14
+ File.readlines(filename).each_with_index do |line, number|
15
+ line.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "<?>")
16
16
  failing_lines << number + 1 if line =~ /^ *(describe|it|context) {1}'{1}/
17
17
  end
18
18
 
19
19
  unless failing_lines.empty?
20
+ # Prevent rubocop from looping infinitely
21
+ # rubocop:disable Style/StringLiterals
20
22
  "#{filename} uses inconsistent single quotes on lines #{failing_lines.join(', ')}"
23
+ # rubocop:enable Style/StringLiterals
21
24
  end
22
25
  end
23
26
 
24
27
  def check_for_tab_characters(filename)
25
28
  failing_lines = []
26
- File.readlines(filename).each_with_index do |line,number|
29
+ File.readlines(filename).each_with_index do |line, number|
30
+ line.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "<?>")
27
31
  failing_lines << number + 1 if line =~ /\t/
28
32
  end
29
33
 
30
34
  unless failing_lines.empty?
35
+ # Prevent rubocop from looping infinitely
36
+ # rubocop:disable Style/StringLiterals
31
37
  "#{filename} has tab characters on lines #{failing_lines.join(', ')}"
38
+ # rubocop:enable Style/StringLiterals
32
39
  end
33
40
  end
34
41
 
35
42
  def check_for_extra_spaces(filename)
36
43
  failing_lines = []
37
- File.readlines(filename).each_with_index do |line,number|
44
+ File.readlines(filename).each_with_index do |line, number|
45
+ line.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "<?>")
38
46
  next if line =~ /^\s+#.*\s+\n$/
39
47
  failing_lines << number + 1 if line =~ /\s+\n$/
40
48
  end
41
49
 
42
50
  unless failing_lines.empty?
51
+ # Prevent rubocop from looping infinitely
52
+ # rubocop:disable Style/StringLiterals
43
53
  "#{filename} has spaces on the EOL on lines #{failing_lines.join(', ')}"
54
+ # rubocop:enable Style/StringLiterals
44
55
  end
45
56
  end
46
57
 
@@ -49,17 +60,18 @@ describe "The library itself" do
49
60
  actual.join("\n")
50
61
  end
51
62
 
52
- match do |actual|
53
- actual.empty?
54
- end
63
+ match(&:empty?)
55
64
  end
56
65
 
66
+ WHITESPACE_OK =
67
+ /\.gitmodules|\.marshal|fixtures|ssl_certs|vendor|LICENSE|etc|reports/
68
+
57
69
  it "has no malformed whitespace" do
58
- exempt = /\.gitmodules|\.marshal|fixtures|vendor|ssl_certs|LICENSE|etc/
59
70
  error_messages = []
60
71
  Dir.chdir(File.expand_path("../..", __FILE__)) do
61
72
  `git ls-files -z`.split("\x0").each do |filename|
62
- next if filename =~ exempt
73
+ next if !File.exist?(filename)
74
+ next if filename =~ WHITESPACE_OK
63
75
  error_messages << check_for_tab_characters(filename)
64
76
  error_messages << check_for_extra_spaces(filename)
65
77
  end
@@ -79,8 +91,6 @@ describe "The library itself" do
79
91
  error_messages.compact.each do |error_message|
80
92
  warn error_message
81
93
  end
82
- # TODO: fail build once this spec emits no warnings
83
- # expect(error_messages.compact).to be_well_formed
94
+ expect(error_messages.compact).to be_well_formed
84
95
  end
85
-
86
96
  end
@@ -1,19 +1,6 @@
1
1
  # add lib to the load path just like rubygems does
2
2
  $:.unshift File.expand_path("../../lib", __FILE__)
3
- if ENV['COVERAGE']
4
- require 'simplecov'
5
- formatters = [SimpleCov::Formatter::HTMLFormatter]
6
- SimpleCov.start 'metric_fu'
7
- begin
8
- puts '[COVERAGE] Running with SimpleCov HTML Formatter'
9
- require 'metric_fu/metrics/rcov/simplecov_formatter'
10
- formatters << SimpleCov::Formatter::MetricFu
11
- puts '[COVERAGE] Running with SimpleCov MetricFu Formatter'
12
- rescue LoadError
13
- puts '[COVERAGE] SimpleCov MetricFu formatter could not be loaded'
14
- end
15
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ *formatters ]
16
- end
3
+ require 'simplecov'
17
4
 
18
5
  require 'date'
19
6
  require 'test_construct'
@@ -81,7 +81,7 @@ SnippetRunner = Struct.new(:code, :language) do
81
81
  test_result.success = false
82
82
  test_result
83
83
  rescue SystemExit => system_exit
84
- puts "I am a system exit"
84
+ mf_debug "I am a system exit"
85
85
  test_result.captured_output = exception_message(system_exit)
86
86
  test_result.success = system_exit.success?
87
87
  test_result
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.11.2
4
+ version: 4.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Scruggs
@@ -42,7 +42,7 @@ cert_chain:
42
42
  lEs7ndJ1/vd/Hy0zQ1tIRWyql+ITLhqMi161Pw5flsYpQvPlRLR5pGJ4eD0/JdKE
43
43
  ZG9WSFH7QcGLY65mEYc=
44
44
  -----END CERTIFICATE-----
45
- date: 2015-01-22 00:00:00.000000000 Z
45
+ date: 2015-01-28 00:00:00.000000000 Z
46
46
  dependencies:
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: flay
@@ -262,6 +262,20 @@ dependencies:
262
262
  - - "~>"
263
263
  - !ruby/object:Gem::Version
264
264
  version: '2.0'
265
+ - !ruby/object:Gem::Dependency
266
+ name: rspec
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: '3.1'
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: '3.1'
265
279
  - !ruby/object:Gem::Dependency
266
280
  name: test_construct
267
281
  requirement: !ruby/object:Gem::Requirement
@@ -294,16 +308,16 @@ dependencies:
294
308
  name: simplecov
295
309
  requirement: !ruby/object:Gem::Requirement
296
310
  requirements:
297
- - - ">="
311
+ - - "~>"
298
312
  - !ruby/object:Gem::Version
299
- version: '0'
313
+ version: '0.9'
300
314
  type: :development
301
315
  prerelease: false
302
316
  version_requirements: !ruby/object:Gem::Requirement
303
317
  requirements:
304
- - - ">="
318
+ - - "~>"
305
319
  - !ruby/object:Gem::Version
306
- version: '0'
320
+ version: '0.9'
307
321
  description: Code metrics from Flog, Flay, Saikuro, Churn, Reek, Roodi, Code Statistics,
308
322
  and Rails Best Practices. (and optionally RCov)
309
323
  email: github@benjaminfleischer.com
@@ -351,6 +365,7 @@ files:
351
365
  - checksum/metric_fu-4.10.0.gem.sha512
352
366
  - checksum/metric_fu-4.11.0.gem.sha512
353
367
  - checksum/metric_fu-4.11.1.gem.sha512
368
+ - checksum/metric_fu-4.11.2.gem.sha512
354
369
  - checksum/metric_fu-4.2.0.gem.sha512
355
370
  - checksum/metric_fu-4.2.1.gem.sha512
356
371
  - checksum/metric_fu-4.3.0.gem.sha512
@@ -374,6 +389,7 @@ files:
374
389
  - config/roodi_config.yml
375
390
  - gem_tasks/build.rake
376
391
  - gem_tasks/usage_test.rake
392
+ - gem_tasks/yard.rake
377
393
  - lib/metric_fu.rb
378
394
  - lib/metric_fu/calculate.rb
379
395
  - lib/metric_fu/cli/client.rb
metadata.gz.sig CHANGED
Binary file