From dcc52d967cfd9577d7899ea0141a2b886c29a693 Mon Sep 17 00:00:00 2001 From: Mauro Otonelli Date: Sun, 19 Jul 2015 20:45:45 -0300 Subject: [PATCH] Applied Rubocop feedback. --- middleman-core/lib/middleman-core/cli/extension.rb | 4 ++-- middleman-core/lib/middleman-core/configuration.rb | 2 -- .../lib/middleman-core/core_extensions/rendering.rb | 3 +-- middleman-core/lib/middleman-core/extension.rb | 1 - .../lib/middleman-core/sitemap/extensions/proxies.rb | 1 - .../lib/middleman-more/core_extensions/default_helpers.rb | 6 +++--- middleman-core/lib/middleman-more/core_extensions/i18n.rb | 4 ++-- middleman-core/lib/middleman-more/extensions/lorem.rb | 4 ++-- .../lib/middleman-more/extensions/relative_assets.rb | 2 +- 9 files changed, 11 insertions(+), 16 deletions(-) diff --git a/middleman-core/lib/middleman-core/cli/extension.rb b/middleman-core/lib/middleman-core/cli/extension.rb index 1065514f..c6ababd9 100644 --- a/middleman-core/lib/middleman-core/cli/extension.rb +++ b/middleman-core/lib/middleman-core/cli/extension.rb @@ -35,13 +35,13 @@ module Middleman::Cli # Output a .gitignore file class_option :git, type: :boolean, default: true - no_tasks { + no_tasks do # Write a .gitignore file for project # @return [void] def generate_gitignore! return unless options[:git] copy_file 'gitignore', File.join(name, '.gitignore') end - } + end end end diff --git a/middleman-core/lib/middleman-core/configuration.rb b/middleman-core/lib/middleman-core/configuration.rb index 6c227504..e1cff713 100644 --- a/middleman-core/lib/middleman-core/configuration.rb +++ b/middleman-core/lib/middleman-core/configuration.rb @@ -118,7 +118,6 @@ module Middleman # Set the value of a setting by key. Creates the setting if it doesn't exist. # @param [Symbol] key # @param [Object] val - # rubocop:disable UselessSetterCall def []=(key, val) setting_obj = setting(key) || define_setting(key) setting_obj.value = val @@ -228,7 +227,6 @@ module Middleman end # Whether or not there has been a value set beyond the default - # rubocop:disable TrivialAccessors def value_set? @value_set end diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index d1c361ee..11e1cbb0 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -428,7 +428,7 @@ module Middleman layout_path = locate_layout(layout_name, current_engine) - if !layout_path + unless layout_path raise ::Middleman::CoreExtensions::Rendering::TemplateNotFound, "Could not locate layout: #{layout_name}" end @@ -462,7 +462,6 @@ module Middleman end # The currently rendering engine - # rubocop:disable TrivialAccessors # @return [Symbol, nil] def current_engine=(v) @_current_engine = v diff --git a/middleman-core/lib/middleman-core/extension.rb b/middleman-core/lib/middleman-core/extension.rb index 3a21000c..311375b7 100644 --- a/middleman-core/lib/middleman-core/extension.rb +++ b/middleman-core/lib/middleman-core/extension.rb @@ -130,7 +130,6 @@ module Middleman @klass.after_configuration do ext.after_configuration if ext.respond_to?(:after_configuration) - # rubocop:disable IfUnlessModifier if ext.respond_to?(:manipulate_resource_list) ext.app.sitemap.register_resource_list_manipulator(ext.class.extension_name, ext) end diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb b/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb index 8fb29cc8..54ca3d5e 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb @@ -17,7 +17,6 @@ module Middleman module ResourceInstanceMethods # Whether this page is a proxy - # rubocop:disable TrivialAccessors # @return [Boolean] def proxy? @proxied_to diff --git a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb index cbb94768..3fe8d680 100644 --- a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb @@ -102,13 +102,13 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension # Override helper to add `relative` opt-out. def stylesheet_link_tag(*sources) options = { - :rel => 'stylesheet' + rel: 'stylesheet' }.update(sources.extract_options!.symbolize_keys) path_options = {} path_options[:relative] = options.delete(:relative) if options.key?(:relative) - sources.flatten.inject(ActiveSupport::SafeBuffer.new) do |all,source| + sources.flatten.inject(ActiveSupport::SafeBuffer.new) do |all, source| all << tag(:link, { href: asset_path(:css, source, path_options) }.update(options)) @@ -122,7 +122,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension path_options = {} path_options[:relative] = options.delete(:relative) if options.key?(:relative) - sources.flatten.inject(::ActiveSupport::SafeBuffer.new) do |all,source| + sources.flatten.inject(::ActiveSupport::SafeBuffer.new) do |all, source| all << content_tag(:script, nil, { src: asset_path(:js, source, path_options) }.update(options)) diff --git a/middleman-core/lib/middleman-more/core_extensions/i18n.rb b/middleman-core/lib/middleman-more/core_extensions/i18n.rb index 318b2b47..2c041a83 100644 --- a/middleman-core/lib/middleman-more/core_extensions/i18n.rb +++ b/middleman-core/lib/middleman-more/core_extensions/i18n.rb @@ -245,10 +245,10 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension ::I18n.locale = lang localized_page_id = ::I18n.t("paths.#{page_id}", default: page_id, fallback: []) - partially_localized_path = "" + partially_localized_path = '' File.dirname(path).split('/').each do |path_sub| - next if path_sub == "" + next if path_sub == '' partially_localized_path = "#{partially_localized_path}/#{(::I18n.t("paths.#{path_sub}", default: path_sub).to_s)}" end diff --git a/middleman-core/lib/middleman-more/extensions/lorem.rb b/middleman-core/lib/middleman-more/extensions/lorem.rb index 32f1c6c1..91a0612d 100644 --- a/middleman-core/lib/middleman-more/extensions/lorem.rb +++ b/middleman-core/lib/middleman-more/extensions/lorem.rb @@ -152,8 +152,8 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension color = options[:color] if options[:random_color] - background_color = hex.shuffle[0...6].join - color = hex.shuffle[0...6].join + background_color = hex.sample(6).join + color = hex.sample(6).join end src << "/#{background_color.sub(/^#/, '')}" if background_color diff --git a/middleman-core/lib/middleman-more/extensions/relative_assets.rb b/middleman-core/lib/middleman-more/extensions/relative_assets.rb index 95eb291b..28024a2e 100644 --- a/middleman-core/lib/middleman-more/extensions/relative_assets.rb +++ b/middleman-core/lib/middleman-more/extensions/relative_assets.rb @@ -18,7 +18,7 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension def asset_url(path, prefix='', options={}) options[:relative] = true unless options.key?(:relative) - path = super(path, prefix, options) + super(path, prefix, options) end end end