diff --git a/.rubocop.yml b/.rubocop.yml index a04de4b4978a61b67806467d31438b5b350c0d28..3b4dd79e81e2dbaf9d7ef73423d66284a8209d5c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -26,6 +26,9 @@ Layout/CaseIndentation: Layout/CommentIndentation: Enabled: true +Layout/ElseAlignment: + Enabled: true + Layout/EmptyLineAfterMagicComment: Enabled: true @@ -140,6 +143,7 @@ Style/UnneededPercentQ: Lint/EndAlignment: Enabled: true EnforcedStyleAlignWith: variable + AutoCorrect: true # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. Lint/RequireParentheses: diff --git a/actioncable/lib/action_cable/connection/client_socket.rb b/actioncable/lib/action_cable/connection/client_socket.rb index 10289ab55c894907e5650c889f928e46fc0cb932..4b1964c4ae760333300c4312fc6246802452a53c 100644 --- a/actioncable/lib/action_cable/connection/client_socket.rb +++ b/actioncable/lib/action_cable/connection/client_socket.rb @@ -83,7 +83,7 @@ def transmit(message) when Numeric then @driver.text(message.to_s) when String then @driver.text(message) when Array then @driver.binary(message) - else false + else false end end diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index f0344fd927f9ee999839310defa28e959c8bf9bd..35ba44005a2fa5f94f31f3bea3edaff65102b5c1 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -274,7 +274,7 @@ def port def standard_port case protocol when "https://" then 443 - else 80 + else 80 end end diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb index 09040ccbc4df231efb0afc4ef49b33958adcb650..4c45f122fe13c8f0dbd05d145fb8f9a8e5fa1ede 100644 --- a/actionview/lib/action_view/helpers/date_helper.rb +++ b/actionview/lib/action_view/helpers/date_helper.rb @@ -116,7 +116,7 @@ def distance_of_time_in_words(from_time, to_time = 0, options = {}) when 10..19 then locale.t :less_than_x_seconds, count: 20 when 20..39 then locale.t :half_a_minute when 40..59 then locale.t :less_than_x_minutes, count: 1 - else locale.t :x_minutes, count: 1 + else locale.t :x_minutes, count: 1 end when 2...45 then locale.t :x_minutes, count: distance_in_minutes @@ -131,7 +131,7 @@ def distance_of_time_in_words(from_time, to_time = 0, options = {}) when 43200...86400 then locale.t :about_x_months, count: (distance_in_minutes.to_f / 43200.0).round # 60 days up to 365 days when 86400...525600 then locale.t :x_months, count: (distance_in_minutes.to_f / 43200.0).round - else + else from_year = from_time.year from_year += 1 if from_time.month >= 3 to_year = to_time.year diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index a8895f86063b8bd787cfb0691acc9e6664f6c0c0..c6e5122daf140ba17523c1ea0f46608b284d2118 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -38,7 +38,7 @@ def create_database(name, options = {}) " TABLESPACE = \"#{value}\"" when :connection_limit " CONNECTION LIMIT = #{value}" - else + else "" end end diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb index 11d28d12a119db8dc64459ef6f9d6cd45cea29d7..5b48254646e218c96460b266e86c0d728961cb39 100644 --- a/activesupport/lib/active_support/core_ext/hash/conversions.rb +++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb @@ -165,7 +165,7 @@ def normalize_keys(params) Hash[params.map { |k, v| [k.to_s.tr("-", "_"), normalize_keys(v)] } ] when Array params.map { |v| normalize_keys(v) } - else + else params end end @@ -178,7 +178,7 @@ def deep_to_h(value) process_array(value) when String value - else + else raise "can't typecast #{value.class.name} - #{value.inspect}" end end diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 82c10b3079bc457fa7f885f7fbae9292c3b2deb5..abc648e0c62b2fe1f3477ed90c69ec2147b8a579 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -670,7 +670,7 @@ def to_constant_name(desc) #:nodoc: when Module desc.name || raise(ArgumentError, "Anonymous modules have no name to be referenced by") - else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}" + else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}" end end diff --git a/activesupport/lib/active_support/deprecation/reporting.rb b/activesupport/lib/active_support/deprecation/reporting.rb index 242e21b78249b6a88c2aba273bf7221ddbd98f51..2c004f4c9ec5425646607addd62e6af8fdba1760 100644 --- a/activesupport/lib/active_support/deprecation/reporting.rb +++ b/activesupport/lib/active_support/deprecation/reporting.rb @@ -61,7 +61,7 @@ def deprecated_method_warning(method_name, message = nil) case message when Symbol then "#{warning} (use #{message} instead)" when String then "#{warning} (#{message})" - else warning + else warning end end diff --git a/activesupport/lib/active_support/inflector/inflections.rb b/activesupport/lib/active_support/inflector/inflections.rb index 0450a4be4c6e49cdedc87014f26c1455bc82de01..7e5dff1d6df6d941068644a52cca2819f3bc41c2 100644 --- a/activesupport/lib/active_support/inflector/inflections.rb +++ b/activesupport/lib/active_support/inflector/inflections.rb @@ -227,7 +227,7 @@ def clear(scope = :all) case scope when :all @plurals, @singulars, @uncountables, @humans = [], [], Uncountables.new, [] - else + else instance_variable_set "@#{scope}", [] end end diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index 60eeaa77cbfdb00b39f0dcf13d0a01739b6dfeb7..7e782e2a93331f12d7c6eb164620434145c9c4b3 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -350,7 +350,7 @@ def ordinal(number) when 1; "st" when 2; "nd" when 3; "rd" - else "th" + else "th" end end end diff --git a/activesupport/lib/active_support/multibyte/unicode.rb b/activesupport/lib/active_support/multibyte/unicode.rb index a64223c0e02ab796b20d7e7ca772bfa9216fc072..f923061fae402217d5c237069bb2a4f001b01f09 100644 --- a/activesupport/lib/active_support/multibyte/unicode.rb +++ b/activesupport/lib/active_support/multibyte/unicode.rb @@ -276,7 +276,7 @@ def normalize(string, form = nil) reorder_characters(decompose(:compatibility, codepoints)) when :kc compose(reorder_characters(decompose(:compatibility, codepoints))) - else + else raise ArgumentError, "#{form} is not a valid normalization variant", caller end.pack("U*".freeze) end diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index 4d81ac939effaf1c25d607136886c13227a44ee9..b75f5733b5c17b25c798e826ff5964c687fb149a 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -238,7 +238,7 @@ def [](arg) when Numeric, ActiveSupport::Duration arg *= 3600 if arg.abs <= 13 all.find { |z| z.utc_offset == arg.to_i } - else + else raise ArgumentError, "invalid argument to TimeZone[]: #{arg.inspect}" end end diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb index 27284599683b38991115162e872c8cf0399aca5b..f7fd30a5fb6978c6658a2a60d0bc6fb381417b05 100644 --- a/railties/lib/rails/generators/generated_attribute.rb +++ b/railties/lib/rails/generators/generated_attribute.rb @@ -75,7 +75,7 @@ def field_type when :date then :date_select when :text then :text_area when :boolean then :check_box - else + else :text_field end end @@ -91,7 +91,7 @@ def default when :text then "MyText" when :boolean then false when :references, :belongs_to then nil - else + else "" end end