Skip to content

Commit

Permalink
Merge 6aba374 into 6d6d677
Browse files Browse the repository at this point in the history
  • Loading branch information
backus committed Sep 28, 2015
2 parents 6d6d677 + 6aba374 commit 50ee6f3
Show file tree
Hide file tree
Showing 44 changed files with 173 additions and 171 deletions.
2 changes: 1 addition & 1 deletion config/devtools.yml
@@ -1,4 +1,4 @@
---
unit_test_timeout: 0.1
unit_test_timeout: 1.0
fail_on_branch:
- "master"
2 changes: 1 addition & 1 deletion config/flay.yml
@@ -1,3 +1,3 @@
---
threshold: 9
total_score: 167
total_score: 172
2 changes: 1 addition & 1 deletion config/flog.yml
@@ -1,2 +1,2 @@
---
threshold: 14.4
threshold: 9.7
5 changes: 1 addition & 4 deletions config/mutant.yml
@@ -1,7 +1,4 @@
---
name: yardstick
namespace: Yardstick
expect_coverage: 2358/2450
ignore_subjects:
# sometimes creates a neutral failure
- Yardstick::Rake::Measurement#define
since: HEAD~1
4 changes: 4 additions & 0 deletions config/rubocop.yml
Expand Up @@ -68,3 +68,7 @@ ExtraSpacing:
# Buggy
FormatParameterMismatch:
Enabled: false

# Align if/else blocks with the variable assignment
EndAlignment:
AlignWith: variable
1 change: 1 addition & 0 deletions lib/yardstick.rb
Expand Up @@ -5,6 +5,7 @@
require 'delegate'

require 'yard'
require 'yard/logging'

require 'yardstick/ordered_set'
require 'yardstick/measurement'
Expand Down
19 changes: 7 additions & 12 deletions lib/yardstick/cli.rb
Expand Up @@ -34,27 +34,22 @@ def self.run(*args)
# @api private
def self.parse_config(args)
args << '--help' if args.empty?
options = {}
option_parser(options).parse!(args)
Config.new(options.merge(path: args))
option_parser.parse!(args)
Config.new(path: args)
rescue OptionParser::InvalidOption => error
display_exit(error.message)
display_exit(error)
end

# Return an OptionParser instance for the command-line app
#
# @param [Hash] _options
# the options to set when parsing the command-line arguments
#
# @return [Yardstick::OptionParser]
# the option parser instance
#
# @api private
def self.option_parser(_options)
def self.option_parser
opts = OptionParser.new
opts.on_tail('-v', '--version', 'print version information and exit') { display_exit("#{opts.program_name} #{Yardstick::VERSION}") }
opts.on_tail('-h', '--help', 'display this help and exit') { display_exit(opts.to_s) }
opts
opts.on_tail('-v', '--version', 'print version information and exit') { display_exit("#{opts.program_name} #{VERSION}") }
opts.on_tail('-h', '--help', 'display this help and exit') { display_exit(opts) }
end

# Display a message and exit
Expand All @@ -66,7 +61,7 @@ def self.option_parser(_options)
#
# @api private
def self.display_exit(message)
puts message.to_str
puts message
exit
end

Expand Down
8 changes: 6 additions & 2 deletions lib/yardstick/config.rb
Expand Up @@ -81,8 +81,12 @@ def self.coerce(hash, &block)
# @api private
def self.normalize_hash(hash)
hash.reduce({}) do |normalized_hash, (key, value)|
normalized_value = value.is_a?(Hash) ? normalize_hash(value) : value
normalized_hash[key.to_sym] = normalized_value
normalized_hash[key.to_sym] = if value.instance_of?(Hash)
normalize_hash(value)
else
value
end

normalized_hash
end
end
Expand Down
1 change: 0 additions & 1 deletion lib/yardstick/document.rb
Expand Up @@ -197,7 +197,6 @@ class NullTag
#
# @api private
def text
nil
end

# Empty list of types
Expand Down
1 change: 0 additions & 1 deletion lib/yardstick/document_set.rb
Expand Up @@ -12,7 +12,6 @@ class DocumentSet < OrderedSet
def measure(config)
reduce(MeasurementSet.new) do |set, document|
set.merge(Document.measure(document, config))
set
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/yardstick/measurement.rb
Expand Up @@ -34,7 +34,7 @@ def initialize(rule)
#
# @api public
def ok?
@result == true || skip?
skip? || @result
end

# Return true if the measurement was skipped
Expand All @@ -50,7 +50,7 @@ def ok?
#
# @api public
def skip?
@result == :skip
@result.equal?(:skip)
end

