From c81af6ae723ccfcd601032167d7b7f57c5449c33 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Wed, 12 Jun 2019 21:30:49 +0900 Subject: Enable `Layout/EmptyLinesAroundAccessModifier` cop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost. --- actionview/lib/action_view/cache_expiry.rb | 1 - actionview/lib/action_view/flows.rb | 1 - actionview/lib/action_view/helpers/active_model_helper.rb | 1 - actionview/lib/action_view/helpers/cache_helper.rb | 1 - actionview/lib/action_view/helpers/date_helper.rb | 1 - actionview/lib/action_view/helpers/number_helper.rb | 1 - actionview/lib/action_view/helpers/tags/base.rb | 1 - actionview/lib/action_view/helpers/tags/check_box.rb | 1 - actionview/lib/action_view/helpers/tags/collection_check_boxes.rb | 1 - actionview/lib/action_view/helpers/tags/collection_helpers.rb | 1 - actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb | 1 - actionview/lib/action_view/helpers/tags/color_field.rb | 1 - actionview/lib/action_view/helpers/tags/date_field.rb | 1 - actionview/lib/action_view/helpers/tags/date_select.rb | 1 - actionview/lib/action_view/helpers/tags/datetime_field.rb | 1 - actionview/lib/action_view/helpers/tags/datetime_local_field.rb | 1 - actionview/lib/action_view/helpers/tags/label.rb | 1 - actionview/lib/action_view/helpers/tags/month_field.rb | 1 - actionview/lib/action_view/helpers/tags/radio_button.rb | 1 - actionview/lib/action_view/helpers/tags/select.rb | 1 - actionview/lib/action_view/helpers/tags/text_field.rb | 1 - actionview/lib/action_view/helpers/tags/time_field.rb | 1 - actionview/lib/action_view/helpers/tags/week_field.rb | 1 - actionview/lib/action_view/helpers/text_helper.rb | 1 - actionview/lib/action_view/layouts.rb | 3 --- actionview/lib/action_view/log_subscriber.rb | 1 - actionview/lib/action_view/lookup_context.rb | 2 -- actionview/lib/action_view/path_set.rb | 1 - actionview/lib/action_view/record_identifier.rb | 1 - actionview/lib/action_view/renderer/abstract_renderer.rb | 1 - actionview/lib/action_view/renderer/partial_renderer.rb | 1 - actionview/lib/action_view/renderer/streaming_template_renderer.rb | 2 -- actionview/lib/action_view/renderer/template_renderer.rb | 1 - actionview/lib/action_view/rendering.rb | 1 - actionview/lib/action_view/template.rb | 1 - actionview/lib/action_view/template/error.rb | 1 - actionview/lib/action_view/template/handlers/erb.rb | 1 - actionview/lib/action_view/template/resolver.rb | 4 ---- actionview/lib/action_view/test_case.rb | 2 -- actionview/lib/action_view/testing/resolvers.rb | 1 - actionview/lib/action_view/unbound_template.rb | 1 - actionview/lib/action_view/view_paths.rb | 1 - 42 files changed, 50 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/cache_expiry.rb b/actionview/lib/action_view/cache_expiry.rb index 7cdc2e9982..27690561b7 100644 --- a/actionview/lib/action_view/cache_expiry.rb +++ b/actionview/lib/action_view/cache_expiry.rb @@ -41,7 +41,6 @@ module ActionView end private - def dirs_to_watch fs_paths = all_view_paths.grep(FileSystemResolver) fs_paths.map(&:path).sort.uniq diff --git a/actionview/lib/action_view/flows.rb b/actionview/lib/action_view/flows.rb index ff44fa6619..1609777182 100644 --- a/actionview/lib/action_view/flows.rb +++ b/actionview/lib/action_view/flows.rb @@ -68,7 +68,6 @@ module ActionView end private - def inside_fiber? Fiber.current.object_id != @root end diff --git a/actionview/lib/action_view/helpers/active_model_helper.rb b/actionview/lib/action_view/helpers/active_model_helper.rb index e41a95d2ce..e8f1d4fee5 100644 --- a/actionview/lib/action_view/helpers/active_model_helper.rb +++ b/actionview/lib/action_view/helpers/active_model_helper.rb @@ -38,7 +38,6 @@ module ActionView end private - def object_has_errors? object.respond_to?(:errors) && object.errors.respond_to?(:[]) && error_message.present? end diff --git a/actionview/lib/action_view/helpers/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb index 020aebeea3..5a05f8706a 100644 --- a/actionview/lib/action_view/helpers/cache_helper.rb +++ b/actionview/lib/action_view/helpers/cache_helper.rb @@ -227,7 +227,6 @@ module ActionView end private - def fragment_name_with_digest(name, virtual_path, digest_path) virtual_path ||= @virtual_path diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb index 9d5e5eaba3..f1d9fdc678 100644 --- a/actionview/lib/action_view/helpers/date_helper.rb +++ b/actionview/lib/action_view/helpers/date_helper.rb @@ -688,7 +688,6 @@ module ActionView end private - def normalize_distance_of_time_argument_to_time(value) if value.is_a?(Numeric) Time.at(value) diff --git a/actionview/lib/action_view/helpers/number_helper.rb b/actionview/lib/action_view/helpers/number_helper.rb index 03ec7df9c1..827e0bd02c 100644 --- a/actionview/lib/action_view/helpers/number_helper.rb +++ b/actionview/lib/action_view/helpers/number_helper.rb @@ -403,7 +403,6 @@ module ActionView end private - def delegate_number_helper_method(method, number, options) return unless number options = escape_unsafe_options(options.symbolize_keys) diff --git a/actionview/lib/action_view/helpers/tags/base.rb b/actionview/lib/action_view/helpers/tags/base.rb index 39c01f3334..4ce1f507f3 100644 --- a/actionview/lib/action_view/helpers/tags/base.rb +++ b/actionview/lib/action_view/helpers/tags/base.rb @@ -34,7 +34,6 @@ module ActionView end private - def value if @allow_method_names_outside_object object.public_send @method_name if object && object.respond_to?(@method_name) diff --git a/actionview/lib/action_view/helpers/tags/check_box.rb b/actionview/lib/action_view/helpers/tags/check_box.rb index 4327e07cae..dbf020e514 100644 --- a/actionview/lib/action_view/helpers/tags/check_box.rb +++ b/actionview/lib/action_view/helpers/tags/check_box.rb @@ -39,7 +39,6 @@ module ActionView end private - def checked?(value) case value when TrueClass, FalseClass diff --git a/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb index 455442178e..d058eb2c72 100644 --- a/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb +++ b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb @@ -22,7 +22,6 @@ module ActionView end private - def render_component(builder) builder.check_box + builder.label end diff --git a/actionview/lib/action_view/helpers/tags/collection_helpers.rb b/actionview/lib/action_view/helpers/tags/collection_helpers.rb index e1ad11bff8..62060547de 100644 --- a/actionview/lib/action_view/helpers/tags/collection_helpers.rb +++ b/actionview/lib/action_view/helpers/tags/collection_helpers.rb @@ -37,7 +37,6 @@ module ActionView end private - def instantiate_builder(builder_class, item, value, text, html_options) builder_class.new(@template_object, @object_name, @method_name, item, sanitize_attribute_name(value), text, value, html_options) diff --git a/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb b/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb index 16d37134e5..0c3b899f53 100644 --- a/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb +++ b/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb @@ -21,7 +21,6 @@ module ActionView end private - def render_component(builder) builder.radio_button + builder.label end diff --git a/actionview/lib/action_view/helpers/tags/color_field.rb b/actionview/lib/action_view/helpers/tags/color_field.rb index 39ab1285c3..69b190809f 100644 --- a/actionview/lib/action_view/helpers/tags/color_field.rb +++ b/actionview/lib/action_view/helpers/tags/color_field.rb @@ -12,7 +12,6 @@ module ActionView end private - def validate_color_string(string) regex = /#[0-9a-fA-F]{6}/ if regex.match?(string) diff --git a/actionview/lib/action_view/helpers/tags/date_field.rb b/actionview/lib/action_view/helpers/tags/date_field.rb index b17a907651..ceaabfa99c 100644 --- a/actionview/lib/action_view/helpers/tags/date_field.rb +++ b/actionview/lib/action_view/helpers/tags/date_field.rb @@ -5,7 +5,6 @@ module ActionView module Tags # :nodoc: class DateField < DatetimeField # :nodoc: private - def format_date(value) value.try(:strftime, "%Y-%m-%d") end diff --git a/actionview/lib/action_view/helpers/tags/date_select.rb b/actionview/lib/action_view/helpers/tags/date_select.rb index fe4e3914d7..f222bf2075 100644 --- a/actionview/lib/action_view/helpers/tags/date_select.rb +++ b/actionview/lib/action_view/helpers/tags/date_select.rb @@ -23,7 +23,6 @@ module ActionView end private - def select_type self.class.select_type end diff --git a/actionview/lib/action_view/helpers/tags/datetime_field.rb b/actionview/lib/action_view/helpers/tags/datetime_field.rb index 5d9b639b1b..e2dbf408c8 100644 --- a/actionview/lib/action_view/helpers/tags/datetime_field.rb +++ b/actionview/lib/action_view/helpers/tags/datetime_field.rb @@ -14,7 +14,6 @@ module ActionView end private - def format_date(value) raise NotImplementedError end diff --git a/actionview/lib/action_view/helpers/tags/datetime_local_field.rb b/actionview/lib/action_view/helpers/tags/datetime_local_field.rb index d8f8fd00d1..8908bf9948 100644 --- a/actionview/lib/action_view/helpers/tags/datetime_local_field.rb +++ b/actionview/lib/action_view/helpers/tags/datetime_local_field.rb @@ -11,7 +11,6 @@ module ActionView end private - def format_date(value) value.try(:strftime, "%Y-%m-%dT%T") end diff --git a/actionview/lib/action_view/helpers/tags/label.rb b/actionview/lib/action_view/helpers/tags/label.rb index 02bd099784..436c4cbda3 100644 --- a/actionview/lib/action_view/helpers/tags/label.rb +++ b/actionview/lib/action_view/helpers/tags/label.rb @@ -71,7 +71,6 @@ module ActionView end private - def render_component(builder) builder.translation end diff --git a/actionview/lib/action_view/helpers/tags/month_field.rb b/actionview/lib/action_view/helpers/tags/month_field.rb index 93b2bf11f0..463866a181 100644 --- a/actionview/lib/action_view/helpers/tags/month_field.rb +++ b/actionview/lib/action_view/helpers/tags/month_field.rb @@ -5,7 +5,6 @@ module ActionView module Tags # :nodoc: class MonthField < DatetimeField # :nodoc: private - def format_date(value) value.try(:strftime, "%Y-%m") end diff --git a/actionview/lib/action_view/helpers/tags/radio_button.rb b/actionview/lib/action_view/helpers/tags/radio_button.rb index 621db2b1b5..4ce6c9f6bc 100644 --- a/actionview/lib/action_view/helpers/tags/radio_button.rb +++ b/actionview/lib/action_view/helpers/tags/radio_button.rb @@ -23,7 +23,6 @@ module ActionView end private - def checked?(value) value.to_s == @tag_value.to_s end diff --git a/actionview/lib/action_view/helpers/tags/select.rb b/actionview/lib/action_view/helpers/tags/select.rb index 790721a0b7..172e3a9226 100644 --- a/actionview/lib/action_view/helpers/tags/select.rb +++ b/actionview/lib/action_view/helpers/tags/select.rb @@ -29,7 +29,6 @@ module ActionView end private - # Grouped choices look like this: # # [nil, []] diff --git a/actionview/lib/action_view/helpers/tags/text_field.rb b/actionview/lib/action_view/helpers/tags/text_field.rb index d92967e212..c579e9e79f 100644 --- a/actionview/lib/action_view/helpers/tags/text_field.rb +++ b/actionview/lib/action_view/helpers/tags/text_field.rb @@ -24,7 +24,6 @@ module ActionView end private - def field_type self.class.field_type end diff --git a/actionview/lib/action_view/helpers/tags/time_field.rb b/actionview/lib/action_view/helpers/tags/time_field.rb index 9384a83a3e..e74c578db9 100644 --- a/actionview/lib/action_view/helpers/tags/time_field.rb +++ b/actionview/lib/action_view/helpers/tags/time_field.rb @@ -5,7 +5,6 @@ module ActionView module Tags # :nodoc: class TimeField < DatetimeField # :nodoc: private - def format_date(value) value.try(:strftime, "%T.%L") end diff --git a/actionview/lib/action_view/helpers/tags/week_field.rb b/actionview/lib/action_view/helpers/tags/week_field.rb index 572535d1d6..5a403ed91d 100644 --- a/actionview/lib/action_view/helpers/tags/week_field.rb +++ b/actionview/lib/action_view/helpers/tags/week_field.rb @@ -5,7 +5,6 @@ module ActionView module Tags # :nodoc: class WeekField < DatetimeField # :nodoc: private - def format_date(value) value.try(:strftime, "%Y-W%V") end diff --git a/actionview/lib/action_view/helpers/text_helper.rb b/actionview/lib/action_view/helpers/text_helper.rb index c282505e13..8203a43239 100644 --- a/actionview/lib/action_view/helpers/text_helper.rb +++ b/actionview/lib/action_view/helpers/text_helper.rb @@ -426,7 +426,6 @@ module ActionView end private - def next_index step_index(1) end diff --git a/actionview/lib/action_view/layouts.rb b/actionview/lib/action_view/layouts.rb index 08f66bf435..be21ff0e5d 100644 --- a/actionview/lib/action_view/layouts.rb +++ b/actionview/lib/action_view/layouts.rb @@ -224,7 +224,6 @@ module ActionView # that if no layout conditions are used, this method is not used module LayoutConditions # :nodoc: private - # Determines whether the current action has a layout definition by # checking the action name against the :only and :except conditions # set by the layout method. @@ -334,7 +333,6 @@ module ActionView end private - # If no layout is supplied, look for a template named the return # value of this method. # @@ -372,7 +370,6 @@ module ActionView end private - def _conditional_layout? true end diff --git a/actionview/lib/action_view/log_subscriber.rb b/actionview/lib/action_view/log_subscriber.rb index 227f025385..02ac0ce477 100644 --- a/actionview/lib/action_view/log_subscriber.rb +++ b/actionview/lib/action_view/log_subscriber.rb @@ -54,7 +54,6 @@ module ActionView end private - EMPTY = "" def from_rails_root(string) # :doc: string = string.sub(rails_root, EMPTY) diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb index b9a8cc129c..138ffa515b 100644 --- a/actionview/lib/action_view/lookup_context.rb +++ b/actionview/lib/action_view/lookup_context.rb @@ -112,7 +112,6 @@ module ActionView end private - def _set_detail(key, value) # :doc: @details = @details.dup if @digest_cache || @details_key @digest_cache = nil @@ -171,7 +170,6 @@ module ActionView end private - # Whenever setting view paths, makes a copy so that we can manipulate them in # instance objects as we wish. def build_view_paths(paths) diff --git a/actionview/lib/action_view/path_set.rb b/actionview/lib/action_view/path_set.rb index d54749d8e3..a6401323db 100644 --- a/actionview/lib/action_view/path_set.rb +++ b/actionview/lib/action_view/path_set.rb @@ -69,7 +69,6 @@ module ActionView #:nodoc: end private - def _find_all(path, prefixes, args) prefixes = [prefixes] if String === prefixes prefixes.each do |prefix| diff --git a/actionview/lib/action_view/record_identifier.rb b/actionview/lib/action_view/record_identifier.rb index ee39b6050d..7491dbe15a 100644 --- a/actionview/lib/action_view/record_identifier.rb +++ b/actionview/lib/action_view/record_identifier.rb @@ -95,7 +95,6 @@ module ActionView end private - # Returns a string representation of the key attribute(s) that is suitable for use in an HTML DOM id. # This can be overwritten to customize the default generated string representation if desired. # If you need to read back a key from a dom_id in order to query for the underlying database record, diff --git a/actionview/lib/action_view/renderer/abstract_renderer.rb b/actionview/lib/action_view/renderer/abstract_renderer.rb index b397c02cde..a52e5d3aca 100644 --- a/actionview/lib/action_view/renderer/abstract_renderer.rb +++ b/actionview/lib/action_view/renderer/abstract_renderer.rb @@ -74,7 +74,6 @@ module ActionView end private - def extract_details(options) # :doc: @lookup_context.registered_details.each_with_object({}) do |key, details| value = options[key] diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb index 608e417583..46bc4c9d5f 100644 --- a/actionview/lib/action_view/renderer/partial_renderer.rb +++ b/actionview/lib/action_view/renderer/partial_renderer.rb @@ -322,7 +322,6 @@ module ActionView end private - def render_collection(view, template) identifier = (template && template.identifier) || @path instrument(:collection, identifier: identifier, count: @collection.size) do |payload| diff --git a/actionview/lib/action_view/renderer/streaming_template_renderer.rb b/actionview/lib/action_view/renderer/streaming_template_renderer.rb index 19fa399e2c..08a280c7ee 100644 --- a/actionview/lib/action_view/renderer/streaming_template_renderer.rb +++ b/actionview/lib/action_view/renderer/streaming_template_renderer.rb @@ -27,7 +27,6 @@ module ActionView end private - # This is the same logging logic as in ShowExceptions middleware. def log_error(exception) logger = ActionView::Base.logger @@ -55,7 +54,6 @@ module ActionView end private - def delayed_render(buffer, template, layout, view, locals) # Wrap the given buffer in the StreamingBuffer and pass it to the # underlying template handler. Now, every time something is concatenated diff --git a/actionview/lib/action_view/renderer/template_renderer.rb b/actionview/lib/action_view/renderer/template_renderer.rb index 4cd8fc5bb2..b2d7332572 100644 --- a/actionview/lib/action_view/renderer/template_renderer.rb +++ b/actionview/lib/action_view/renderer/template_renderer.rb @@ -14,7 +14,6 @@ module ActionView end private - # Determine the template to be rendered using the given options. def determine_template(options) keys = options.has_key?(:locals) ? options[:locals].keys : [] diff --git a/actionview/lib/action_view/rendering.rb b/actionview/lib/action_view/rendering.rb index 5a06bd9da6..7247598ac2 100644 --- a/actionview/lib/action_view/rendering.rb +++ b/actionview/lib/action_view/rendering.rb @@ -104,7 +104,6 @@ module ActionView end private - # Find and render a template based on the options given. def _render_template(options) variant = options.delete(:variant) diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index b80bf56c1b..88320dcd0d 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -264,7 +264,6 @@ module ActionView end private - # Compile a template. This method ensures a template is compiled # just once and removes the source after it is compiled. def compile!(view) diff --git a/actionview/lib/action_view/template/error.rb b/actionview/lib/action_view/template/error.rb index d0ea03e228..feceef15f9 100644 --- a/actionview/lib/action_view/template/error.rb +++ b/actionview/lib/action_view/template/error.rb @@ -114,7 +114,6 @@ module ActionView end private - def source_location if line_number "on line ##{line_number} of " diff --git a/actionview/lib/action_view/template/handlers/erb.rb b/actionview/lib/action_view/template/handlers/erb.rb index b6314a5bc3..69a5a0b1b9 100644 --- a/actionview/lib/action_view/template/handlers/erb.rb +++ b/actionview/lib/action_view/template/handlers/erb.rb @@ -63,7 +63,6 @@ module ActionView end private - def valid_encoding(string, encoding) # If a magic encoding comment was found, tag the # String with this encoding. This is for a case diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index ce53eb046d..ebda5a167e 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -93,7 +93,6 @@ module ActionView end private - def canonical_no_templates(templates) templates.empty? ? NO_TEMPLATES : templates end @@ -130,7 +129,6 @@ module ActionView end private - def _find_all(name, prefix, partial, details, key, locals) find_templates(name, prefix, partial, details, locals) end @@ -183,7 +181,6 @@ module ActionView end private - def _find_all(name, prefix, partial, details, key, locals) path = Path.build(name, prefix, partial) query(path, details, details[:formats], locals, cache: !!key) @@ -323,7 +320,6 @@ module ActionView end private - def find_template_paths_from_details(path, details) # Instead of checking for every possible path, as our other globs would # do, scan the directory for files with the right prefix. diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb index 3a75633743..b08f8b2dfb 100644 --- a/actionview/lib/action_view/test_case.rb +++ b/actionview/lib/action_view/test_case.rb @@ -93,7 +93,6 @@ module ActionView end private - def include_helper_modules! helper(helper_class) if helper_class include _helpers @@ -163,7 +162,6 @@ module ActionView end private - # Need to experiment if this priority is the best one: rendered => output_buffer def document_root_element Nokogiri::HTML::Document.parse(@rendered.blank? ? @output_buffer : @rendered).root diff --git a/actionview/lib/action_view/testing/resolvers.rb b/actionview/lib/action_view/testing/resolvers.rb index 1bedf44934..539bedcdf0 100644 --- a/actionview/lib/action_view/testing/resolvers.rb +++ b/actionview/lib/action_view/testing/resolvers.rb @@ -22,7 +22,6 @@ module ActionView #:nodoc: end private - def query(path, exts, _, locals, cache:) query = +"" EXTENSIONS.each do |ext, prefix| diff --git a/actionview/lib/action_view/unbound_template.rb b/actionview/lib/action_view/unbound_template.rb index db69b6d016..d28bab91b6 100644 --- a/actionview/lib/action_view/unbound_template.rb +++ b/actionview/lib/action_view/unbound_template.rb @@ -18,7 +18,6 @@ module ActionView end private - def build_template(locals) options = @options.merge(locals: locals) Template.new( diff --git a/actionview/lib/action_view/view_paths.rb b/actionview/lib/action_view/view_paths.rb index 3ca5aedc14..7e05f15648 100644 --- a/actionview/lib/action_view/view_paths.rb +++ b/actionview/lib/action_view/view_paths.rb @@ -29,7 +29,6 @@ module ActionView end private - # Override this method in your controller if you want to change paths prefixes for finding views. # Prefixes defined here will still be added to parents' ._prefixes. def local_prefixes -- cgit v1.2.3