Add Style/EmptyLines in .rubocop.yml and remove extra empty lines

This commit is contained in:
Ryuta Kamizono 2016-08-07 17:50:59 +09:00
parent 0d12708f39
commit 762e3f05f3
76 changed files with 4 additions and 90 deletions

@ -20,6 +20,10 @@ Style/BracesAroundHashParameters:
Style/CaseIndentation:
Enabled: true
# No extra empty lines.
Style/EmptyLines:
Enabled: true
# In a regular class definition, no empty lines around the body.
Style/EmptyLinesAroundClassBody:
Enabled: true

@ -177,7 +177,6 @@ def unsubscribe_from_channel # :nodoc:
end
end
protected
# Called once a consumer has become a subscriber of the channel. Usually the place to setup any streams
# you want this channel to be sending to the subscriber.

@ -23,7 +23,6 @@ def teardown
[@rx_adapter, @tx_adapter].uniq.each(&:shutdown)
end
def subscribe_as_queue(channel, adapter = @rx_adapter)
queue = Queue.new
@ -41,7 +40,6 @@ def subscribe_as_queue(channel, adapter = @rx_adapter)
adapter.unsubscribe(channel, callback) if subscribed.set?
end
def test_subscribe_and_unsubscribe
subscribe_as_queue("channel") do |queue|
end

@ -380,7 +380,6 @@ def welcome
end
end
test "implicit multipart with several view paths uses the first one with template" do
old = BaseMailer.view_paths
begin

@ -6,7 +6,6 @@
require "racc/parser.rb"
require "action_dispatch/journey/parser_extras"
module ActionDispatch
module Journey

