Clean up some Rubocop warnings that were previously suppressed.

This commit is contained in:
Ben Hollis 2014-05-24 00:22:09 -07:00
parent dd7f06968a
commit 9a3f9fe488
7 changed files with 39 additions and 53 deletions

View file

@ -6,12 +6,11 @@ require 'padrino-helpers'
class Padrino::Helpers::OutputHelpers::ErbHandler
# Force Erb capture not to use safebuffer
# rubocop:disable UnderscorePrefixedVariableName
def capture_from_template(*args, &block)
self.output_buffer, _buf_was = '', output_buffer
self.output_buffer, buf_was = '', output_buffer
raw = block.call(*args)
captured = template.instance_variable_get(:@_out_buf)
self.output_buffer = _buf_was
self.output_buffer = buf_was
engine_matches?(block) ? captured : raw
end
end
@ -39,7 +38,6 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
helpers do
# Make all block content html_safe
# rubocop:disable Semicolon
def content_tag(name, content=nil, options=nil, &block)
# safe_content_tag(name, content, options, &block)
if block_given?
@ -53,7 +51,10 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
output.safe_concat "<#{name}#{attributes}>"
if content.respond_to?(:each) && !content.is_a?(String)
content.each { |c| output.safe_concat c; output.safe_concat ::Padrino::Helpers::TagHelpers::NEWLINE }
content.each do |c|
output.safe_concat c
output.safe_concat ::Padrino::Helpers::TagHelpers::NEWLINE
end
else
output.safe_concat "#{content}"
end
@ -72,17 +73,10 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
ActiveSupport::SafeBuffer.new.safe_concat(result)
end
# rubocop:disable MultilineBlockChain, UnusedBlockArgument
def auto_find_proper_handler(&block)
if block_given?
engine = File.extname(block.source_location[0])[1..-1].to_sym
::Padrino::Helpers::OutputHelpers.handlers.select do |e, h|
e == engine
end.values.map do |h|
h.new(self)
end.find do |h|
h.engine_matches?(block)
end
::Padrino::Helpers::OutputHelpers.handlers.select { |e, _| e == engine }.values.map { |h| h.new(self) }.find { |h| h.engine_matches?(block) }
else
find_proper_handler
end
@ -195,10 +189,8 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
#
# @param [String] path The path (such as "photo.jpg")
# @param [String] prefix The type prefix (such as "images")
# @param [Hash] options Data to pass through.
# @return [String] The fully qualified asset url
# rubocop:disable UnusedMethodArgument
def asset_url(path, prefix='', options={})
def asset_url(path, prefix='', _)
# Don't touch assets which already have a full path
if path.include?('//') || path.start_with?('data:')
path

View file

@ -124,12 +124,11 @@ module Middleman
# configuration can be included later without impacting
# other classes and instances.
#
# rubocop:disable ClassVars
# @return [Class]
def server(&block)
@@servercounter ||= 0
@@servercounter += 1
const_set("MiddlemanApplication#{@@servercounter}", Class.new(Middleman::Application, &block))
@servercounter ||= 0
@servercounter += 1
const_set("MiddlemanApplication#{@servercounter}", Class.new(Middleman::Application, &block))
end
end

View file

@ -280,7 +280,6 @@ module Middleman
@klass.after_configuration do
ext.after_configuration if ext.respond_to?(:after_configuration)
# rubocop:disable IfUnlessModifier
if ext.respond_to?(:manipulate_resource_list)
ext.app.sitemap.register_resource_list_manipulator(ext.class.ext_name, ext, ext.class.resource_list_manipulator_priority)
end

View file

@ -20,7 +20,6 @@ module Middleman
# @param [Hash] opts
# @param [Class] context
# @return [String]
# rubocop:disable UnderscorePrefixedVariableName
def render(locs={}, opts={}, context, &block)
path = @path.dup
@ -32,7 +31,7 @@ module Middleman
context.current_engine, engine_was = engine, context.current_engine
# Save current buffer for later
_buf_was = context.save_buffer
buf_was = context.save_buffer
# Read from disk or cache the contents of the file
body = if opts[:template_body]
@ -85,7 +84,7 @@ module Middleman
output
ensure
# Reset stored buffer
context.restore_buffer(_buf_was)
context.restore_buffer(buf_was)
context.current_engine = engine_was
end

View file

@ -2,7 +2,6 @@ require 'webrick'
require 'middleman-core/meta_pages'
require 'middleman-core/logger'
# rubocop:disable GlobalVars
module Middleman
module PreviewServer
DEFAULT_PORT = 4567
@ -35,12 +34,12 @@ module Middleman
loop do
@webrick.start
# $mm_shutdown is set by the signal handler
if $mm_shutdown
# @mm_shutdown is set by the signal handler
if @mm_shutdown
shutdown
exit
elsif $mm_reload
$mm_reload = false
elsif @mm_reload
@mm_reload = false
reload
end
end
@ -130,7 +129,7 @@ module Middleman
# See if the changed file is config.rb or lib/*.rb
if needs_to_reload?(added_and_modified + removed)
$mm_reload = true
@mm_reload = true
@webrick.stop
else
added_and_modified.each do |path|
@ -156,7 +155,7 @@ module Middleman
if Signal.list[sig]
Signal.trap(sig) do
# Do as little work as possible in the signal context
$mm_shutdown = true
@mm_shutdown = true
@webrick.stop
end
end

View file

@ -1,22 +1,21 @@
module Middleman
module Profiling
# The profiler instance. There can only be one!
# rubocop:disable TrivialAccessors
def self.profiler=(prof)
@profiler = prof
end
def self.profiler
@profiler ||= NullProfiler.new
end
class << self
# The profiler instance. There can only be one!
attr_writer :profiler
def profiler
@profiler ||= NullProfiler.new
end
# Start the profiler
def self.start
profiler.start
end
# Start the profiler
def start
profiler.start
end
# Stop the profiler and generate a report. Make sure to call start first
def self.report(report_name)
profiler.report(report_name)
# Stop the profiler and generate a report. Make sure to call start first
def report(report_name)
profiler.report(report_name)
end
end
# A profiler that does nothing. The default.

View file

@ -1,7 +1,6 @@
require 'middleman-core/file_renderer'
require 'middleman-core/template_renderer'
# rubocop:disable UnderscorePrefixedVariableName
module Middleman
class TemplateContext
attr_reader :app
@ -16,13 +15,13 @@ module Middleman
end
def save_buffer
@_out_buf, _buf_was = '', @_out_buf
_buf_was
@_out_buf, buf_was = '', @_out_buf
buf_was
end
# rubocop:disable TrivialAccessors
def restore_buffer(_buf_was)
@_out_buf = _buf_was
def restore_buffer(buf_was)
@_out_buf = buf_was
end
# Allow layouts to be wrapped in the contents of other layouts
@ -30,7 +29,7 @@ module Middleman
# @return [void]
def wrap_layout(layout_name, &block)
# Save current buffer for later
_buf_was = save_buffer
buf_was = save_buffer
layout_path = ::Middleman::TemplateRenderer.locate_layout(@app, layout_name, current_engine)
@ -48,7 +47,7 @@ module Middleman
end
ensure
# Reset stored buffer
restore_buffer(_buf_was)
restore_buffer(buf_was)
end
file_renderer = ::Middleman::FileRenderer.new(@app, layout_path)