Fix most auto-correctable rubocop issues

This commit is contained in:
Tom Hughes 2015-02-16 19:02:59 +00:00
parent 34e3e51456
commit ef7f3d800c
206 changed files with 2925 additions and 3473 deletions

View file

@ -2,7 +2,8 @@ if defined?(ActiveRecord::ConnectionAdaptors::AbstractAdapter)
module ActiveRecord
module ConnectionAdapters
class AbstractAdapter
protected
protected
alias_method :old_log, :log
def log(sql, name)

View file

@ -1,8 +1,8 @@
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
ActionView::Base.field_error_proc = proc do |html_tag, _instance|
class_attr_index = html_tag.index 'class="'
if class_attr_index
html_tag.insert class_attr_index+7, 'field_with_errors '
html_tag.insert class_attr_index + 7, 'field_with_errors '
else
html_tag.insert html_tag.index(/\/?>/), ' class="field_with_errors"'
end

View file

@ -4,7 +4,7 @@ module I18n
def pluralize(locale, entry, count)
super
rescue InvalidPluralizationData => ex
raise ex unless ex.entry.has_key?(:other)
raise ex unless ex.entry.key?(:other)
ex.entry[:other]
end
end
@ -15,7 +15,7 @@ module I18n
def make_ordered(unordered)
ordered = ActiveSupport::OrderedHash.new
unordered.keys.sort { |a,b| a.to_s <=> b.to_s }.each do |key|
unordered.keys.sort { |a, b| a.to_s <=> b.to_s }.each do |key|
value = unordered[key]
if value.is_a?(Hash)

View file

@ -1,5 +1,5 @@
# This is required otherwise libxml writes out memory errors to
# the standard output and exits uncleanly
LibXML::XML::Error.set_handler do |message|
raise message
fail message
end

View file

@ -1,11 +1,11 @@
# Setup any specified hard limit on the virtual size of the process
if defined?(HARD_MEMORY_LIMIT) and defined?(PhusionPassenger) and Process.const_defined?(:RLIMIT_AS)
Process.setrlimit Process::RLIMIT_AS, HARD_MEMORY_LIMIT*1024*1024, Process::RLIM_INFINITY
if defined?(HARD_MEMORY_LIMIT) && defined?(PhusionPassenger) && Process.const_defined?(:RLIMIT_AS)
Process.setrlimit Process::RLIMIT_AS, HARD_MEMORY_LIMIT * 1024 * 1024, Process::RLIM_INFINITY
end
# If we're running under passenger and a soft memory limit is
# configured then setup some rack middleware to police the limit
if defined?(SOFT_MEMORY_LIMIT) and defined?(PhusionPassenger)
if defined?(SOFT_MEMORY_LIMIT) && defined?(PhusionPassenger)
# Define some rack middleware to police the soft memory limit
class MemoryLimit
def initialize(app)
@ -24,7 +24,9 @@ if defined?(SOFT_MEMORY_LIMIT) and defined?(PhusionPassenger)
# Return the result of this request
[status, headers, body]
end
private
private
def resident_size
# Read statm to get process sizes. Format is
# Size RSS Shared Text Lib Data
@ -33,7 +35,7 @@ if defined?(SOFT_MEMORY_LIMIT) and defined?(PhusionPassenger)
end
# Return resident size in megabytes
return fields[1].to_i / 256
fields[1].to_i / 256
end
end

View file

@ -14,7 +14,7 @@ module Paperclip
end
end
Rails.application.config.after_initialize do |app|
Rails.application.config.after_initialize do |_app|
Paperclip::AssetUrlGenerator::VIEW_ACCESSORS.each do |attr|
Paperclip::AssetUrlGenerator.send("#{attr}=", ActionView::Base.send(attr))
end

View file

@ -1,5 +1,5 @@
require "yaml"
if File.exists?(piwik_file = File.expand_path("../../piwik.yml", __FILE__))
if File.exist?(piwik_file = File.expand_path("../../piwik.yml", __FILE__))
PIWIK = YAML.load_file(piwik_file)
end

View file

@ -1,5 +1,5 @@
# Load presets
POTLATCH_PRESETS = Potlatch::Potlatch.get_presets()
POTLATCH_PRESETS = Potlatch::Potlatch.get_presets
# Use SQL (faster) or Rails (more elegant) for common Potlatch reads
# getway speedup is approximately x2, whichways approximately x7

View file

@ -13,7 +13,7 @@ class R2Template < Tilt::Template
@output = R2.r2(data)
end
def evaluate(scope, locals, &block)
def evaluate(_scope, _locals, &_block)
@output
end
end

View file

@ -6,7 +6,7 @@ module ActionDispatch
class Router
class Utils
def self.normalize_path_with_encoding(path)
self.normalize_path_without_encoding(path).force_encoding("UTF-8")
normalize_path_without_encoding(path).force_encoding("UTF-8")
end
class << self

View file

@ -1,5 +1,5 @@
Sanitize::Config::OSM = Sanitize::Config::RELAXED.dup
Sanitize::Config::OSM[:elements] -= [ 'div', 'style' ]
Sanitize::Config::OSM[:elements] -= %w(div style)
Sanitize::Config::OSM[:add_attributes] = { 'a' => { 'rel' => 'nofollow' } }
Sanitize::Config::OSM[:remove_contents] = [ 'script', 'style' ]
Sanitize::Config::OSM[:remove_contents] = %w(script style)

View file

@ -4,7 +4,7 @@ module ActionController
alias_method :old_send_file, :send_file
def send_file(file, options = {})
if file.is_a? File or file.is_a? Tempfile
if file.is_a?(File) || file.is_a?(Tempfile)
headers["Content-Length"] ||= file.size.to_s
options[:filename] ||= File.basename(file.path) unless options[:url_based_filename]

View file

@ -2,6 +2,6 @@
# does a half assed job of making TempFile act as a File
class Tempfile
def file
return @tmpfile
@tmpfile
end
end