Merge pull request #26077 from kamipo/add_stype_empty_lines

Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty lines
This commit is contained in:
Xavier Noria 2016-08-07 11:48:29 +02:00 committed by GitHub
commit fb98d2e571
76 changed files with 4 additions and 90 deletions

View File

@ -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

View File

@ -177,7 +177,6 @@ module ActionCable
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.

View File

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

View File

@ -380,7 +380,6 @@ class BaseTest < ActiveSupport::TestCase
end
end
test "implicit multipart with several view paths uses the first one with template" do
old = BaseMailer.view_paths
begin

View File

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

View File

@ -134,7 +134,6 @@ module ActionDispatch
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 @@ module ActionDispatch
method, args = builder.handle_model record_or_hash_or_array
end
if options.empty?
recipient.send(method, *args)
else

View File

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

View File

@ -277,7 +277,6 @@ CACHED
@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

View File

@ -247,7 +247,6 @@ class HelperTest < ActiveSupport::TestCase
end
end
class IsolatedHelpersTest < ActionController::TestCase
class A < ActionController::Base
def index

View File

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

View File

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

View File

@ -99,7 +99,6 @@ class PrependProtectForgeryBaseController < ActionController::Base
@called_callbacks << name
end
def custom_action
add_called_callback("custom_action")
end

View File

@ -159,7 +159,6 @@ class SendFileTest < ActionController::TestCase
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

View File

@ -50,7 +50,6 @@ class RequestIdResponseTest < ActionDispatch::IntegrationTest
end
end
private
def with_test_route_set

View File

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

View File

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

View File

@ -82,7 +82,6 @@ module StaticTests
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")

View File

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

View File

@ -24,7 +24,6 @@ unless defined?(ActiveRecord) && defined?(FixtureSet)
end
$stderr.flush
# Define the rest of the connector
class ActiveRecordTestConnector
class << self

View File

@ -1318,7 +1318,6 @@ class DateHelperTest < ActionView::TestCase
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 @@ class DateHelperTest < ActionView::TestCase
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}

View File

@ -2257,7 +2257,6 @@ class FormHelperTest < ActionView::TestCase
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)

View File

@ -57,7 +57,6 @@ class FormOptionsHelperTest < ActionView::TestCase
)
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>",

View File

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

View File

@ -2,7 +2,6 @@ require "helper"
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

View File

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

View File

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

View File

@ -71,7 +71,6 @@ class DogValidatorWithIfCondition < Dog
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

View File

@ -336,7 +336,6 @@ class LengthValidationTest < ActiveModel::TestCase
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(

View File

@ -79,7 +79,6 @@ module ActiveRecord
end
end
def through_scope
scope = through_reflection.klass.unscoped

View File

@ -35,7 +35,6 @@ module ActiveRecord
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)

View File

@ -184,7 +184,6 @@ module ActiveRecord
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.

View File

@ -23,7 +23,6 @@ module ActiveRecord
"ActiveRecord::RecordNotSaved" => :unprocessable_entity
)
config.active_record.use_schema_cache_dump = true
config.active_record.maintain_test_schema = true

View File

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

View File

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

View File

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

View File

@ -137,7 +137,6 @@ class AssociationCallbacksTest < ActiveRecord::TestCase
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)

View File

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

View File

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

View File

@ -226,7 +226,6 @@ class InverseHasOneTests < ActiveRecord::TestCase
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

View File

@ -472,7 +472,6 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase
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)

View File

@ -56,7 +56,6 @@ class AssociationsTest < ActiveRecord::TestCase
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}

View File

@ -134,7 +134,6 @@ class DirtyTest < ActiveRecord::TestCase
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 @@ class DirtyTest < ActiveRecord::TestCase
assert !pirate.changed?
end
def test_reverted_changes_are_not_dirty_going_from_nil_to_value_and_back
pirate = Pirate.create!(catchphrase: "Yar!")

View File

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

View File

@ -374,7 +374,6 @@ class OptimisticLockingWithSchemaChangeTest < ActiveRecord::TestCase
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.

View File

@ -49,7 +49,6 @@ module ActiveRecord
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) {

View File

@ -401,7 +401,6 @@ class MigrationTest < ActiveRecord::TestCase
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"

View File

@ -35,7 +35,6 @@ class ReadOnlyTest < ActiveRecord::TestCase
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? }

View File

@ -132,7 +132,6 @@ module ActiveRecord
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

View File

@ -953,7 +953,6 @@ class RelationTest < ActiveRecord::TestCase
}
end
def test_find_all_using_where_with_relation_with_select_to_build_subquery
david = authors(:david)
assert_queries(1) {

View File

@ -25,7 +25,6 @@ module ActiveRecord
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")

View File

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

View File

@ -12,7 +12,6 @@ class LengthValidationTest < ActiveRecord::TestCase
end
end
def test_validates_size_of_association
assert_nothing_raised { @owner.validates_size_of :pets, minimum: 1 }
o = @owner.new("name" => "nopets")

View File

@ -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

View File

@ -13,7 +13,6 @@ module ActiveSupport
# 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

View File

@ -161,7 +161,6 @@ module ActiveSupport
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:
#

View File

@ -66,7 +66,6 @@ module ActiveSupport
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.

View File

@ -181,8 +181,6 @@ module CallbacksTest
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 @@ module CallbacksTest
end
end
class ResetCallbackTest < ActiveSupport::TestCase
def test_save_conditional_person
person = CleanPerson.new

View File

@ -276,7 +276,6 @@ class HashExtTest < ActiveSupport::TestCase
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! }

View File

@ -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

View File

@ -509,7 +509,6 @@ class MethodAliasingTest < ActiveSupport::TestCase
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!

View File

@ -176,7 +176,6 @@ class NumericExtFormattingTest < ActiveSupport::TestCase
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 @@ class NumericExtFormattingTest < ActiveSupport::TestCase
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: ".")

View File

@ -1036,7 +1036,6 @@ class DependenciesTest < ActiveSupport::TestCase
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

View File

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

View File

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

View File

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

View File

@ -306,7 +306,6 @@ class TestJSONEncoding < ActiveSupport::TestCase
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 = ""

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -618,7 +618,6 @@ class PluginGeneratorTest < Rails::Generators::TestCase
end
end
def test_api_generators_configuration_for_api_engines
run_generator [destination_root, "--full", "--api"]

View File

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

View File

@ -34,7 +34,6 @@ module ApplicationTests
end
RUBY
@simple_plugin.write "lib/weblog.rb", <<-RUBY
module Weblog
class Engine < ::Rails::Engine
@ -239,7 +238,6 @@ module ApplicationTests
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