Skip to content

Commit be3f8c9

Browse files
style(Style/OptionalBooleanParameter): manual
1 parent 61ab07e commit be3f8c9

File tree

13 files changed

+29
-42
lines changed

13 files changed

+29
-42
lines changed

.rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ Style/NumericLiterals:
238238
Style/NumericPredicate:
239239
Enabled: false
240240

241+
Style/OptionalBooleanParameter:
242+
AllowedMethods:
243+
- respond_to?
244+
- respond_to_missing?
245+
- set_parent=
246+
241247
Style/RaiseArgs:
242248
EnforcedStyle: compact
243249

.rubocop_todo.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -826,25 +826,6 @@ Style/OpenStructUse:
826826
- 'spec/rails/controller_extension/controller_runtime_spec.rb'
827827
- 'spec/support/rails_mock.rb'
828828

829-
# Offense count: 17
830-
# Configuration parameters: AllowedMethods.
831-
# AllowedMethods: respond_to_missing?
832-
Style/OptionalBooleanParameter:
833-
Exclude:
834-
- 'lib/mongoid/association/embedded/cyclic.rb'
835-
- 'lib/mongoid/association/many.rb'
836-
- 'lib/mongoid/association/one.rb'
837-
- 'lib/mongoid/association/referenced/has_many/enumerable.rb'
838-
- 'lib/mongoid/atomic.rb'
839-
- 'lib/mongoid/attributes/dynamic.rb'
840-
- 'lib/mongoid/criteria.rb'
841-
- 'lib/mongoid/criteria/queryable/extensions/string.rb'
842-
- 'lib/mongoid/criteria/queryable/extensions/symbol.rb'
843-
- 'lib/mongoid/criteria/queryable/key.rb'
844-
- 'lib/mongoid/criteria/queryable/options.rb'
845-
- 'spec/support/models/address.rb'
846-
- 'spec/support/models/name.rb'
847-
848829
# Offense count: 242
849830
# This cop supports safe autocorrection (--autocorrect).
850831
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.

lib/mongoid/association/embedded/cyclic.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def recursively_embeds_many(options = {})
6565
# or its children.
6666
def recursively_embeds_one(options = {})
6767
embeds_one(
68-
cyclic_child_name(false),
68+
cyclic_child_name(many: false),
6969
options.merge(class_name: name, cyclic: true)
7070
)
7171
embedded_in cyclic_parent_name, class_name: name, cyclic: true
@@ -92,7 +92,7 @@ def cyclic_parent_name
9292
#
9393
# @return [ String ] "child_" plus the class name underscored in
9494
# singular or plural form.
95-
def cyclic_child_name(many = true)
95+
def cyclic_child_name(many: true)
9696
:"child_#{name.demodulize.underscore.send(many ? :pluralize : :singularize)}"
9797
end
9898
end

lib/mongoid/atomic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def atomic_array_add_to_sets
116116
# person.atomic_updates(children)
117117
#
118118
# @return [ Hash ] The updates and their modifiers.
119-
def atomic_updates(_use_indexes = false)
119+
def atomic_updates(_use_indexes: false)
120120
process_flagged_destroys
121121
mods = Modifiers.new
122122
generate_atomic_updates(mods, self)

lib/mongoid/criteria/queryable/expandable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module Expandable
3737
#
3838
# @return [ Array<String, Object> ] The expanded field and value.
3939
def expand_one_condition(field, value)
40-
kv = field.__expr_part__(value.__expand_complex__, negating?)
40+
kv = field.__expr_part__(value.__expand_complex__, negating: negating?)
4141
[kv.keys.first.to_s, kv.values.first]
4242
end
4343

lib/mongoid/criteria/queryable/extensions/string.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def __sort_option__
6363
# @param [ true | false ] negating If the selection should be negated.
6464
#
6565
# @return [ Hash ] The selection.
66-
def __expr_part__(value, negating = false)
67-
::String.__expr_part__(self, value, negating)
66+
def __expr_part__(value, negating: false)
67+
::String.__expr_part__(self, value, negating: negating)
6868
end
6969

7070
module ClassMethods
@@ -79,7 +79,7 @@ module ClassMethods
7979
# @param [ true | false ] negating If the selection should be negated.
8080
#
8181
# @return [ Hash ] The selection.
82-
def __expr_part__(key, value, negating = false)
82+
def __expr_part__(key, value, negating: false)
8383
if negating
8484
{ key => { "$#{value.regexp? ? 'not' : 'ne'}" => value } }
8585
else

lib/mongoid/criteria/queryable/extensions/symbol.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ module Symbol
1717
# @param [ true | false ] negating If the selection should be negated.
1818
#
1919
# @return [ Hash ] The selection.
20-
def __expr_part__(value, negating = false)
21-
::String.__expr_part__(self, value, negating)
20+
def __expr_part__(value, negating: false)
21+
::String.__expr_part__(self, value, negating: negating)
2222
end
2323

2424
module ClassMethods

lib/mongoid/criteria/queryable/key.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ def initialize(name, strategy, operator, expanded = nil, &block)
131131
# @param [ true | false ] negating If the selection should be negated.
132132
#
133133
# @return [ Hash ] The raw MongoDB selector.
134-
def __expr_part__(object, negating = false)
135-
{ name.to_s => transform_value(object, negating) }
134+
def __expr_part__(object, negating: false)
135+
{ name.to_s => transform_value(object, negating: negating) }
136136
end
137137

138138
# Gets the raw selector condition that would be passed to Mongo.
@@ -144,7 +144,7 @@ def __expr_part__(object, negating = false)
144144
# @param [ true | false ] negating If the selection should be negated.
145145
#
146146
# @return [ Hash ] The raw MongoDB selector.
147-
def transform_value(value, negating = false)
147+
def transform_value(value, negating: false)
148148
expr = block ? block[value] : value
149149
expr = { expanded => expr } if expanded
150150
expr = { operator => expr }

lib/mongoid/criteria/queryable/mergeable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def _mongoid_expand_keys(expr)
261261

262262
result = BSON::Document.new
263263
expr.each do |field, value|
264-
field.__expr_part__(value.__expand_complex__, negating?).each do |k, v|
264+
field.__expr_part__(value.__expand_complex__, negating: negating?).each do |k, v|
265265
if (existing = result[k])
266266
if existing.is_a?(Hash)
267267
# Existing value is an operator.

lib/mongoid/criteria/queryable/optional.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def only(*args)
119119
options.store(
120120
:fields,
121121
args.inject(options[:fields] || {}) { |sub, field| sub.tap { sub[field] = 1 } },
122-
false
122+
localize: false
123123
)
124124
end
125125
end
@@ -241,7 +241,7 @@ def without(*args)
241241
options.store(
242242
:fields,
243243
args.inject(options[:fields] || {}) { |sub, field| sub.tap { sub[field] = 0 } },
244-
false
244+
localize: false
245245
)
246246
end
247247
end

0 commit comments

Comments
 (0)