fix(rubocop): Fix Layout related offenses [ci skip]

- Layout/EmptyLines
- Layout/EmptyLineAfterGuardClause
- Layout/TrailingEmptyLines
- Layout/EmptyLinesAroundBlockBody
- Layout/EmptyLinesAroundModuleBody
- Layout/EmptyLineAfterMagicComment
- Layout/SpaceInsidePercentLiteralDelimiters
- Layout/SpaceAroundEqualsInParameterDefault
- Layout/SpaceInsideArrayLiteralBrackets
- Layout/LeadingCommentSpace
- Layout/SpaceBeforeComment
- Layout/SpaceAroundOperators
- Layout/SpaceInsideRangeLiteral
- Layout/SpaceInsideReferenceBrackets
- Layout/SpaceInLambdaLiteral
- Layout/SpaceAfterComma
- Layout/SpaceInsideHashLiteralBraces
- Layout/TrailingWhitespace
- Layout/ArgumentAlignment
- Layout/HashAlignment
- Layout/DotPosition
- Layout/IndentationWidth
- Layout/EndAlignment
- Layout/MultilineOperationIndentation
- Layout/IndentationConsistency
- Layout/ClosingHeredocIndentation
- Layout/MultilineMethodCallBrace- Layout
- Layout/ClosingParenthesisIndentation
This commit is contained in:
Kapil Sachdev 2020-09-05 17:44:10 +05:30 committed by Elliot Winkler
parent 0acc27eaac
commit ee1008de7a
44 changed files with 98 additions and 101 deletions

View File

@ -15,6 +15,7 @@ def class_list(root = Registry.root, tree = TreeContext.new)
end
children.compact.sort_by(&:path).each do |child|
next unless child.is_a?(CodeObjects::NamespaceObject)
name = child.namespace.is_a?(CodeObjects::Proxy) ? child.path : child.name
has_children = run_verifier(child.children).any? {|o| o.is_a?(CodeObjects::NamespaceObject) }
out << "<li id='object_#{child.path}' class='#{tree.classes.join(' ')}'>"

View File

@ -183,7 +183,6 @@ module Shoulda
end
end
def guess_controller_if_necessary(controller)
params[:controller] ||= controller.controller_path
end

View File

@ -18,6 +18,7 @@ module Shoulda
unless numericality_matcher.respond_to? :diff_to_compare
raise ArgumentError, 'numericality_matcher is invalid'
end
@numericality_matcher = numericality_matcher
@value = value
@operator = operator

View File

@ -372,9 +372,9 @@ module Shoulda
def allow_nil
@expects_to_allow_nil = true
prepare_submatcher(
AllowValueMatcher.new(nil)
.for(@attribute)
.with_message(:not_a_number),
AllowValueMatcher.new(nil).
for(@attribute).
with_message(:not_a_number),
)
self
end

View File

@ -58,8 +58,6 @@ module Shoulda
@instance
end
end
end
end
end

View File

@ -63,12 +63,14 @@ module Shoulda
def failure_message
return if !@errors
"Expected #{@subject.class} to #{description} but the following " \
"errors were found: #{@errors.join(', ')}"
end
def failure_message_when_negated
return if !@errors
"Did not expect #{@subject.class} to have secure token " \
":#{token_attribute}"
end

View File

@ -30,6 +30,7 @@ module Shoulda
def self.indent(string, width)
return if !string
indentation = ' ' * width
string.split(/[\n\r]/).map { |line| indentation + line }.join("\n")
end

View File

@ -10,8 +10,7 @@ module UnitTests
def builder_for_record_validating_confirmation_with_18n_message(options = {})
builder = builder_for_record_validating_confirmation(options)
RecordBuilderWithI18nValidationMessage.new(builder,
validation_message_key: :confirmation,
)
validation_message_key: :confirmation,)
end
end
end

View File

@ -23,7 +23,6 @@ describe Shoulda::Matchers::ActionController::RenderWithLayoutMatcher, type: :co
end
context 'a controller that renders without a layout' do
it 'rejects rendering with a layout' do
controller_without_layout = build_fake_response { render layout: false }