# Warns the results the measurement if it was not successful
Expand Down
4 changes: 2 additions & 2 deletions lib/yardstick/ordered_set.rb
Expand Up @@ -17,7 +17,7 @@ class OrderedSet
def initialize(entries = nil)
@entries = []
@index = {}
merge(entries || [])
merge(entries || self)
end

# Append to the OrderedSet
Expand All @@ -31,7 +31,7 @@ def initialize(entries = nil)
# @api private
def <<(entry)
unless include?(entry)
@index[entry] = @entries.length
@index[entry] = length
@entries << entry
end
self
Expand Down
5 changes: 2 additions & 3 deletions lib/yardstick/parser.rb
Expand Up @@ -10,7 +10,7 @@ class Parser
#
# @api private
def self.parse_paths(paths)
YARD.parse(paths, [], YARD::Logger::ERROR)
YARD.parse(paths, [], Logger::ERROR)
documents
end

Expand All @@ -36,7 +36,6 @@ def self.parse_string(string)
def self.documents
method_objects.reduce(DocumentSet.new) do |set, method_object|
set << Document.new(method_object.docstring)
set
end
end
private_class_method :documents
Expand All @@ -48,7 +47,7 @@ def self.documents
#
# @api private
def self.method_objects
YARD::Registry.all(:method).select(&:file).select(&:line).sort_by do |method_object|
YARD::Registry.all(:method).select(&:file).sort_by do |method_object|
[method_object.file, method_object.line]
end
ensure
Expand Down
4 changes: 2 additions & 2 deletions lib/yardstick/rules/api_tag.rb
Expand Up @@ -51,7 +51,7 @@ class ProtectedMethod < Rule
#
# @api private
def validatable?
visibility == :protected
visibility.equal?(:protected)
end

# @see class description
Expand All @@ -77,7 +77,7 @@ class PrivateMethod < Rule
#
# @api private
def validatable?
visibility == :private
visibility.equal?(:private)
end

# @see class description
Expand Down
2 changes: 1 addition & 1 deletion lib/yardstick/rules/example_tag.rb
Expand Up @@ -16,7 +16,7 @@ class ExampleTag < Rule
#
# @api private
def validatable?
!api?(%w(private)) && tag_types('return') != %w(undefined)
!api?(%w(private)) && !tag_types('return').eql?(%w(undefined))
end

# @see class description
Expand Down
6 changes: 3 additions & 3 deletions lib/yardstick/rules/summary.rb
Expand Up @@ -34,9 +34,9 @@ def valid?
# Checks that method summary length doesn't go over 80 characters
#
class Length < Rule
MAXIMUM_LINE_LENGTH = 80
MAXIMUM_LINE_LENGTH = 79

self.description = 'The method summary should be less than 80 characters in length'
self.description = 'The method summary should be less than or equal to 79 characters in length'

# @see class description
#
Expand All @@ -61,7 +61,7 @@ class Delimiter < Rule
#
# @api private
def valid?
summary_text[-1, 1] != '.'
!summary_text.end_with?('.')
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/yardstick/yard_ext.rb
Expand Up @@ -2,7 +2,7 @@

module YARD #:nodoc: all
# Test if JRuby head is being used
JRUBY_19MODE = RUBY_VERSION >= '1.9' && RUBY_ENGINE == 'jruby'
JRUBY_19MODE = RUBY_VERSION >= '1.9' && RUBY_ENGINE.eql?('jruby')

# Fix jruby-head to use the ruby 1.8 parser until their ripper port is working
Parser::SourceParser.parser_type = :ruby18 if JRUBY_19MODE
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/yardstick/class_methods/measure_spec.rb
Expand Up @@ -5,7 +5,7 @@
describe Yardstick, '.measure' do
describe 'with no arguments' do
before :all do
@measurements = Yardstick.measure
@measurements = described_class.measure
end

it_should_behave_like 'measured itself'
Expand All @@ -14,7 +14,7 @@
describe 'with a config' do
before :all do
config = Yardstick::Config.new(path: Yardstick::ROOT.join('lib', 'yardstick.rb'))
@measurements = Yardstick.measure(config)
@measurements = described_class.measure(config)
end

it_should_behave_like 'measured itself'
Expand Down
Expand Up @@ -12,8 +12,8 @@
end

describe 'with no arguments' do
it 'should raise an exception' do
expect { Yardstick.measure_string }
it 'raises an exception' do
expect { described_class.measure_string }
.to raise_error(ArgumentError)
end
end
Expand Down

0 comments on commit 50ee6f3

Please sign in to comment.