Skip to content

Commit

Permalink
Enforce consistent quote style
Browse files Browse the repository at this point in the history
Previously we allowed any style of quotation between files and within
the same file, which only serves to increase the mental load when trying
to write consistent code. It would be quite a large change to reenable
the associated RuboCop across the whole of GOV.UK, but this change will
help reduce the quotation choice overhead for at least this repo.
  • Loading branch information
Ben Thorner committed Sep 12, 2019
1 parent 8be6062 commit 3f55cd1
Show file tree
Hide file tree
Showing 181 changed files with 2,196 additions and 2,192 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
AllCops:
Exclude:
- 'lib/tasks/cucumber.rake' # Automatically generated
- tmp/**/*

Lint/AmbiguousRegexpLiteral:
Exclude:
Expand All @@ -11,3 +12,6 @@ Metrics/BlockLength:
- 'features/**/*.rb'
- 'spec/**/*'
- 'config/routes.rb'

Style/StringLiterals:
Enabled: true
58 changes: 29 additions & 29 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
source 'https://rubygems.org'
source "https://rubygems.org"

ruby File.read(".ruby-version").strip

gem 'chronic', '~> 0.10.2'
gem 'dalli'
gem 'gds-api-adapters', '~> 60.0'
gem "chronic", "~> 0.10.2"
gem "dalli"
gem "gds-api-adapters", "~> 60.0"
gem "google-api-client"
gem 'govuk_ab_testing', '~> 2.4.1'
gem 'govuk_app_config', '~> 2.0.0'
gem 'govuk_document_types', '~> 0.9.2'
gem 'govuk_publishing_components', '~> 20.5.0'
gem 'rails', '~> 5.2.3'
gem 'slimmer', '~> 13.1.0'
gem "govuk_ab_testing", "~> 2.4.1"
gem "govuk_app_config", "~> 2.0.0"
gem "govuk_document_types", "~> 0.9.2"
gem "govuk_publishing_components", "~> 20.5.0"
gem "rails", "~> 5.2.3"
gem "slimmer", "~> 13.1.0"

gem 'govuk_frontend_toolkit', '~> 8.2'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '~> 4.1'
gem 'whenever', "~> 1.0.0"
gem "govuk_frontend_toolkit", "~> 8.2"
gem "sass-rails", "~> 5.0"
gem "uglifier", "~> 4.1"
gem "whenever", "~> 1.0.0"

group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
gem "sdoc", require: false
end

group :development do
Expand All @@ -29,23 +29,23 @@ group :development do
end

group :development, :test do
gem 'awesome_print'
gem "awesome_print"
gem "dotenv-rails"
gem 'govuk-lint', '~> 3.11.5'
gem 'govuk_schemas', '~> 4.0'
gem 'jasmine-rails'
gem 'pry-byebug'
gem 'rspec-rails', '~> 3.8.2'
gem "govuk-lint", "~> 3.11.5"
gem "govuk_schemas", "~> 4.0"
gem "jasmine-rails"
gem "pry-byebug"
gem "rspec-rails", "~> 3.8.2"
end

group :test do
gem 'cucumber-rails', '~> 1.8.0', require: false
gem 'factory_bot'
gem 'govuk-content-schema-test-helpers', '~> 1.6'
gem 'govuk_test'
gem 'launchy', '~> 2.4.2'
gem 'rails-controller-testing'
gem 'simplecov', '~> 0.17.0'
gem "cucumber-rails", "~> 1.8.0", require: false
gem "factory_bot"
gem "govuk-content-schema-test-helpers", "~> 1.6"
gem "govuk_test"
gem "launchy", "~> 2.4.2"
gem "rails-controller-testing"
gem "simplecov", "~> 0.17.0"
gem "timecop"
gem 'webmock', '~> 3.7.2'
gem "webmock", "~> 3.7.2"
end
18 changes: 9 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('config/application', __dir__)
require File.expand_path("config/application", __dir__)

if Rails.env.development? && ENV['LIVE']
puts 'Pointing application at live dependencies...'
ENV['GOVUK_APP_DOMAIN'] = 'www.gov.uk'
ENV['GOVUK_WEBSITE_ROOT'] = 'https://www.gov.uk'
ENV['PLEK_SERVICE_SEARCH_URI'] = 'https://www.gov.uk/api'
ENV['PLEK_SERVICE_CONTENT_STORE_URI'] = 'https://www.gov.uk/api'
ENV['PLEK_SERVICE_STATIC_URI'] = 'assets.publishing.service.gov.uk'
ENV['PLEK_SERVICE_WHITEHALL_ADMIN_URI'] = 'https://www.gov.uk'
if Rails.env.development? && ENV["LIVE"]
puts "Pointing application at live dependencies..."
ENV["GOVUK_APP_DOMAIN"] = "www.gov.uk"
ENV["GOVUK_WEBSITE_ROOT"] = "https://www.gov.uk"
ENV["PLEK_SERVICE_SEARCH_URI"] = "https://www.gov.uk/api"
ENV["PLEK_SERVICE_CONTENT_STORE_URI"] = "https://www.gov.uk/api"
ENV["PLEK_SERVICE_STATIC_URI"] = "assets.publishing.service.gov.uk"
ENV["PLEK_SERVICE_WHITEHALL_ADMIN_URI"] = "https://www.gov.uk"
end

FinderFrontend::Application.load_tasks
10 changes: 5 additions & 5 deletions app/controllers/concerns/search_cluster_ab_testable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ def self.included(base)
# anything else = use default cluster
def search_cluster_test
@search_cluster_test ||= GovukAbTesting::AbTest.new(
'SearchClusterQueryABTest',
"SearchClusterQueryABTest",
dimension: CUSTOM_DIMENSION,
allowed_variants: %w[Default A B],
control_variant: 'Default',
control_variant: "Default",
)
end

Expand All @@ -26,7 +26,7 @@ def search_cluster_ab_params
if use_default_cluster?
{}
else
{ search_cluster_query: use_b_cluster? ? 'B' : 'A' }
{ search_cluster_query: use_b_cluster? ? "B" : "A" }
end
end

Expand All @@ -35,11 +35,11 @@ def set_search_cluster_response_header
end

def use_default_cluster?
!(search_cluster_variant.variant?('A') || search_cluster_variant.variant?('B'))
!(search_cluster_variant.variant?("A") || search_cluster_variant.variant?("B"))
end

def use_b_cluster?
search_cluster_variant.variant? 'B'
search_cluster_variant.variant? "B"
end

def search_cluster_test_in_scope?
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/email_alert_subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def has_default_filters?
def applied_filters
params
.permit("filter" => {})
.dig('filter')
.dig("filter")
.to_h
.merge(
filter_params.fetch('subscriber_list_params', {})
filter_params.fetch("subscriber_list_params", {})
)
end

Expand All @@ -73,16 +73,16 @@ def subscriber_list_title
title_builder = signup_presenter.email_filter_by == "facet_values" ? EmailAlertListTitleBuilder : EmailAlertTitleBuilder
title_builder.call(
filter: applied_filters,
subscription_list_title_prefix: content.dig('details', 'subscription_list_title_prefix'),
subscription_list_title_prefix: content.dig("details", "subscription_list_title_prefix"),
facets: signup_presenter.choices
)
end

def default_filters
content['details'].fetch('filter', {})
content["details"].fetch("filter", {})
end

def finder_format
finder_content_item.dig('details', 'filter', 'document_type')
finder_content_item.dig("details", "filter", "document_type")
end
end
18 changes: 9 additions & 9 deletions app/controllers/finders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def show
end
end
rescue ActionController::UnknownFormat
render plain: 'Not acceptable', status: :not_acceptable
render plain: "Not acceptable", status: :not_acceptable
end

private
Expand All @@ -51,7 +51,7 @@ def show
def redirect_to_destination
@redirect = content_item.redirect
@finder_slug = finder_slug
render 'finders/show-redirect'
render "finders/show-redirect"
end

def json_response
Expand Down Expand Up @@ -129,8 +129,8 @@ def sort_presenter
def pagination_presenter
PaginationPresenter.new(
per_page: content_item.default_documents_per_page,
start_offset: search_results.dig('start'),
total_results: search_results.dig('total'),
start_offset: search_results.dig("start"),
total_results: search_results.dig("total"),
url_builder: finder_url_builder,
)
end
Expand All @@ -140,7 +140,7 @@ def search_results
end

def suggestions
search_results.fetch('suggested_queries', []).map do |keywords|
search_results.fetch("suggested_queries", []).map do |keywords|
{
keywords: keywords,
link: finder_url_builder.url(keywords: keywords),
Expand All @@ -153,7 +153,7 @@ def finder_url_builder
end

def parent
params.fetch(:parent, '')
params.fetch(:parent, "")
end

def facet_tags
Expand All @@ -169,7 +169,7 @@ def grouped_display?
end

def remove_search_box
hide_site_serch = params['slug'] == 'search/all'
hide_site_serch = params["slug"] == "search/all"
set_slimmer_headers(remove_search: hide_site_serch)
end

Expand All @@ -178,11 +178,11 @@ def i_am_a_topic_page_finder
end

def taxonomy_registry
Services.registries.all['full_topic_taxonomy']
Services.registries.all["full_topic_taxonomy"]
end

def organisation_registry
Services.registries.all['organisations']
Services.registries.all["organisations"]
end

def debug_score?
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/qa_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def facet_grouped_allowed_values
end

def custom_options?
question_type == "single" && current_facet['custom_options'].present?
question_type == "single" && current_facet["custom_options"].present?
end

def options
Expand Down Expand Up @@ -143,7 +143,7 @@ def next_page_url
helper_method :next_page_url

def redirect_to_finder
redirect_to qa_config["finder_base_path"] + '?' + filtered_params.to_query
redirect_to qa_config["finder_base_path"] + "?" + filtered_params.to_query
end

def skip_link_url
Expand All @@ -166,7 +166,7 @@ def filtered_params
helper_method :filtered_params

def permitted_params
permitted_yesnos = facets.map { |facet| :"#{facet['key']}-yesno" }
permitted_yesnos = facets.map { |facet| :"#{facet["key"]}-yesno" }

permitted_keys = facets.each_with_object({}) do |facet, keys|
keys[facet["key"]] = []
Expand Down
46 changes: 23 additions & 23 deletions app/controllers/redirection_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class RedirectionController < ApplicationController
include PublicationsRoutes
DEFAULT_PUBLICATIONS_PATH = 'search/all'.freeze
DEFAULT_PUBLICATIONS_PATH = "search/all".freeze

def announcements
respond_to do |format|
format.html { redirect_to(finder_path('search/news-and-communications', params: convert_common_parameters)) }
format.atom { redirect_to(finder_path('search/news-and-communications', params: convert_common_parameters, format: :atom)) }
format.html { redirect_to(finder_path("search/news-and-communications", params: convert_common_parameters)) }
format.atom { redirect_to(finder_path("search/news-and-communications", params: convert_common_parameters, format: :atom)) }
end
end

Expand All @@ -18,34 +18,34 @@ def publications

def published_statistics
respond_to do |format|
format.html { redirect_to(finder_path('search/statistics', params: convert_common_parameters)) }
format.atom { redirect_to(finder_path('search/statistics', params: convert_common_parameters, format: :atom)) }
format.html { redirect_to(finder_path("search/statistics", params: convert_common_parameters)) }
format.atom { redirect_to(finder_path("search/statistics", params: convert_common_parameters, format: :atom)) }
end
end

def upcoming_statistics
respond_to do |format|
format.html { redirect_to(finder_path('search/statistics', params: convert_common_parameters.merge(content_store_document_type: :statistics_upcoming))) }
format.atom { redirect_to(finder_path('search/statistics', params: convert_common_parameters.merge(content_store_document_type: :statistics_upcoming), format: :atom)) }
format.html { redirect_to(finder_path("search/statistics", params: convert_common_parameters.merge(content_store_document_type: :statistics_upcoming))) }
format.atom { redirect_to(finder_path("search/statistics", params: convert_common_parameters.merge(content_store_document_type: :statistics_upcoming), format: :atom)) }
end
end

def advanced_search
conversion_hash =
{
'services' => 'services',
'guidance_and_regulation' => 'guidance-and-regulation',
'news_and_communications' => 'news-and-communications',
'research_and_statistics' => 'research-and-statistics',
'policy_and_engagement' => 'policy-papers-and-consultations',
'transparency' => 'transparency-and-freedom-of-information-releases'
"services" => "services",
"guidance_and_regulation" => "guidance-and-regulation",
"news_and_communications" => "news-and-communications",
"research_and_statistics" => "research-and-statistics",
"policy_and_engagement" => "policy-papers-and-consultations",
"transparency" => "transparency-and-freedom-of-information-releases"
}
group = conversion_hash[params['group']]
group = conversion_hash[params["group"]]
error_not_found && return if group.nil?

topic = params['topic']
topic = params["topic"]
url_params = if topic.present?
registry = Services.registries.all['full_topic_taxonomy']
registry = Services.registries.all["full_topic_taxonomy"]
content_id, = registry.taxonomy.find { |_, hash| hash["base_path"] == topic }
{ topic: content_id }
else
Expand All @@ -66,12 +66,12 @@ def set_document_type
end

def convert_common_parameters
{ keywords: params['keywords'],
level_one_taxon: params['taxons'].try(:first) || params['topics'].try(:first),
level_two_taxon: params['subtaxons'].try(:first),
organisations: params['departments'] || params['organisations'],
people: params['people'],
world_locations: params['world_locations'],
public_timestamp: { from: params['from_date'], to: params['to_date'] }.compact.presence }.compact
{ keywords: params["keywords"],
level_one_taxon: params["taxons"].try(:first) || params["topics"].try(:first),
level_two_taxon: params["subtaxons"].try(:first),
organisations: params["departments"] || params["organisations"],
people: params["people"],
world_locations: params["world_locations"],
public_timestamp: { from: params["from_date"], to: params["to_date"] }.compact.presence }.compact
end
end
12 changes: 6 additions & 6 deletions app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def index
redirect_to_all_content_finder(search_params) && return
end

render(action: 'no_search_term') && return
render(action: "no_search_term") && return
end

protected
Expand All @@ -39,12 +39,12 @@ def fill_in_slimmer_headers(result_count)
def redirect_to_all_content_finder(search_params)
all_content_params = {
keywords: search_params.search_term,
organisations: params['filter_organisations'],
manual: params['filter_manual'],
format: params['format'],
order: 'relevance'
organisations: params["filter_organisations"],
manual: params["filter_manual"],
format: params["format"],
order: "relevance"
}.compact

redirect_to(finder_path('search/all', params: all_content_params), status: :moved_permanently)
redirect_to(finder_path("search/all", params: all_content_params), status: :moved_permanently)
end
end
Loading

0 comments on commit 3f55cd1

Please sign in to comment.