diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-06-13 18:36:23 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-13 18:36:23 +0900 |
commit | 98a57aa5f610bc66af31af409c72173cdeeb3c9e (patch) | |
tree | 77365fa7eab9725d5ca185ae3df03508898596f5 /activemodel | |
parent | c5ecc338e863e771adcbcd87d5c23ae5e7ca7894 (diff) | |
parent | c81af6ae723ccfcd601032167d7b7f57c5449c33 (diff) | |
download | rails-98a57aa5f610bc66af31af409c72173cdeeb3c9e.tar.gz rails-98a57aa5f610bc66af31af409c72173cdeeb3c9e.tar.bz2 rails-98a57aa5f610bc66af31af409c72173cdeeb3c9e.zip |
Merge pull request #36472 from kamipo/empty_line_only_before_access_modifier
Enable `Layout/EmptyLinesAroundAccessModifier` cop
Diffstat (limited to 'activemodel')
32 files changed, 0 insertions, 35 deletions
diff --git a/activemodel/lib/active_model/attribute_assignment.rb b/activemodel/lib/active_model/attribute_assignment.rb index f0e3458f51..9bdec0dfda 100644 --- a/activemodel/lib/active_model/attribute_assignment.rb +++ b/activemodel/lib/active_model/attribute_assignment.rb @@ -38,7 +38,6 @@ module ActiveModel alias attributes= assign_attributes private - def _assign_attributes(attributes) attributes.each do |k, v| _assign_attribute(k, v) diff --git a/activemodel/lib/active_model/attribute_set.rb b/activemodel/lib/active_model/attribute_set.rb index 4679b33852..2f5437ceda 100644 --- a/activemodel/lib/active_model/attribute_set.rb +++ b/activemodel/lib/active_model/attribute_set.rb @@ -94,11 +94,9 @@ module ActiveModel end protected - attr_reader :attributes private - def initialized_attributes attributes.select { |_, attr| attr.initialized? } end diff --git a/activemodel/lib/active_model/attributes.rb b/activemodel/lib/active_model/attributes.rb index d176ea88d0..c586f52b78 100644 --- a/activemodel/lib/active_model/attributes.rb +++ b/activemodel/lib/active_model/attributes.rb @@ -42,7 +42,6 @@ module ActiveModel end private - def define_method_attribute=(name) ActiveModel::AttributeMethods::AttrNames.define_attribute_accessor_method( generated_attribute_methods, name, writer: true, @@ -114,7 +113,6 @@ module ActiveModel end private - def write_attribute(attr_name, value) name = attr_name.to_s name = self.class.attribute_aliases[name] || name diff --git a/activemodel/lib/active_model/callbacks.rb b/activemodel/lib/active_model/callbacks.rb index ea2ed7dff7..7a544395cb 100644 --- a/activemodel/lib/active_model/callbacks.rb +++ b/activemodel/lib/active_model/callbacks.rb @@ -126,7 +126,6 @@ module ActiveModel end private - def _define_before_model_callback(klass, callback) klass.define_singleton_method("before_#{callback}") do |*args, **options, &block| options.assert_valid_keys(:if, :unless, :prepend) diff --git a/activemodel/lib/active_model/error.rb b/activemodel/lib/active_model/error.rb index 5a1298e27f..f7267fc7bf 100644 --- a/activemodel/lib/active_model/error.rb +++ b/activemodel/lib/active_model/error.rb @@ -73,7 +73,6 @@ module ActiveModel end protected - def attributes_for_hash [@base, @attribute, @raw_type, @options] end diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index d7bcfacce3..f8ea21cf47 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -594,7 +594,6 @@ module ActiveModel end private - def normalize_arguments(attribute, type, **options) # Evaluate proc first if type.respond_to?(:call) @@ -640,7 +639,6 @@ module ActiveModel end private - def prepare_content content = @errors.to_hash content.each do |attribute, value| diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index bf23fa3c05..6a02d5dbf7 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -207,7 +207,6 @@ module ActiveModel end private - def _singularize(string) ActiveSupport::Inflector.underscore(string).tr("/", "_") end diff --git a/activemodel/lib/active_model/serialization.rb b/activemodel/lib/active_model/serialization.rb index c4b7b32291..168dfa0dd2 100644 --- a/activemodel/lib/active_model/serialization.rb +++ b/activemodel/lib/active_model/serialization.rb @@ -150,7 +150,6 @@ module ActiveModel end private - # Hook method defining how an attribute value should be retrieved for # serialization. By default this is assumed to be an instance named after # the attribute. Override this method in subclasses should you need to diff --git a/activemodel/lib/active_model/type/big_integer.rb b/activemodel/lib/active_model/type/big_integer.rb index 89e43bcc5f..b2c3ee50aa 100644 --- a/activemodel/lib/active_model/type/big_integer.rb +++ b/activemodel/lib/active_model/type/big_integer.rb @@ -6,7 +6,6 @@ module ActiveModel module Type class BigInteger < Integer # :nodoc: private - def max_value ::Float::INFINITY end diff --git a/activemodel/lib/active_model/type/boolean.rb b/activemodel/lib/active_model/type/boolean.rb index e64d2c793c..1214e9319b 100644 --- a/activemodel/lib/active_model/type/boolean.rb +++ b/activemodel/lib/active_model/type/boolean.rb @@ -34,7 +34,6 @@ module ActiveModel end private - def cast_value(value) if value == "" nil diff --git a/activemodel/lib/active_model/type/date.rb b/activemodel/lib/active_model/type/date.rb index c5fe926039..0e96d2c8a4 100644 --- a/activemodel/lib/active_model/type/date.rb +++ b/activemodel/lib/active_model/type/date.rb @@ -15,7 +15,6 @@ module ActiveModel end private - def cast_value(value) if value.is_a?(::String) return if value.empty? diff --git a/activemodel/lib/active_model/type/date_time.rb b/activemodel/lib/active_model/type/date_time.rb index 133410e821..ba705be9b2 100644 --- a/activemodel/lib/active_model/type/date_time.rb +++ b/activemodel/lib/active_model/type/date_time.rb @@ -14,7 +14,6 @@ module ActiveModel end private - def cast_value(value) return apply_seconds_precision(value) unless value.is_a?(::String) return if value.empty? diff --git a/activemodel/lib/active_model/type/decimal.rb b/activemodel/lib/active_model/type/decimal.rb index e8ee18c00e..6aa51ff2ac 100644 --- a/activemodel/lib/active_model/type/decimal.rb +++ b/activemodel/lib/active_model/type/decimal.rb @@ -17,7 +17,6 @@ module ActiveModel end private - def cast_value(value) casted_value = \ case value diff --git a/activemodel/lib/active_model/type/float.rb b/activemodel/lib/active_model/type/float.rb index ea1987df7c..36c7a5103c 100644 --- a/activemodel/lib/active_model/type/float.rb +++ b/activemodel/lib/active_model/type/float.rb @@ -19,7 +19,6 @@ module ActiveModel end private - def cast_value(value) case value when ::Float then value diff --git a/activemodel/lib/active_model/type/helpers/numeric.rb b/activemodel/lib/active_model/type/helpers/numeric.rb index 1d8171e25b..074316b559 100644 --- a/activemodel/lib/active_model/type/helpers/numeric.rb +++ b/activemodel/lib/active_model/type/helpers/numeric.rb @@ -24,7 +24,6 @@ module ActiveModel end private - def number_to_non_number?(old_value, new_value_before_type_cast) old_value != nil && non_numeric_string?(new_value_before_type_cast.to_s) end diff --git a/activemodel/lib/active_model/type/helpers/time_value.rb b/activemodel/lib/active_model/type/helpers/time_value.rb index dab196d653..508fe77531 100644 --- a/activemodel/lib/active_model/type/helpers/time_value.rb +++ b/activemodel/lib/active_model/type/helpers/time_value.rb @@ -44,7 +44,6 @@ module ActiveModel end private - def new_time(year, mon, mday, hour, min, sec, microsec, offset = nil) # Treat 0000-00-00 00:00:00 as nil. return if year.nil? || (year == 0 && mon == 0 && mday == 0) diff --git a/activemodel/lib/active_model/type/immutable_string.rb b/activemodel/lib/active_model/type/immutable_string.rb index 826bd7038f..18e12c54d1 100644 --- a/activemodel/lib/active_model/type/immutable_string.rb +++ b/activemodel/lib/active_model/type/immutable_string.rb @@ -17,7 +17,6 @@ module ActiveModel end private - def cast_value(value) result = \ case value diff --git a/activemodel/lib/active_model/type/string.rb b/activemodel/lib/active_model/type/string.rb index a9c9bfadb6..0d9f4a63b4 100644 --- a/activemodel/lib/active_model/type/string.rb +++ b/activemodel/lib/active_model/type/string.rb @@ -12,7 +12,6 @@ module ActiveModel end private - def cast_value(value) case value when ::String then ::String.new(value) diff --git a/activemodel/lib/active_model/type/time.rb b/activemodel/lib/active_model/type/time.rb index 61847a4ce7..f230bd4257 100644 --- a/activemodel/lib/active_model/type/time.rb +++ b/activemodel/lib/active_model/type/time.rb @@ -29,7 +29,6 @@ module ActiveModel end private - def cast_value(value) return apply_seconds_precision(value) unless value.is_a?(::String) return if value.empty? diff --git a/activemodel/lib/active_model/type/value.rb b/activemodel/lib/active_model/type/value.rb index b6914dd63c..994d135b7b 100644 --- a/activemodel/lib/active_model/type/value.rb +++ b/activemodel/lib/active_model/type/value.rb @@ -114,7 +114,6 @@ module ActiveModel end private - # Convenience method for types which do not need separate type casting # behavior for user and database inputs. Called by Value#cast for # values except +nil+. diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index f18f9a601a..4a6b464131 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -402,7 +402,6 @@ module ActiveModel alias :read_attribute_for_validation :send private - def run_validations! _run_validate_callbacks errors.empty? diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb index 6fd54270f2..1b96575a10 100644 --- a/activemodel/lib/active_model/validations/acceptance.rb +++ b/activemodel/lib/active_model/validations/acceptance.rb @@ -15,7 +15,6 @@ module ActiveModel end private - def setup!(klass) klass.include(LazilyDefineAttributes.new(AttributeDefinition.new(attributes))) end diff --git a/activemodel/lib/active_model/validations/callbacks.rb b/activemodel/lib/active_model/validations/callbacks.rb index 887d31ae2a..7178ba99e9 100644 --- a/activemodel/lib/active_model/validations/callbacks.rb +++ b/activemodel/lib/active_model/validations/callbacks.rb @@ -112,7 +112,6 @@ module ActiveModel end private - # Overwrite run validations to include callbacks. def run_validations! _run_validation_callbacks { super } diff --git a/activemodel/lib/active_model/validations/clusivity.rb b/activemodel/lib/active_model/validations/clusivity.rb index bafb8e2106..fb9f48301c 100644 --- a/activemodel/lib/active_model/validations/clusivity.rb +++ b/activemodel/lib/active_model/validations/clusivity.rb @@ -15,7 +15,6 @@ module ActiveModel end private - def include?(record, value) members = if delimiter.respond_to?(:call) delimiter.call(record) diff --git a/activemodel/lib/active_model/validations/format.rb b/activemodel/lib/active_model/validations/format.rb index 7c3f091473..bea57415b0 100644 --- a/activemodel/lib/active_model/validations/format.rb +++ b/activemodel/lib/active_model/validations/format.rb @@ -23,7 +23,6 @@ module ActiveModel end private - def option_call(record, name) option = options[name] option.respond_to?(:call) ? option.call(record) : option diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index 51e224d5cd..e7be668e9d 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -79,7 +79,6 @@ module ActiveModel end private - def is_number?(raw_value) !parse_as_number(raw_value).nil? rescue ArgumentError, TypeError diff --git a/activemodel/lib/active_model/validations/validates.rb b/activemodel/lib/active_model/validations/validates.rb index 21c4ce0dfe..97612d474d 100644 --- a/activemodel/lib/active_model/validations/validates.rb +++ b/activemodel/lib/active_model/validations/validates.rb @@ -150,7 +150,6 @@ module ActiveModel end private - # When creating custom validators, it might be useful to be able to specify # additional default keys. This can be done by overwriting this method. def _validates_default_keys diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index 94d53b8dd1..3ba6acea15 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -175,7 +175,6 @@ module ActiveModel end private - def validate_each(record, attribute, value) @block.call(record, attribute, value) end diff --git a/activemodel/test/cases/attribute_methods_test.rb b/activemodel/test/cases/attribute_methods_test.rb index 4e228032c3..e3b3b15f25 100644 --- a/activemodel/test/cases/attribute_methods_test.rb +++ b/activemodel/test/cases/attribute_methods_test.rb @@ -40,7 +40,6 @@ private end protected - def protected_method "O_o O_o" end diff --git a/activemodel/test/cases/type/date_time_test.rb b/activemodel/test/cases/type/date_time_test.rb index 74b47d1b4d..4a63eee0cf 100644 --- a/activemodel/test/cases/type/date_time_test.rb +++ b/activemodel/test/cases/type/date_time_test.rb @@ -37,7 +37,6 @@ module ActiveModel end private - def with_timezone_config(default:) old_zone_default = ::Time.zone_default ::Time.zone_default = ::Time.find_zone(default) diff --git a/activemodel/test/cases/validations/acceptance_validation_test.rb b/activemodel/test/cases/validations/acceptance_validation_test.rb index 72baf6e7a7..6bd3d292f8 100644 --- a/activemodel/test/cases/validations/acceptance_validation_test.rb +++ b/activemodel/test/cases/validations/acceptance_validation_test.rb @@ -92,7 +92,6 @@ class AcceptanceValidationTest < ActiveModel::TestCase end private - # Acceptance validator includes anonymous module into class, which cannot # be cleared, so to avoid multiple inclusions we use a named subclass which # we can remove in teardown. diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb index 16c44762cb..191af033df 100644 --- a/activemodel/test/cases/validations/numericality_validation_test.rb +++ b/activemodel/test/cases/validations/numericality_validation_test.rb @@ -310,7 +310,6 @@ class NumericalityValidationTest < ActiveModel::TestCase end private - def invalid!(values, error = nil) with_each_topic_approved_value(values) do |topic, value| assert topic.invalid?, "#{value.inspect} not rejected as a number" |