Permalink
Browse files

fix misc trivial RuboCop offenses

  • Loading branch information...
e2 committed May 19, 2016
1 parent dce4956 commit 28b2dc435ea2a666776bb5fc221a7b1166bed155
View
@@ -1,14 +1,59 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-03-14 21:37:40 +0100 using RuboCop version 0.29.1.
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-05-19 21:55:11 +0200 using RuboCop version 0.40.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 27
Metrics/AbcSize:
Max: 38
# Offense count: 9
Lint/NestedMethodDefinition:
Exclude:
- 'lib/guard/commands/all.rb'
- 'lib/guard/commands/change.rb'
- 'lib/guard/commands/notification.rb'
- 'lib/guard/commands/pause.rb'
- 'lib/guard/commands/reload.rb'
- 'lib/guard/commands/scope.rb'
- 'lib/guard/commands/show.rb'
- 'lib/guard/jobs/pry_wrapper.rb'
# Offense count: 4
Metrics/PerceivedComplexity:
Max: 11
# Offense count: 39
# Cop supports --auto-correct.
Style/MutableConstant:
Exclude:
- 'Rakefile'
- 'lib/guard/dsl.rb'
- 'lib/guard/guardfile.rb'
- 'lib/guard/guardfile/evaluator.rb'
- 'lib/guard/guardfile/generator.rb'
- 'lib/guard/internals/debugging.rb'
- 'lib/guard/internals/groups.rb'
- 'lib/guard/internals/session.rb'
- 'lib/guard/jobs/pry_wrapper.rb'
- 'lib/guard/notifier.rb'
- 'lib/guard/plugin.rb'
- 'lib/guard/plugin_util.rb'
- 'lib/guard/runner.rb'
- 'lib/guard/ui/colors.rb'
- 'lib/guard/version.rb'
# Offense count: 41
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceInsideStringInterpolation:
Exclude:
- 'lib/guard.rb'
- 'lib/guard/cli.rb'
- 'lib/guard/commander.rb'
- 'lib/guard/commands/all.rb'
- 'lib/guard/commands/reload.rb'
- 'lib/guard/commands/scope.rb'
- 'lib/guard/dsl.rb'
- 'lib/guard/guardfile/evaluator.rb'
- 'lib/guard/jobs/pry_wrapper.rb'
- 'lib/guard/plugin.rb'
- 'lib/guard/plugin_util.rb'
- 'lib/guard/runner.rb'
- 'lib/guard/ui.rb'
View
@@ -1,6 +1,8 @@
require "nenv"
require "bundler/gem_tasks"
require "forwardable"
default_tasks = []
require "rspec/core/rake_task"
@@ -63,10 +65,11 @@ class Releaser
end
def rubygems
begin
loop do
STDOUT.puts "Release #{@project_name} #{@version} to RubyGems? (y/n)"
input = STDIN.gets.chomp.downcase
end while !%w(y n).include?(input)
break if %w(y n).include?(input)
end
exit if input == "n"
@@ -133,10 +136,11 @@ class Releaser
end
def _confirm_publish
begin
loop do
STDOUT.puts "Would you like to publish this GitHub release now? (y/n)"
input = STDIN.gets.chomp.downcase
end while !%w(y n).include?(input)
break if %w(y n).include?(input)
end
exit if input == "n"
end
@@ -152,12 +156,19 @@ end
PROJECT_NAME = "Guard"
CURRENT_VERSION = Guard::VERSION
def releaser
$releaser ||= Releaser.new(
project_name: PROJECT_NAME,
gem_name: "guard",
github_repo: "guard/guard",
version: CURRENT_VERSION)
class GuardReleaser
extend Forwardable
def_delegator self, :rubygems, to: :releaser
def_delegator self, :full, to: :releaser
def self.releaser
@releaser ||= Releaser.new(
project_name: PROJECT_NAME,
gem_name: "guard",
github_repo: "guard/guard",
version: CURRENT_VERSION
)
end
end
namespace :release do
@@ -168,11 +179,11 @@ namespace :release do
desc "Push #{PROJECT_NAME} #{CURRENT_VERSION} to RubyGems"
task :gem do
releaser.rubygems
GuardReleaser.rubygems
end
desc "Publish #{PROJECT_NAME} #{CURRENT_VERSION} GitHub release"
task :github do
releaser.github
GuardReleaser.github
end
end
@@ -45,7 +45,7 @@
When(/^I wait for Guard to become idle$/) do
expected = "guard(main)>"
begin
Timeout::timeout(aruba.config.exit_timeout) do
Timeout.timeout(aruba.config.exit_timeout) do
loop do
break if last_command_started.stdout.include?(expected)
sleep 0.1
View
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "notiffany", "~> 0.0"
git_files = `git ls-files -z`.split("\x0")
files = git_files.select { |f| /^(?:bin|lib)\/.*$/ =~ f }
files = git_files.select { |f| %r{^(?:bin|lib)/.*$} =~ f }
files += %w(CHANGELOG.md LICENSE README.md)
files += %w(man/guard.1 man/guard.1.html)
View
@@ -151,7 +151,8 @@ def _evaluate(options)
# TODO: not tested because collides with ongoing refactoring
def _guardfile_deprecated_check(modified)
modified.map!(&:to_s)
guardfiles = modified.select { |path| /^(?:.+\/)?Guardfile$/.match(path) }
regexp = %r{^(?:.+/)?Guardfile$}
guardfiles = modified.select { |path| regexp.match(path) }
return if guardfiles.empty?
guardfile = Pathname("Guardfile").realpath
@@ -1,6 +1,8 @@
require "guard/config"
fail "Deprecations disabled (strict mode)" if Guard::Config.new.strict?
require "forwardable"
require "guard/ui"
require "guard/internals/session"
require "guard/internals/state"
@@ -209,9 +211,9 @@ def to_hash
}
end
def to_a
to_hash.to_a
end
extend Forwardable
delegate [:to_a, :keys] => :to_hash
delegate [:include?] => :keys
def fetch(key, *args)
hash = to_hash
@@ -230,14 +232,6 @@ def []=(key, value)
end
end
def keys
to_hash.keys
end
def include?(value)
keys.include? value
end
private
def verify_key!(hash, key)
View
@@ -326,7 +326,7 @@ def logger(options)
options[:level] = options[:level].to_sym
unless [:debug, :info, :warn, :error].include? options[:level]
UI.warning WARN_INVALID_LOG_LEVEL % [options[:level]]
UI.warning(format(WARN_INVALID_LOG_LEVEL, options[:level]))
options.delete :level
end
end
@@ -58,11 +58,9 @@ def initialize(opts = {})
if opts[:contents]
@type = :inline
@contents = opts[:contents]
else
if opts[:guardfile]
@type = :custom
@path = Pathname(opts[:guardfile]) # may be updated by _read
end
elsif opts[:guardfile]
@type = :custom
@path = Pathname(opts[:guardfile]) # may be updated by _read
end
end
@@ -162,7 +160,7 @@ def _use_inline
source_from_option = @source.nil? && options[:guardfile_contents]
inline = @source == :inline
return false unless (source_from_option) || inline
return false unless source_from_option || inline
@source = :inline
@guardfile_contents = options[:guardfile_contents]
@@ -27,7 +27,8 @@ class Generator
# The Guardfile template for `guard init`
GUARDFILE_TEMPLATE = File.expand_path(
"../../../guard/templates/Guardfile",
__FILE__)
__FILE__
)
# The location of user defined templates
begin
@@ -46,7 +47,7 @@ class NoSuchPlugin < Error
def initialize(plugin_name)
@plugin_name = plugin_name
@class_name = plugin_name.gsub("-", "").capitalize
@class_name = plugin_name.delete("-").capitalize
end
def message
View
@@ -1,3 +1,5 @@
require "forwardable"
module Guard
class Interactor
# Initializes the interactor. This configures
@@ -19,19 +21,8 @@ def interactive?
@interactive
end
# Run in foreground and wait until interrupted or closed
def foreground
idle_job.foreground
end
# Remove interactor so other tasks can run in foreground
def background
idle_job.background
end
def handle_interrupt
idle_job.handle_interrupt
end
extend Forwardable
delegate [:foreground, :background, :handle_interrupt] => :idle_job
# TODO: everything below is just so the DSL can set options
# before setup() is called, which makes it useless for when
@@ -28,9 +28,9 @@ def add(name, options = {})
def matcher_for(filter)
case filter
when String, Symbol
lambda { |group| group.name == filter.to_sym }
->(group) { group.name == filter.to_sym }
when Regexp
lambda { |group| group.name.to_s =~ filter }
->(group) { group.name.to_s =~ filter }
else
fail "Invalid filter: #{filter.inspect}"
end
@@ -31,16 +31,16 @@ def add(name, options)
def matcher_for(filter)
case filter
when String, Symbol
shortname = filter.to_s.downcase.gsub("-", "")
lambda { |plugin| plugin.name == shortname }
shortname = filter.to_s.downcase.delete("-")
->(plugin) { plugin.name == shortname }
when Regexp
lambda { |plugin| plugin.name =~ filter }
->(plugin) { plugin.name =~ filter }
when Hash
lambda do |plugin|
filter.all? do |k, v|
case k
when :name
plugin.name == v.to_s.downcase.gsub("-", "")
plugin.name == v.to_s.downcase.delete("-")
when :group
plugin.group.name == v.to_sym
end
@@ -8,7 +8,8 @@ def initialize(commander)
# Process the change queue, running tasks within the main Guard thread
def process
actions, changes = [], { modified: [], added: [], removed: [] }
actions = []
changes = { modified: [], added: [], removed: [] }
while pending?
if (item = @queue.pop).first.is_a?(Symbol)
@@ -24,7 +25,7 @@ def process
end
def pending?
! @queue.empty?
!@queue.empty?
end
def <<(changes)
@@ -156,9 +156,7 @@ def guardfile_notification=(config)
@guardfile_notifier_options.merge!(config)
end
def interactor_name
@interactor_name
end
attr_reader :interactor_name
# TODO: call this from within action, not within interactor command
def convert_scope(entries)
View
@@ -160,7 +160,7 @@ def self.non_namespaced_name
# @param [String] plugin_location the plugin location
#
def self.template(plugin_location)
File.read TEMPLATE_FORMAT % [plugin_location, non_namespaced_name]
File.read(format(TEMPLATE_FORMAT, plugin_location, non_namespaced_name))
end
# Called once when Guard starts. Please override initialize method to
Oops, something went wrong.

0 comments on commit 28b2dc4

Please sign in to comment.