View File

@ -37,8 +37,7 @@ describe Shoulda::Matchers::ActiveModel::DisallowValueMatcher, type: :model do
it "delegates its failure message to its allow matcher's negative failure message" do
allow_matcher = double('allow_matcher',
failure_message_when_negated: 'allow matcher failure',
).as_null_object
failure_message_when_negated: 'allow matcher failure',).as_null_object
allow(Shoulda::Matchers::ActiveModel::AllowValueMatcher).
to receive(:new).
and_return(allow_matcher)

View File

@ -1,4 +1,5 @@
# encoding: UTF-8
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::Helpers do

View File

@ -241,7 +241,8 @@ could not be proved.
before do
stub_translation(
'activerecord.errors.messages.too_long',
'The %{attribute} of your %{model} is too long (maximum is %{count} characters)',)
'The %{attribute} of your %{model} is too long (maximum is %{count} characters)',
)
end
it 'does not raise an exception' do
@ -256,7 +257,8 @@ could not be proved.
before do
stub_translation(
'activerecord.errors.messages.too_short',
'The %{attribute} of your %{model} is too short (minimum is %{count} characters)',)
'The %{attribute} of your %{model} is too short (minimum is %{count} characters)',
)
end
it 'does not raise an exception' do
@ -270,7 +272,8 @@ could not be proved.
before do
stub_translation(
'activerecord.errors.messages.wrong_length',
'The %{attribute} of your %{model} is the wrong length (should be %{count} characters)',)
'The %{attribute} of your %{model} is the wrong length (should be %{count} characters)',
)
end
it 'does not raise an exception' do

View File

@ -886,7 +886,8 @@ could not be proved.
before do
stub_translation(
'activerecord.errors.messages.blank',
'Please enter a %{attribute} for your %{model}',)
'Please enter a %{attribute} for your %{model}',
)
end
after { I18n.backend.reload! }

View File

@ -858,8 +858,7 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher, type: :model do
it 'accepts a valid association with a :through option' do
define_model :child
define_model :conception, child_id: :integer,
parent_id: :integer do
define_model :conception, child_id: :integer, parent_id: :integer do
belongs_to :child
end
define_model :parent do
@ -877,9 +876,7 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher, type: :model do
has_many :children, through: :conceptions
end
expect { have_many(:children) }
.not_to match_against(parent_class.new)
.and_fail_with(<<-MESSAGE)
expect { have_many(:children) }.not_to match_against(parent_class.new).and_fail_with(<<-MESSAGE)
Expected Parent to have a has_many association called children through conceptions (Could not find the source association(s) "child" or :children in model Conception. Try 'has_many :children, :through => :conceptions, :source => <name>'. Is it one of ?)
MESSAGE
end
@ -1442,7 +1439,6 @@ Expected Parent to have a has_many association called children through conceptio
}.to fail_with_message(message)
end
it 'accepts an association with a through' do
define_model :detail
@ -1977,9 +1973,7 @@ Expected Person to have a has_and_belongs_to_many association called relatives (
some_foreign_key_id: :integer
expect(Person.new).to have_and_belong_to_many(:relatives)
end
end
it 'rejects an association of the wrong type' do

View File

@ -3,7 +3,6 @@ require 'unit_spec_helper'
# rubocop:disable Metrics/BlockLength
describe Shoulda::Matchers::ActiveRecord::HaveSecureTokenMatcher,
type: :model do
if active_record_supports_has_secure_token?
describe '#description' do
it 'returns the message including the name of the default column' do

View File

@ -186,8 +186,7 @@ module Shoulda::Matchers::Doublespeak
object: instance,
method_name: method_name,
args: expected_args,
block: expected_block,
)
block: expected_block,)
double = described_class.new(
world,
klass,

View File

@ -610,6 +610,7 @@ to account for when #country *was* nil.
def hello
return unless country
country.hello
end
end