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:
parent
0acc27eaac
commit
ee1008de7a
|
@ -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(' ')}'>"
|
||||
|
|
|
@ -183,7 +183,6 @@ module Shoulda
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def guess_controller_if_necessary(controller)
|
||||
params[:controller] ||= controller.controller_path
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ module Shoulda
|
|||
module ActionController
|
||||
# @private
|
||||
class RouteParams
|
||||
PARAMS_TO_SYMBOLIZE = %i{ format }
|
||||
PARAMS_TO_SYMBOLIZE = %i{format}
|
||||
|
||||
def initialize(args)
|
||||
@args = args
|
||||
|
|
|
@ -46,7 +46,7 @@ module Shoulda
|
|||
self
|
||||
end
|
||||
|
||||
def with_message(message, options={})
|
||||
def with_message(message, options = {})
|
||||
allow_matcher.with_message(message, options)
|
||||
self
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -103,7 +103,7 @@ module Shoulda
|
|||
if reflection
|
||||
obj = reflection.klass.new
|
||||
if collection?
|
||||
[ obj ]
|
||||
[obj]
|
||||
else
|
||||
obj
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -5,7 +5,7 @@ module Shoulda
|
|||
class ValidationMessageFinder
|
||||
include Helpers
|
||||
|
||||
def initialize(instance, attribute, context=nil)
|
||||
def initialize(instance, attribute, context = nil)
|
||||
@instance = instance
|
||||
@attribute = attribute
|
||||
@context = context
|
||||
|
@ -58,8 +58,6 @@ module Shoulda
|
|||
@instance
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -421,9 +421,9 @@ module Shoulda
|
|||
def expected_prefix
|
||||
if options.include?(:prefix)
|
||||
if options[:prefix] == true
|
||||
attribute_name#.to_sym
|
||||
attribute_name # .to_sym
|
||||
else
|
||||
options[:prefix]#.to_sym
|
||||
options[:prefix] # .to_sym
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -431,9 +431,9 @@ module Shoulda
|
|||
def expected_suffix
|
||||
if options.include?(:suffix)
|
||||
if options[:suffix] == true
|
||||
attribute_name#.to_sym
|
||||
attribute_name # .to_sym
|
||||
else
|
||||
options[:suffix]#.to_sym
|
||||
options[:suffix] # .to_sym
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -795,7 +795,7 @@ module Shoulda
|
|||
column = column_for(scope)
|
||||
|
||||
if column.respond_to?(:array) && column.array
|
||||
[ dummy_scalar_value_for(column) ]
|
||||
[dummy_scalar_value_for(column)]
|
||||
else
|
||||
dummy_scalar_value_for(column)
|
||||
end
|
||||
|
@ -807,7 +807,7 @@ module Shoulda
|
|||
|
||||
def next_value_for(scope, previous_value)
|
||||
if previous_value.is_a?(Array)
|
||||
[ next_scalar_value_for(scope, previous_value[0]) ]
|
||||
[next_scalar_value_for(scope, previous_value[0])]
|
||||
else
|
||||
next_scalar_value_for(scope, previous_value)
|
||||
end
|
||||
|
|
|
@ -446,7 +446,7 @@ module Shoulda
|
|||
calls_on_delegate_object.each_with_index do |call, i|
|
||||
name = call.method_name
|
||||
args = call.args.map { |arg| arg.inspect }.join(', ')
|
||||
string << "#{i+1}) #{name}(#{args})\n"
|
||||
string << "#{i + 1}) #{name}(#{args})\n"
|
||||
end
|
||||
else
|
||||
string << ' (none)'
|
||||
|
|
|
@ -20,7 +20,7 @@ Shoulda::Matchers.configure do |config|
|
|||
with.test_framework :test_unit
|
||||
end
|
||||
end
|
||||
EOT
|
||||
EOT
|
||||
end
|
||||
|
||||
def include(*modules, **options); end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -185,7 +185,7 @@ module Shoulda
|
|||
leftover = ''
|
||||
else
|
||||
fitted_line = line[0..index].rstrip
|
||||
leftover = line[index + 1 .. -1]
|
||||
leftover = line[index + 1..-1]
|
||||
end
|
||||
|
||||
{ fitted_line: fitted_line, leftover: leftover }
|
||||
|
|
|
@ -8,7 +8,7 @@ require 'rspec/core'
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
Dir[ File.join(File.expand_path('support/acceptance/**/*.rb', __dir__)) ].sort.each do |file|
|
||||
Dir[File.join(File.expand_path('support/acceptance/**/*.rb', __dir__))].sort.each do |file|
|
||||
require file
|
||||
end
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ module Tests
|
|||
)
|
||||
@env = extract_env_from(@options)
|
||||
|
||||
@wrapper = ->(block) { block.call }
|
||||
@wrapper = -> (block) { block.call }
|
||||
@command_prefix = ''
|
||||
self.directory = Dir.pwd
|
||||
@run_quickly = false
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -27,7 +27,7 @@ module UnitTests
|
|||
layout false
|
||||
define_method(action, &block)
|
||||
end
|
||||
controller_class.view_paths = [ $test_app.temp_views_directory.to_s ]
|
||||
controller_class.view_paths = [$test_app.temp_views_directory.to_s]
|
||||
|
||||
define_routes do
|
||||
get 'examples', to: "examples##{action}"
|
||||
|
|
|
@ -60,7 +60,7 @@ describe Shoulda::Matchers::ActionController::RenderTemplateMatcher, type: :cont
|
|||
context 'a controller that renders a partial several times' do
|
||||
it 'accepts rendering that partial twice' do
|
||||
controller = build_fake_response(partial: '_customer') do
|
||||
render partial: 'customer', collection: [1,2]
|
||||
render partial: 'customer', collection: [1, 2]
|
||||
end
|
||||
|
||||
expect(controller).to render_template(partial: '_customer', count: 2)
|
||||
|
|
|
@ -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 }
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ describe Shoulda::Matchers::ActionController::RouteParams, type: :controller do
|
|||
context 'when the route params is a string' do
|
||||
it 'produces a hash of route params' do
|
||||
expect(build_route_params('examples#index').normalize).
|
||||
to eq({ controller: 'examples', action: 'index'})
|
||||
to eq({ controller: 'examples', action: 'index' })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require 'unit_spec_helper'
|
||||
|
||||
describe Shoulda::Matchers::ActiveModel::Helpers do
|
||||
|
@ -101,7 +102,7 @@ describe Shoulda::Matchers::ActiveModel::Helpers do
|
|||
expect(record).to validate_length_of(:attr).is_equal_to(40)
|
||||
end
|
||||
|
||||
def store_translations(options = {without: []})
|
||||
def store_translations(options = { without: [] })
|
||||
options[:without] = Array.wrap(options[:without] || [])
|
||||
|
||||
translations = {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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! }
|
||||
|
|
|
@ -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
|
||||
|
@ -2154,7 +2148,7 @@ Expected Person to have a has_and_belongs_to_many association called relatives (
|
|||
end
|
||||
end
|
||||
|
||||
def define_association_with_conditions(model, macro, name, conditions, other_options={})
|
||||
def define_association_with_conditions(model, macro, name, conditions, other_options = {})
|
||||
args = []
|
||||
options = {}
|
||||
if active_record_supports_relations?
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -20,7 +20,7 @@ describe Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher, type: :mo
|
|||
|
||||
it 'still accepts if the scope is unset beforehand' do
|
||||
record = build_record_validating_uniqueness(
|
||||
scopes: [ build_attribute(name: :scope, value: nil) ],
|
||||
scopes: [build_attribute(name: :scope, value: nil)],
|
||||
)
|
||||
|
||||
expect(record).to validate_uniqueness.scoped_to(:scope)
|
||||
|
@ -41,7 +41,7 @@ describe Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher, type: :mo
|
|||
|
||||
it 'still accepts if the scope is unset beforehand' do
|
||||
record = create_record_validating_uniqueness(
|
||||
scopes: [ build_attribute(name: :scope, value: nil) ],
|
||||
scopes: [build_attribute(name: :scope, value: nil)],
|
||||
)
|
||||
|
||||
expect(record).to validate_uniqueness.scoped_to(:scope)
|
||||
|
@ -55,7 +55,7 @@ describe Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher, type: :mo
|
|||
value2 = next_version_of(value1, value_type)
|
||||
value3 = next_version_of(value2, value_type)
|
||||
model = define_model_validating_uniqueness(
|
||||
scopes: [ build_attribute(name: :scope) ],
|
||||
scopes: [build_attribute(name: :scope)],
|
||||
)
|
||||
create_record_from(model, scope: value2)
|
||||
create_record_from(model, scope: value3)
|
||||
|
@ -122,7 +122,7 @@ within the scope of :scope1, but this could not be proved.
|
|||
context 'when a different scope is specified' do
|
||||
it 'rejects with an appropriate failure message' do
|
||||
record = build_record_validating_uniqueness(
|
||||
scopes: [ build_attribute(name: :other) ],
|
||||
scopes: [build_attribute(name: :other)],
|
||||
additional_attributes: [:scope],
|
||||
)
|
||||
assertion = lambda do
|
||||
|
@ -145,7 +145,7 @@ within the scope of :scope, but this could not be proved.
|
|||
context 'when no scope is specified' do
|
||||
it 'rejects with an appropriate failure message' do
|
||||
record = build_record_validating_uniqueness(
|
||||
scopes: [ build_attribute(name: :scope) ],
|
||||
scopes: [build_attribute(name: :scope)],
|
||||
)
|
||||
|
||||
assertion = lambda do
|
||||
|
@ -165,7 +165,7 @@ this could not be proved.
|
|||
context 'if the scope attribute is unset in the record given to the matcher' do
|
||||
it 'rejects with an appropriate failure message' do
|
||||
record = build_record_validating_uniqueness(
|
||||
scopes: [ build_attribute(name: :scope, value: nil) ],
|
||||
scopes: [build_attribute(name: :scope, value: nil)],
|
||||
)
|
||||
|
||||
assertion = lambda do
|
||||
|
@ -188,7 +188,7 @@ this could not be proved.
|
|||
context 'when there is more than one scope' do
|
||||
it 'rejects with an appropriate failure message (and does not raise an error)' do
|
||||
record = build_record_validating_uniqueness(
|
||||
scopes: [ build_attribute(name: :scope) ],
|
||||
scopes: [build_attribute(name: :scope)],
|
||||
)
|
||||
|
||||
assertion = lambda do
|
||||
|
@ -208,7 +208,7 @@ within the scope of :non_existent, but this could not be proved.
|
|||
context 'when there is more than one scope' do
|
||||
it 'rejects with an appropriate failure message (and does not raise an error)' do
|
||||
record = build_record_validating_uniqueness(
|
||||
scopes: [ build_attribute(name: :scope) ],
|
||||
scopes: [build_attribute(name: :scope)],
|
||||
)
|
||||
|
||||
assertion = lambda do
|
||||
|
@ -1548,7 +1548,7 @@ this could not be proved.
|
|||
|
||||
def next_version_of(value, value_type)
|
||||
if value.is_a?(Array)
|
||||
[ next_version_of(value[0], value_type) ]
|
||||
[next_version_of(value[0], value_type)]
|
||||
elsif value_type == :uuid
|
||||
SecureRandom.uuid
|
||||
elsif value.is_a?(Time)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -610,6 +610,7 @@ to account for when #country *was* nil.
|
|||
|
||||
def hello
|
||||
return unless country
|
||||
|
||||
country.hello
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ require 'spec_helper'
|
|||
|
||||
$VERBOSE = true
|
||||
|
||||
Dir[ File.join(File.expand_path('support/unit/**/*.rb', __dir__)) ].sort.each do |file|
|
||||
Dir[File.join(File.expand_path('support/unit/**/*.rb', __dir__))].sort.each do |file|
|
||||
require file
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue