Skip to content

Commit

Permalink
Rubocop automatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Vicente authored and Pablo Vicente committed Oct 14, 2014
1 parent 84ed59b commit 7e1fa73
Show file tree
Hide file tree
Showing 169 changed files with 467 additions and 511 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -27,7 +27,7 @@ def parent_template
helper_method :parent_template

def not_found
raise ActionController::RoutingError.new('Not Found')
fail ActionController::RoutingError.new('Not Found')
end

def cookies_not_accepted?
Expand Down
1 change: 0 additions & 1 deletion app/controllers/articles_preview_controller.rb
Expand Up @@ -4,5 +4,4 @@ class ArticlesPreviewController < ArticlesController
def interactor
Core::ArticlePreviewer.new(params[:id])
end

end
5 changes: 2 additions & 3 deletions app/controllers/budget_planner_controller.rb
@@ -1,12 +1,11 @@
class BudgetPlannerController < EmbeddedToolsController
protected
protected

helper_method def incognito?
params.key?(:incognito)
params.key?(:incognito)
end

def category_id
'managing-money'
end

end
2 changes: 1 addition & 1 deletion app/controllers/concerns/localisation.rb
Expand Up @@ -20,7 +20,7 @@ def alternate_locales
I18n.available_locales - Array(I18n.locale)
end

def default_url_options(options={})
def default_url_options(_options = {})
{ locale: I18n.locale }
end

Expand Down
8 changes: 3 additions & 5 deletions app/controllers/embedded_tools_controller.rb
@@ -1,6 +1,5 @@
class EmbeddedToolsController < ApplicationController

protected
protected

def breadcrumbs
BreadcrumbTrail.build(category, category_tree)
Expand All @@ -22,7 +21,7 @@ def alternate_url

# Remove the locale and tool_id as we've dealt with those in the script_name.
# (And if we don't they'll be added to the query string.)
new_params.delete_if { |key, _| ['locale', 'tool_id'].include?(key) }
new_params.delete_if { |key, _| %w(locale tool_id).include?(key) }

url = url_for(new_params)

Expand All @@ -38,7 +37,7 @@ def alternate_url
def alternate_options
{
"#{params[:locale]}-GB" => request.url,
"#{alternate_locale }-GB"=> alternate_url
"#{alternate_locale }-GB" => alternate_url
}
end

Expand Down Expand Up @@ -77,5 +76,4 @@ def display_category_directory?
end

helper_method :display_category_directory?

end
4 changes: 2 additions & 2 deletions app/controllers/empty_controller.rb
Expand Up @@ -13,13 +13,13 @@ def optimizely_include_tag
end
helper_method :optimizely_include_tag

def raw(stringish)
def raw(_stringish)
end
helper_method :raw

def render(*args)
super
root = "#{request.protocol}#{request.host_with_port.sub(/:80$/, "")}/"
root = "#{request.protocol}#{request.host_with_port.sub(/:80$/, '')}/"
response.body = response.body.gsub(%r{href=\"/}, "href=\"#{root}")
end
end
2 changes: 0 additions & 2 deletions app/controllers/home_controller.rb
@@ -1,7 +1,5 @@
class HomeController < ApplicationController

def show

end

def display_menu_button_in_header?
Expand Down
1 change: 0 additions & 1 deletion app/controllers/newsletter_subscriptions_controller.rb
@@ -1,5 +1,4 @@
class NewsletterSubscriptionsController < ApplicationController

def create
if @success = Core::NewsletterSubscriptionCreator.new(subscription_params).call
flash[:success] = I18n.t('newsletter_subscriptions.success')
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/registrations_controller.rb
Expand Up @@ -8,14 +8,14 @@ def edit

protected

def build_resource(hash=nil)
def build_resource(hash = nil)
hash[:accept_terms_conditions] = true if hash
super(hash)
end

private

def after_sign_up_path_for(resource)
def after_sign_up_path_for(_resource)
session[:user_return_to] || root_path
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/sessions_controller.rb
Expand Up @@ -6,7 +6,7 @@ def new
# This method is mostly copied devise code
# With one tweak to add the error to resource from the flash hash
self.resource = resource_class.new(sign_in_params)
self.resource.errors.add(:base, flash[:alert]) if flash[:alert]
resource.errors.add(:base, flash[:alert]) if flash[:alert]
clean_up_passwords(resource)
respond_with(resource, serialize_options(resource))
end
Expand All @@ -17,11 +17,11 @@ def xhr_not_implemented
head :not_implemented if request.xhr?
end

def after_sign_in_path_for(resource)
def after_sign_in_path_for(_resource)
last_known_path_or_root_path
end

def after_sign_out_path_for(resource)
def after_sign_out_path_for(_resource)
last_known_path_or_root_path
end

Expand Down
21 changes: 10 additions & 11 deletions app/controllers/styleguide_controller.rb
Expand Up @@ -66,7 +66,6 @@ def pages_home
end

def pages_tool

def contact_panels_border_top?
true
end
Expand Down Expand Up @@ -149,18 +148,18 @@ def categories
title: 'Insurance',
object: { contents: [] },
contents: [
{ title: 'Choosing home insurance cover' },
{ title: 'Do I need car insurance' },
{ title: 'Making a claim' }
]
{ title: 'Choosing home insurance cover' },
{ title: 'Do I need car insurance' },
{ title: 'Making a claim' }
]
},
{
title: 'Debt',
object: { contents: [] },
contents: [
{ title: 'Avoiding the bailiff' },
{ title: 'Does money grow on trees - we investigate' }
]
{ title: 'Avoiding the bailiff' },
{ title: 'Does money grow on trees - we investigate' }
]
}
].map(&:to_ostruct)
end
Expand Down Expand Up @@ -226,9 +225,9 @@ def categories_for_directory_en

def news
[{
title: "Women are feeling the financial squeeze more than men",
date: "10 Jun 2014",
description: "Four in ten women feel financially worse off than they did a year ago, according to a new report from SavvyWoman."
title: 'Women are feeling the financial squeeze more than men',
date: '10 Jun 2014',
description: 'Four in ten women feel financially worse off than they did a year ago, according to a new report from SavvyWoman.'
}].map(&:to_ostruct)
end

Expand Down
2 changes: 1 addition & 1 deletion app/decorators/campaign_page/section_decorator.rb
Expand Up @@ -20,7 +20,7 @@ def intro
end

def css_name
name.tr("_", "-")
name.tr('_', '-')
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/decorators/category_decorator.rb
Expand Up @@ -19,9 +19,9 @@ def alternate_options

def render_contents
partial = if object.parent?
'child_categories'
'child_categories'
elsif object.child?
'content_items'
'content_items'
end

h.render partial, contents: contents
Expand Down
4 changes: 2 additions & 2 deletions app/decorators/chat_opening_hours_decorator.rb
Expand Up @@ -25,14 +25,14 @@ def description

def periods
@periods ||= begin
days.reduce([]) { |result, day|
days.reduce([]) do |result, day|
if result.last && result.last.hours == week[day]
result.last.days << day
else
result << Period.new([day], week[day])
end
result
}.map { |opening_period| opening_period.to_s }
end.map(&:to_s)
end
end

Expand Down
3 changes: 1 addition & 2 deletions app/decorators/news_article_decorator.rb
Expand Up @@ -3,13 +3,12 @@
class NewsArticleDecorator < ContentItemDecorator
delegate :description


def initialize(object, options = {})
super
processors << [HTMLProcessor::NodeRemover, [HTMLProcessor::IMAGE_AUTHOR]]
end

def date(options={})
def date(options = {})
h.l(object.date, format: options.fetch(:format, :short))
end

Expand Down
1 change: 0 additions & 1 deletion app/decorators/search_result_decorator.rb
Expand Up @@ -28,5 +28,4 @@ def title_suffix_regexps
ellipsis: is_truncated ? ' ...' : nil })
end
end

end
4 changes: 2 additions & 2 deletions app/domain/breadcrumb.rb
Expand Up @@ -4,8 +4,8 @@ class Breadcrumb
attr_accessor :path, :title

def initialize(category)
@path, @title = if category.home? or category.news?
[category.path, category.title]
@path, @title = if category.home? || category.news?
[category.path, category.title]
else
[category_path(category.id, locale: I18n.locale), category.title]
end
Expand Down
2 changes: 1 addition & 1 deletion app/domain/breadcrumb_trail.rb
Expand Up @@ -3,7 +3,7 @@ def self.build(item, category_tree)
categories = case item
when Core::Category
if item.parent_id.present?
RootToNodePath.build(item, category_tree)[0 ... -1]
RootToNodePath.build(item, category_tree)[0...-1]
else
[HomeCategory.new]
end
Expand Down
2 changes: 1 addition & 1 deletion app/domain/related_content.rb
Expand Up @@ -3,7 +3,7 @@ def self.build(item, limit = 6)
category_contents = sibling_and_cousin_contents(item)
related_content = []

until category_contents.all?(&:empty?) do
until category_contents.all?(&:empty?)
category_contents.each do |contents|
related_content << item if item = contents.shift
return related_content if related_content.count == limit
Expand Down
2 changes: 1 addition & 1 deletion app/domain/root_to_node_path.rb
@@ -1,7 +1,7 @@
class RootToNodePath
def self.build(category, category_tree)
if node = category_tree.find { |n| n.name == category.id }
node.parentage.reverse.collect(&:content) + [category]
node.parentage.reverse.map(&:content) + [category]
else
[]
end
Expand Down
2 changes: 0 additions & 2 deletions app/domain/tool_category.rb
@@ -1,5 +1,4 @@
class ToolCategory

attr_reader :id

def initialize(category_id)
Expand All @@ -23,5 +22,4 @@ def news?
def entity
@entity ||= Core::CategoryReader.new(id).call
end

end
1 change: 0 additions & 1 deletion app/models/campaign_page/article.rb
Expand Up @@ -10,4 +10,3 @@ def initialize(attributes = {})
end
end
end

7 changes: 3 additions & 4 deletions app/models/user.rb
Expand Up @@ -30,7 +30,7 @@ def field_order
validates :last_name, format: { with: /\A[A-Za-z '-\.]+\z/ },
allow_blank: true,
length: { maximum: 24 }
validates :gender, inclusion: { in: ['female', 'male'] }, allow_nil: true
validates :gender, inclusion: { in: %w(female male) }, allow_nil: true
validates :date_of_birth, timeliness: { before: Date.today, allow_nil: true, type: :date }
validates :age_range, inclusion: { in: VALID_AGE_RANGES }, allow_nil: true

Expand Down Expand Up @@ -64,12 +64,11 @@ def create_to_crm
end

def uppercase_post_code
self.post_code.upcase! if post_code
post_code.upcase! if post_code
end

def fake_send_confirmation_email
#Temporary fix to trick Devise into thinking an email confirmation is sent to the user so they can sign in desktop site.
# Temporary fix to trick Devise into thinking an email confirmation is sent to the user so they can sign in desktop site.
self.confirmation_sent_at = DateTime.now
end
end

1 change: 0 additions & 1 deletion app/services/perform_corrective_search.rb
@@ -1,5 +1,4 @@
class PerformCorrectiveSearch

def initialize(query, page)
@query = query
@page = page
Expand Down
2 changes: 1 addition & 1 deletion bin/cucumber
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
load File.expand_path('../spring', __FILE__)
rescue LoadError
end
require 'bundler/setup'
Expand Down
2 changes: 1 addition & 1 deletion bin/rails
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
load File.expand_path('../spring', __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
Expand Down
2 changes: 1 addition & 1 deletion bin/rake
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
load File.expand_path('../spring', __FILE__)
rescue LoadError
end
require 'bundler/setup'
Expand Down
2 changes: 1 addition & 1 deletion bin/rspec
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
load File.expand_path('../spring', __FILE__)
rescue LoadError
end
require 'bundler/setup'
Expand Down
12 changes: 6 additions & 6 deletions bin/spring
Expand Up @@ -4,15 +4,15 @@
# It gets overwritten when you run the `spring binstub` command

unless defined?(Spring)
require "rubygems"
require "bundler"
require 'rubygems'
require 'bundler'

if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
ENV["GEM_HOME"] = ""
ENV['GEM_PATH'] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
ENV['GEM_HOME'] = ''
Gem.paths = ENV

gem "spring", match[1]
require "spring/binstub"
gem 'spring', match[1]
require 'spring/binstub'
end
end
2 changes: 1 addition & 1 deletion features/factories/category.rb
Expand Up @@ -11,7 +11,7 @@
type 'category'

trait :content_items do
contents { %w{article_hash action_plan_hash}.map(&method(:build)) }
contents { %w(article_hash action_plan_hash).map(&method(:build)) }
end

initialize_with do
Expand Down

0 comments on commit 7e1fa73

Please sign in to comment.