Skip to content

Commit

Permalink
Fix style offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Aug 14, 2016
1 parent c82d2ae commit 173b3d0
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 19 deletions.
6 changes: 6 additions & 0 deletions lib/nanoc/base/contracts_support.rb
Expand Up @@ -6,9 +6,15 @@ module ContractsSupport
class Ignorer
include Singleton

# rubocop:disable Style/MethodMissing
def method_missing(*_args)
self
end
# rubocop:enable Style/MethodMissing

def respond_to_missing?(*_args)
true
end
end

module DisabledContracts
Expand Down
4 changes: 2 additions & 2 deletions lib/nanoc/base/repos/data_source.rb
Expand Up @@ -61,7 +61,7 @@ def loading
#
# @return [void]
def use
up if @references == 0
up if @references.zero?
@references += 1
end

Expand All @@ -74,7 +74,7 @@ def use
# @return [void]
def unuse
@references -= 1
down if @references == 0
down if @references.zero?
end

# Brings up the connection to the data. Depending on the way data is
Expand Down
2 changes: 1 addition & 1 deletion lib/nanoc/cli/commands/compile.rb
Expand Up @@ -271,7 +271,7 @@ def initialize(*)
# @see Listener#start
def start
Nanoc::Int::NotificationCenter.on(:compilation_started) do |_rep|
if @gc_count % 20 == 0
if (@gc_count % 20).zero?
GC.enable
GC.start
GC.disable
Expand Down
4 changes: 2 additions & 2 deletions lib/nanoc/extra/filesystem_tools.rb
Expand Up @@ -55,7 +55,7 @@ def all_files_in(dir_name, extra_files, recursion_limit = 10)
all_files_and_dirs_in(dir_name, extra_files).map do |fn|
case File.ftype(fn)
when 'link'
if 0 == recursion_limit
if recursion_limit.zero?
raise MaxSymlinkDepthExceededError.new(fn)
else
absolute_target = resolve_symlink(fn)
Expand Down Expand Up @@ -129,7 +129,7 @@ def resolve_symlink(filename, recursion_limit = 5)

case File.ftype(absolute_target)
when 'link'
if 0 == recursion_limit
if recursion_limit.zero?
raise MaxSymlinkDepthExceededError.new(absolute_target)
else
resolve_symlink(absolute_target, recursion_limit - 1)
Expand Down
20 changes: 10 additions & 10 deletions scripts/release
Expand Up @@ -25,27 +25,27 @@ def run(*args)
end
end

puts "=== Logging in to GitHub’s API…"
puts '=== Logging in to GitHub’s API…'
client = Octokit::Client.new(netrc: true)
puts

puts "=== Deleting old *.gem files…"
puts '=== Deleting old *.gem files…'
Dir['*.gem'].each do |fn|
puts " #{fn}…"
FileUtils.rm_f(fn)
end
puts

puts "=== Building new gem…"
puts '=== Building new gem…'
run('gem', 'build', 'nanoc.gemspec')
puts

puts "=== Reading version…"
puts '=== Reading version…'
require './lib/nanoc/version'
puts "Version = #{Nanoc::VERSION}"
puts

puts "=== Verifying that release does not yet exist…"
puts '=== Verifying that release does not yet exist…'
releases = client.releases('nanoc/nanoc')
release = releases.find { |r| r.tag_name == Nanoc::VERSION }
if release
Expand All @@ -55,28 +55,28 @@ if release
end
puts

puts "=== Creating Git tag…"
puts '=== Creating Git tag…'
run('git', 'tag', '--sign', '--annotate', Nanoc::VERSION, '--message', "Version #{Nanoc::VERSION}")
puts

puts "=== Pushing Git data…"
puts '=== Pushing Git data…'
run('git', 'push', 'origin')
run('git', 'push', 'origin', '--tags')
puts

puts "=== Pushing gem…"
puts '=== Pushing gem…'
run('gem', 'push', "nanoc-#{Nanoc::VERSION}.gem")
puts

puts "=== Reading release notes…"
puts '=== Reading release notes…'
release_notes =
File.readlines('NEWS.md')
.drop(4)
.take_while { |l| l !~ /^## / }
.join
puts

puts "=== Creating release on GitHub…"
puts '=== Creating release on GitHub…'
sleep 3 # Give GitHub some time to detect the new tag
is_prerelease = Nanoc::VERSION =~ /a|b|rc/ || Nanoc::VERSION =~ /^0/
client.create_release(
Expand Down
2 changes: 1 addition & 1 deletion tasks/rubocop.rake
@@ -1,6 +1,6 @@
require 'rubocop/rake_task'

RuboCop::RakeTask.new(:rubocop) do |task|
task.options = %w( --display-cop-names --format simple )
task.options = %w(--display-cop-names --format simple)
task.patterns = ['bin/nanoc', 'lib/**/*.rb', 'spec/**/*.rb', 'test/**/*.rb']
end
2 changes: 1 addition & 1 deletion tasks/test.rake
Expand Up @@ -4,7 +4,7 @@ require 'coveralls/rake/task'

Coveralls::RakeTask.new

SUBDIRS = %w( * base cli data_sources extra filters helpers ).freeze
SUBDIRS = %w(* base cli data_sources extra filters helpers).freeze

namespace :test do
SUBDIRS.each do |dir|
Expand Down
6 changes: 6 additions & 0 deletions test/cli/test_cleaning_stream.rb
Expand Up @@ -6,9 +6,15 @@ def initialize
@called_methods = Set.new
end

# rubocop:disable Style/MethodMissing
def method_missing(symbol, *_args)
@called_methods << symbol
end
# rubocop:enable Style/MethodMissing

def respond_to_missing?(*_args)
true
end
end

def test_forward
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test_error_handler.rb
Expand Up @@ -48,7 +48,7 @@ def test_write_stack_trace_verbose

def new_error(amount_factor)
backtrace_generator = lambda do |af|
if af == 0
if af.zero?
raise 'finally!'
else
backtrace_generator.call(af - 1)
Expand Down
2 changes: 1 addition & 1 deletion test/extra/checking/checks/test_external_links.rb
Expand Up @@ -52,7 +52,7 @@ def test_fallback_to_get_when_head_is_not_allowed
# Create check
check = Nanoc::Extra::Checking::Checks::ExternalLinks.create(site)
def check.request_url_once(url, req_method = Net::HTTP::Head)
Net::HTTPResponse.new('1.1', (req_method == Net::HTTP::Head || url.path == '/405') ? '405' : '200', 'okay')
Net::HTTPResponse.new('1.1', req_method == Net::HTTP::Head || url.path == '/405' ? '405' : '200', 'okay')
end

# Test
Expand Down

0 comments on commit 173b3d0

Please sign in to comment.