@ -134,7 +134,6 @@ def polymorphic_path(record_or_hash_or_array, options = {})
opts
end
%w(edit new).each do |action|
module_eval <<-EOT, __FILE__, __LINE__ + 1
def #{action}_polymorphic_url(record_or_hash, options = {})
@ -211,7 +210,6 @@ def self.polymorphic_method(recipient, record_or_hash_or_array, action, type, op
method, args = builder.handle_model record_or_hash_or_array
end
if options.empty?
recipient.send(method, *args)
else

@ -247,7 +247,6 @@ class TestCase
end
end
class ::ApplicationController < ActionController::Base
end

@ -277,7 +277,6 @@ def test_xml_formatted_fragment_caching
@store.read("views/test.host/functional_caching/formatted_fragment_cached/#{template_digest("functional_caching/formatted_fragment_cached")}")
end
def test_fragment_caching_with_variant
get :formatted_fragment_cached_with_variant, format: "html", params: { v: :phone }
assert_response :success

@ -247,7 +247,6 @@ def test_helper=(helper_module)
end
end
class IsolatedHelpersTest < ActionController::TestCase
class A < ActionController::Base
def index

@ -51,7 +51,6 @@ def json_xml_or_html
end
end
def forced_xml
request.format = :xml
@ -109,7 +108,6 @@ def custom_type_handling
end
end
def custom_constant_handling
respond_to do |type|
type.html { render body: "HTML" }

@ -86,7 +86,6 @@ def test_render_json_render_to_string
assert_equal "[]", @response.body
end
def test_render_json
get :render_json_hello_world
assert_equal '{"hello":"world"}', @response.body

@ -99,7 +99,6 @@ def add_called_callback(name)
@called_callbacks << name
end
def custom_action
add_called_callback("custom_action")
end

@ -159,7 +159,6 @@ def test_send_file_headers_with_mime_lookup_with_symbol
assert_equal "image/png", response.content_type
end
def test_send_file_headers_with_bad_symbol
error = assert_raise(ArgumentError) { get __method__ }
assert_equal "Unknown MIME type this_type_is_not_registered", error.message

@ -50,7 +50,6 @@ def index
end
end
private
def with_test_route_set

@ -1069,7 +1069,6 @@ class RequestParameters < BaseRequestTest
end
end
class RequestParameterFilter < BaseRequestTest
test "process parameter filter" do
test_hashes = [

@ -338,7 +338,6 @@ def test_routes_can_be_filtered_with_namespaced_controllers
" DELETE /admin/posts/:id(.:format) admin/posts#destroy"], output
end
def test_regression_route_with_controller_regexp
output = draw do
ActiveSupport::Deprecation.silence do

@ -82,7 +82,6 @@ def test_served_static_file_with_non_english_filename
assert_html "means hello in Japanese\n", get("/foo/#{Rack::Utils.escape("こんにちは.html")}")
end
def test_serves_static_file_with_exclamation_mark_in_filename
with_static_file "/foo/foo!bar.html" do |file|
assert_html file, get("/foo/foo%21bar.html")

@ -105,7 +105,6 @@ def dependencies
attr_reader :name, :template
private :name, :template
private
def source
template.source

@ -24,7 +24,6 @@ class ActiveRecordTestConnector
end
$stderr.flush
# Define the rest of the connector
class ActiveRecordTestConnector
class << self

@ -1318,7 +1318,6 @@ def test_select_datetime_with_html_options
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
expected << "</select>\n"
expected << %(<select id="date_first_month" name="date[first][month]" class="selector">\n)
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
expected << "</select>\n"
@ -1953,7 +1952,6 @@ def test_date_select_within_fields_for_with_blank_index
concat f.date_select(:written_on)
end
expected = %{<select id="post_#{id}_written_on_1i" name="post[#{id}][written_on(1i)]">\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option selected="selected" value="2004">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n</select>\n}
expected << %{<select id="post_#{id}_written_on_2i" name="post[#{id}][written_on(2i)]">\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option selected="selected" value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n</select>\n}
expected << %{<select id="post_#{id}_written_on_3i" name="post[#{id}][written_on(3i)]">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option selected="selected" value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n</select>\n}

@ -2257,7 +2257,6 @@ def test_deep_nested_fields_for
assert_dom_equal expected, output_buffer
end
def test_nested_fields_for_with_nested_collections
form_for(@post, as: "post[]") do |f|
concat f.text_field(:title)

@ -57,7 +57,6 @@ def test_collection_options
)
end
def test_collection_options_with_preselected_value
assert_dom_equal(
"<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" selected=\"selected\">Babe went home</option>\n<option value=\"Cabe\">Cabe went home</option>",

@ -517,7 +517,6 @@ def test_submit_tag_with_symbol_value
)
end
def test_button_tag
assert_dom_equal(
%(<button name="button" type="submit">Button</button>),

@ -2,7 +2,6 @@
require "jobs/hello_job"
require "active_support/core_ext/numeric/time"
class QueuingTest < ActiveSupport::TestCase
setup do
JobBuffer.clear
@ -32,7 +31,6 @@ class QueuingTest < ActiveSupport::TestCase
assert_equal [ "Jamie" ], job.arguments
end
test "job returned by perform_at has the timestamp available" do
begin
job = HelloJob.set(wait_until: Time.utc(2014, 1, 1)).perform_later

@ -17,7 +17,6 @@ class CallbackJob < ActiveJob::Base
job.history << "CallbackJob ran around_enqueue_stop"
end
def perform(person = "david")
# NOTHING!
end

@ -12,7 +12,6 @@ def safe_ensure_connected
end
end
module SneakersJobsManager
def setup
ActiveJob::Base.queue_adapter = :sneakers

@ -71,7 +71,6 @@ def set_after_validation_marker1; self.history << "after_validation_marker1"; en
def set_after_validation_marker2; self.history << "after_validation_marker2" ; end
end
class CallbacksWithMethodNamesShouldBeCalled < ActiveModel::TestCase
def test_if_condition_is_respected_for_before_validation
d = DogValidatorWithIfCondition.new

@ -336,7 +336,6 @@ def test_validates_length_of_with_block
assert_equal ["Your essay must be at least 5 words."], t.errors[:content]
end
def test_validates_length_of_with_symbol
assert_deprecated do
Topic.validates_length_of(

@ -79,7 +79,6 @@ def reset_association(owners, association_name)
end
end
def through_scope
scope = through_reflection.klass.unscoped

@ -35,7 +35,6 @@ def data_source_exists?(name)
alias table_exists? data_source_exists?
deprecate table_exists?: "use #data_source_exists? instead"
# Add internal cache for table with +table_name+.
def add(table_name)
if data_source_exists?(table_name)

@ -184,7 +184,6 @@ def inherited(subclass)
end
end
# In de/serialize we change `nil` to 0, so that we can allow passing
# `nil` values to `lock_version`, and not result in `ActiveRecord::StaleObjectError`
# during update record.

@ -23,7 +23,6 @@ class Railtie < Rails::Railtie # :nodoc:
"ActiveRecord::RecordNotSaved" => :unprocessable_entity
)
config.active_record.use_schema_cache_dump = true
config.active_record.maintain_test_schema = true

@ -317,7 +317,6 @@ def derive_class_name
end
end
# Holds all the meta-data about an aggregation as it was specified in the
# Active Record class.
class AggregateReflection < MacroReflection #:nodoc:

@ -92,7 +92,6 @@ def expand_from_hash(attributes)
end
end
def create_binds_for_hash(attributes)
result = attributes.dup
binds = []

@ -1,7 +1,6 @@
require "cases/helper"
require "support/ddl_helper"
class PostgresqlTime < ActiveRecord::Base
end

@ -137,7 +137,6 @@ def test_has_and_belongs_to_many_after_add_called_after_save
assert_equal "after_adding<new>", ar.developers_log.last
end
def test_has_and_belongs_to_many_remove_callback
david = developers(:david)
jamis = developers(:jamis)

@ -58,8 +58,6 @@ class NonPolyTwo < ActiveRecord::Base
include Remembered
end
class EagerLoadPolyAssocsTest < ActiveRecord::TestCase
NUM_SIMPLE_OBJS = 50
NUM_SHAPE_EXPRESSIONS = 100

@ -1,6 +1,5 @@
require "cases/helper"
if ActiveRecord::Base.connection.supports_migrations?
class EagerSingularizationTest < ActiveRecord::TestCase
class Virus < ActiveRecord::Base

@ -226,7 +226,6 @@ def test_parent_instance_should_be_shared_with_child_on_find
assert_equal m.name, f.man.name, "Name of man should be the same after changes to child-owned instance"
end
def test_parent_instance_should_be_shared_with_eager_loaded_child_on_find
m = Man.all.merge!(where: {name: "Gordon"}, includes: :face).first
f = m.face

@ -472,7 +472,6 @@ def test_associating_unsaved_records_with_has_many_through
assert new_tag.persisted?
assert saved_post.reload.tags.reload.include?(new_tag)
new_post = Post.new(title: "Association replacement works!", body: "You best believe it.")
saved_tag = tags(:general)

@ -56,7 +56,6 @@ def test_loading_the_association_target_should_load_most_recent_attributes_for_c
assert_equal "Deck", ship.parts[0].name
end
def test_include_with_order_works
assert_nothing_raised {Account.all.merge!(order: "id", includes: :firm).first}
assert_nothing_raised {Account.all.merge!(order: :id, includes: :firm).first}

@ -134,7 +134,6 @@ def test_time_attributes_changes_without_time_zone
end
end
def test_aliased_attribute_changes
# the actual attribute here is name, title is an
# alias setup via alias_attribute
@ -408,7 +407,6 @@ def test_reverted_changes_are_not_dirty_after_multiple_changes
assert !pirate.changed?
end
def test_reverted_changes_are_not_dirty_going_from_nil_to_value_and_back
pirate = Pirate.create!(catchphrase: "Yar!")

@ -479,7 +479,6 @@ def test_subclassing_should_preserve_setups
end
end
class OverlappingFixturesTest < ActiveRecord::TestCase
fixtures :topics, :developers
fixtures :developers, :accounts

@ -374,7 +374,6 @@ def counter_test(model, expected_count)
end
end
# TODO: test against the generated SQL since testing locking behavior itself
# is so cumbersome. Will deadlock Ruby threads if the underlying db.execute
# blocks, so separate script called by Kernel#system is needed.

@ -49,7 +49,6 @@ def test_rename_index_too_long
assert connection.index_name_exists?(table_name, "old_idx", false)
end
def test_double_add_index
connection.add_index(table_name, [:foo], name: "some_idx")
assert_raises(ArgumentError) {

@ -401,7 +401,6 @@ def test_internal_metadata_stores_environment
ENV["RACK_ENV"] = original_rack_env
end
def test_migration_sets_internal_metadata_even_when_fully_migrated
current_env = ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
migrations_path = MIGRATIONS_ROOT + "/valid"

@ -35,7 +35,6 @@ def test_cant_save_readonly_record
assert_equal "Developer is marked as readonly", e.message
end
def test_find_with_readonly_option
Developer.all.each { |d| assert !d.readonly? }
Developer.readonly(false).each { |d| assert !d.readonly? }

@ -132,7 +132,6 @@ def relation
assert_equal "title DESC", relation.order_values.first
assert_equal "comments_count ASC", relation.order_values.last
relation.reverse_order!
assert_equal "title ASC", relation.order_values.first

@ -953,7 +953,6 @@ def test_find_all_using_where_with_relation_with_joins
}
end
def test_find_all_using_where_with_relation_with_select_to_build_subquery
david = authors(:david)
assert_queries(1) {

@ -25,7 +25,6 @@ def test_statement_cache
assert_equal "my other book", b[0].name
end
def test_statement_cache_id
b1 = Book.create(name: "my book")
b2 = Book.create(name: "my other book")

@ -449,7 +449,6 @@ def test_before_commit_update_in_same_transaction
end
end
class TransactionEnrollmentCallbacksTest < ActiveRecord::TestCase
class TopicWithoutTransactionalEnrollmentCallbacks < ActiveRecord::Base
self.table_name = :topics

@ -12,7 +12,6 @@ def self.name; "Owner"; end
end
end
def test_validates_size_of_association
assert_nothing_raised { @owner.validates_size_of :pets, minimum: 1 }
o = @owner.new("name" => "nopets")

@ -60,7 +60,6 @@ class PersonWithDependentNullifyJobs < ActiveRecord::Base
has_many :jobs, source: :job, through: :references, dependent: :nullify
end
class LoosePerson < ActiveRecord::Base
self.table_name = "people"
self.abstract_class = true

@ -13,7 +13,6 @@ class ShareLock
# we need exclusive locks to be reentrant, and we need to be able
# to upgrade share locks to exclusive.
def raw_state # :nodoc:
synchronize do
threads = @sleeping.keys | @sharing.keys | @waiting.keys

@ -161,7 +161,6 @@ def key?(key)
alias_method :has_key?, :key?
alias_method :member?, :key?
# Same as <tt>Hash#[]</tt> where the key passed as argument can be
# either a string or a symbol:
#

@ -66,7 +66,6 @@ def test_order
alias :assert_not_respond_to :refute_respond_to
alias :assert_not_same :refute_same
# Assertion that the block should not raise an exception.
#
# Passes if evaluated code in the yielded block raises no exception.

@ -181,8 +181,6 @@ def test_after_save_runs_in_the_reverse_order
end
end
class ConditionalPerson < Record
# proc
before_save Proc.new { |r| r.history << [:before_save, :proc] }, if: Proc.new { |r| true }
@ -489,8 +487,6 @@ def test_save_conditional_person
end
end
class ResetCallbackTest < ActiveSupport::TestCase
def test_save_conditional_person
person = CleanPerson.new

@ -276,7 +276,6 @@ def test_deep_symbolize_keys_for_hash_with_indifferent_access
assert_equal @nested_symbols, @nested_mixed.with_indifferent_access.deep_symbolize_keys
end
def test_symbolize_keys_bang_for_hash_with_indifferent_access
assert_raise(NoMethodError) { @symbols.with_indifferent_access.dup.symbolize_keys! }
assert_raise(NoMethodError) { @strings.with_indifferent_access.dup.symbolize_keys! }

@ -1,7 +1,6 @@
require "abstract_unit"
require "active_support/core_ext/load_error"
class TestMissingSourceFile < ActiveSupport::TestCase
def test_it_is_deprecated
assert_deprecated do

@ -509,7 +509,6 @@ def quux=(v); "quux=" end
assert_respond_to @instance, :quux_with_baz?
assert_respond_to @instance, :quux_with_baz=
FooClassWithBarMethod.alias_method_chain :quux!, :baz
assert_equal "quux!_with_baz", @instance.quux!
assert_equal "quux!", @instance.quux_without_baz!

@ -176,7 +176,6 @@ def test_to_s__currency
assert_equal("&pound;1234567890,50", 1234567890.50.to_s(:currency, unit: "&pound;", separator: ",", delimiter: ""))
end
def test_to_s__rounded
assert_equal("-111.235", -111.2346.to_s(:rounded))
assert_equal("111.235", 111.2346.to_s(:rounded))
@ -222,7 +221,6 @@ def test_to_s__delimited__with_options_hash
assert_equal "12.345.678,05", 12345678.05.to_s(:delimited, delimiter: ".", separator: ",")
end
def test_to_s__rounded_with_custom_delimiter_and_separator
assert_equal "31,83", 31.825.to_s(:rounded, precision: 2, separator: ",")
assert_equal "1.231,83", 1231.825.to_s(:rounded, precision: 2, separator: ",", delimiter: ".")

@ -1036,7 +1036,6 @@ def test_access_unloaded_constants_for_reload
remove_constants(:A)
end
def test_autoload_once_paths_should_behave_when_recursively_loading
old_path = ActiveSupport::Dependencies.autoload_once_paths
with_loading "dependencies", "autoloading_fixtures" do

@ -35,7 +35,6 @@ module B
A = ActiveSupport::Deprecation::DeprecatedConstantProxy.new("Deprecatee::A", "Deprecatee::B::C")
end
class DeprecationTest < ActiveSupport::TestCase
include ActiveSupport::Testing::Stream

@ -80,7 +80,6 @@ def run(*args)
assert_equal 1, i
end
test "updated should become true when watched files are created" do
i = 0
@ -92,7 +91,6 @@ def run(*args)
assert checker.updated?
end
test "updated should become true when watched files are modified" do
i = 0

@ -80,7 +80,6 @@ def test_uncountable_word_is_not_greedy
end
end
def test_overwrite_previous_inflectors
assert_equal("series", ActiveSupport::Inflector.singularize("series"))
ActiveSupport::Inflector.inflections.singular "series", "serie"

@ -306,7 +306,6 @@ def test_struct_encoding
user_birthday = Struct::UserNameAndDate.new "David", Date.new(2010, 01, 01)
custom = Struct::Custom.new "David", user_birthday
json_strings = ""
json_string_and_date = ""
json_custom = ""

@ -1,6 +1,5 @@
require "abstract_unit"
class MultibyteUnicodeDatabaseTest < ActiveSupport::TestCase
include ActiveSupport::Multibyte::Unicode

@ -97,7 +97,6 @@ def sos_cool_error
end
end
class RescuableTest < ActiveSupport::TestCase
def setup
@stargate = Stargate.new

@ -3,7 +3,6 @@
require "active_support/xml_mini"
require "active_support/core_ext/hash/conversions"
class JDOMEngineTest < ActiveSupport::TestCase
include ActiveSupport
@ -56,7 +55,6 @@ def test_not_allowed_to_expand_parameter_entities_to_files
end
end
def test_not_allowed_to_load_external_doctypes
attack_xml = <<-EOT
<!DOCTYPE member SYSTEM "file://#{FILES_DIR}/jdom_doctype.dtd">

@ -191,7 +191,6 @@ def test_children_with_blank_text_and_attribute
eoxml
end
private
def assert_equal_rexml(xml)
parsed_xml = XmlMini.parse(xml)

@ -274,7 +274,6 @@ def log(*args)
end
end
# Runs the supplied command using either "rake ..." or "rails ..."
# based on the executor parameter provided.
def execute_command(executor, command, options={})

@ -666,7 +666,6 @@ class Post
end
RUBY
app_file "app/controllers/posts_controller.rb", <<-RUBY
class PostsController < ApplicationController
def index

@ -40,7 +40,6 @@ def test_start
def test_start_with_sandbox
start ["--sandbox"]
assert app.console.started?
assert app.sandbox
assert_match(/Loading \w+ environment in sandbox \(Rails/, output)

@ -618,7 +618,6 @@ def test_dummy_api_application_for_api_plugins
end
end
def test_api_generators_configuration_for_api_engines
run_generator [destination_root, "--full", "--api"]

@ -1226,7 +1226,6 @@ def index
end
RUBY
app_file "config/routes.rb", <<-RUBY
Rails.application.routes.draw do
mount Bukkits::Engine => "/"
@ -1276,7 +1275,6 @@ def index
end
RUBY
@plugin.write "app/controllers/bukkits/bukkit_controller.rb", <<-RUBY
class Bukkits::BukkitController < ActionController::Base
def index

@ -34,7 +34,6 @@ def setup
end
RUBY
@simple_plugin.write "lib/weblog.rb", <<-RUBY
module Weblog
class Engine < ::Rails::Engine
@ -239,7 +238,6 @@ def app
get "/metrics/generate_blog_route_in_view", {}, "SCRIPT_NAME" => "/foo"
assert_equal "/foo/anonymous/blog/posts/1", last_response.body
# test generating application's route from engine with default_url_options
get "/someone/blog/generate_application_route", {}, "SCRIPT_NAME" => "/foo"
assert_equal "/foo/", last_response.body