diff options
author | Xavier Noria <fxn@hashref.com> | 2016-09-02 00:43:33 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-09-02 00:43:33 +0200 |
commit | 810dff7c9fa9b2a38eb1560ce0378d760529ee6b (patch) | |
tree | d5ea948c1f0043c7bc4c5b10241279e448a6d696 | |
parent | 11eaf1c1dd48e86a38b8dc83a2b35d99f746b1f8 (diff) | |
download | rails-810dff7c9fa9b2a38eb1560ce0378d760529ee6b.tar.gz rails-810dff7c9fa9b2a38eb1560ce0378d760529ee6b.tar.bz2 rails-810dff7c9fa9b2a38eb1560ce0378d760529ee6b.zip |
RuboCop is 100% green :tada:
-rw-r--r-- | actionmailer/lib/action_mailer/preview.rb | 9 | ||||
-rw-r--r-- | actionpack/lib/action_controller/metal/implicit_render.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 21 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/date_helper.rb | 13 | ||||
-rw-r--r-- | activemodel/lib/active_model/type/helpers/numeric.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/type/immutable_string.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 25 | ||||
-rw-r--r-- | activesupport/test/core_ext/duration_test.rb | 6 | ||||
-rw-r--r-- | guides/rails_guides/markdown/renderer.rb | 17 |
9 files changed, 53 insertions, 44 deletions
diff --git a/actionmailer/lib/action_mailer/preview.rb b/actionmailer/lib/action_mailer/preview.rb index d88ca7ace4..93a11453bf 100644 --- a/actionmailer/lib/action_mailer/preview.rb +++ b/actionmailer/lib/action_mailer/preview.rb @@ -34,11 +34,12 @@ module ActionMailer # Either a class or a string can be passed in as the Interceptor. If a # string is passed in it will be <tt>constantize</tt>d. def register_preview_interceptor(interceptor) - preview_interceptor = case interceptor - when String, Symbol - interceptor.to_s.camelize.constantize + preview_interceptor = \ + case interceptor + when String, Symbol + interceptor.to_s.camelize.constantize else - interceptor + interceptor end unless preview_interceptors.include?(preview_interceptor) diff --git a/actionpack/lib/action_controller/metal/implicit_render.rb b/actionpack/lib/action_controller/metal/implicit_render.rb index e7e32e5108..8615c16c6f 100644 --- a/actionpack/lib/action_controller/metal/implicit_render.rb +++ b/actionpack/lib/action_controller/metal/implicit_render.rb @@ -62,7 +62,7 @@ module ActionController def method_for_action(action_name) super || if template_exists?(action_name.to_s, _prefixes) "default_render" - end + end end private diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 864ffe3a79..8d0bf680c8 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -282,16 +282,17 @@ module ActionDispatch mod.module_eval do define_method(name) do |*args| last = args.last - options = case last - when Hash - args.pop - when ActionController::Parameters - if last.permitted? - args.pop.to_h - else - raise ArgumentError, ActionDispatch::Routing::INSECURE_URL_PARAMETERS_MESSAGE - end - end + options = \ + case last + when Hash + args.pop + when ActionController::Parameters + if last.permitted? + args.pop.to_h + else + raise ArgumentError, ActionDispatch::Routing::INSECURE_URL_PARAMETERS_MESSAGE + end + end helper.call self, args, options end end diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb index 74c6f0ab1c..c277738920 100644 --- a/actionview/lib/action_view/helpers/date_helper.rb +++ b/actionview/lib/action_view/helpers/date_helper.rb @@ -1011,12 +1011,13 @@ module ActionView # css_class_attribute(:year, 'date optional', { year: 'my-year' }) # => "date optional my-year" def css_class_attribute(type, html_options_class, options) # :nodoc: - css_class = case options - when Hash - options[type.to_sym] - else - type - end + css_class = \ + case options + when Hash + options[type.to_sym] + else + type + end [html_options_class, css_class].compact.join(" ") end diff --git a/activemodel/lib/active_model/type/helpers/numeric.rb b/activemodel/lib/active_model/type/helpers/numeric.rb index ec1d1daf1a..eee745cbc4 100644 --- a/activemodel/lib/active_model/type/helpers/numeric.rb +++ b/activemodel/lib/active_model/type/helpers/numeric.rb @@ -8,7 +8,7 @@ module ActiveModel when false then 0 when ::String then value.presence else value - end + end super(value) end diff --git a/activemodel/lib/active_model/type/immutable_string.rb b/activemodel/lib/active_model/type/immutable_string.rb index 41e4a2a1ac..75654e1334 100644 --- a/activemodel/lib/active_model/type/immutable_string.rb +++ b/activemodel/lib/active_model/type/immutable_string.rb @@ -21,7 +21,7 @@ module ActiveModel when true then "t" when false then "f" else value.to_s - end + end result.freeze end end diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 8c5e4d042e..9b692f55d2 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -14,18 +14,19 @@ module ActiveRecord end def self.create(macro, name, scope, options, ar) - klass = case macro - when :composed_of - AggregateReflection - when :has_many - HasManyReflection - when :has_one - HasOneReflection - when :belongs_to - BelongsToReflection - else - raise "Unsupported Macro: #{macro}" - end + klass = \ + case macro + when :composed_of + AggregateReflection + when :has_many + HasManyReflection + when :has_one + HasOneReflection + when :belongs_to + BelongsToReflection + else + raise "Unsupported Macro: #{macro}" + end reflection = klass.new(name, scope, options, ar) options[:through] ? ThroughReflection.new(reflection) : reflection diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index 1a2dcba760..a881768470 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -208,7 +208,11 @@ class DurationTest < ActiveSupport::TestCase end def test_case_when - cased = case 1.day when 1.day then "ok" end + cased = \ + case 1.day + when 1.day + "ok" + end assert_equal cased, "ok" end diff --git a/guides/rails_guides/markdown/renderer.rb b/guides/rails_guides/markdown/renderer.rb index 4ff76c519b..f8e32fc498 100644 --- a/guides/rails_guides/markdown/renderer.rb +++ b/guides/rails_guides/markdown/renderer.rb @@ -67,14 +67,15 @@ HTML # as a list item, but as a paragraph starting with a plain # asterisk. body.gsub(/^(TIP|IMPORTANT|CAUTION|WARNING|NOTE|INFO|TODO)[.:](.*?)(\n(?=\n)|\Z)/m) do - css_class = case $1 - when "CAUTION", "IMPORTANT" - "warning" - when "TIP" - "info" - else - $1.downcase - end + css_class = \ + case $1 + when "CAUTION", "IMPORTANT" + "warning" + when "TIP" + "info" + else + $1.downcase + end %(<div class="#{css_class}"><p>#{$2.strip}</p></div>) end end |