Skip to content

Commit 21e752a

Browse files
author
Ben Thorner
committed
Linting auto-correct
1 parent 905661c commit 21e752a

30 files changed

+58
-58
lines changed

Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ unless Rails.env.production?
1010
require "scss_lint/rake_task"
1111

1212
RuboCop::RakeTask.new(:rubocop) do |t|
13-
t.patterns = %w(app config test Gemfile)
13+
t.patterns = %w[app config test Gemfile]
1414
end
1515

1616
SCSSLint::RakeTask.new do |t|

app/helpers/webchat_availability_helper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module WebchatAvailabilityHelper
22
UNAVAILABILITY_MESSAGE = "This service will be unavailable from 4pm on Saturday 12 May to 9am on Monday 14 May.".freeze
3-
HMRC_WEBCHAT_CONTACT_PATHS = %w(
3+
HMRC_WEBCHAT_CONTACT_PATHS = %w[
44
/government/organisations/hm-revenue-customs/contact/online-services-helpdesk
55
/government/organisations/hm-revenue-customs/contact/income-tax-enquiries-for-individuals-pensioners-and-employees
66
/government/organisations/hm-revenue-customs/contact/self-assessment
77
/government/organisations/hm-revenue-customs/contact/tax-credits-enquiries
8-
).freeze
8+
].freeze
99
UNAVAILABILITY_START = Time.zone.parse("2018-05-12 16:00 BST").freeze
1010
UNAVAILABILITY_END = Time.zone.parse("2018-05-14 09:00 BST").freeze
1111

app/models/webchat.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Webchat
33

44
CONFIG_PATH = Rails.root.join("lib/webchat.yaml")
55

6-
validates_presence_of :base_path, :open_url, :availability_url
6+
validates :base_path, :open_url, :availability_url, presence: true
77

88
attr_reader :base_path, :open_url, :availability_url, :open_url_redirect
99

app/presenters/consultation_presenter.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def open?
3232
end
3333

3434
def closed?
35-
%w(closed_consultation consultation_outcome).include? document_type
35+
%w[closed_consultation consultation_outcome].include? document_type
3636
end
3737

3838
def unopened?
@@ -127,7 +127,7 @@ def display_date_and_time(date, rollback_midnight = false)
127127
# 12am, 12:00am and "midnight on" can all be misinterpreted
128128
# Use 11:59pm on the day before to remove ambiguity
129129
# 12am on 10 January becomes 11:59pm on 9 January
130-
time = time - 1.second if time.strftime(time_format) == "12:00am"
130+
time -= 1.second if time.strftime(time_format) == "12:00am"
131131
end
132132
I18n.l(time, format: "#{time_format} on #{date_format}").gsub(":00", "").gsub("12pm", "midday").gsub("12am on ", "").strip
133133
end

app/presenters/contact_presenter.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def related_contacts_links
140140
related.map do |link|
141141
{
142142
title: link["title"],
143-
url: link["base_path"],
143+
url: link["base_path"],
144144
}
145145
end
146146
end
@@ -150,7 +150,7 @@ def quick_links
150150
quick.map do |link|
151151
{
152152
title: link["title"],
153-
url: link["url"],
153+
url: link["url"],
154154
}
155155
end
156156
end

app/presenters/content_item/contents_list.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def first_item_has_long_content?
4949
def first_item_content
5050
element = first_item
5151
first_item_text = ""
52-
allowed_elements = %w(p ul ol)
52+
allowed_elements = %w[p ul ol]
5353

5454
until element.name == "h2"
5555
first_item_text += element.text if element.name.in?(allowed_elements)
@@ -70,7 +70,7 @@ def first_item_has_long_table?
7070
def find_first_table
7171
element = first_item
7272

73-
until element.name == "h2" do
73+
until element.name == "h2"
7474
return element if element.name == "table"
7575

7676
element = element.next_element

app/presenters/content_item/linkable.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ module Linkable
33
include ActionView::Helpers::UrlHelper
44

55
def from
6-
organisations_ordered_by_importance + links_group(%w{worldwide_organisations people speaker})
6+
organisations_ordered_by_importance + links_group(%w[worldwide_organisations people speaker])
77
end
88

99
def part_of
10-
links_group(%w{
10+
links_group(%w[
1111
document_collections
1212
related_policies
1313
policies
1414
world_locations
1515
topics
1616
topical_events
1717
related_statistical_data_sets
18-
})
18+
])
1919
end
2020

2121
private

app/presenters/content_item/parts.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def part_links
8787
parts.map.with_index(1) do |part, position|
8888
if part["slug"] != current_part["slug"]
8989
link_to part["title"], part["full_path"], class: "govuk-link",
90-
data: {
90+
data: {
9191
track_category: "contentsClicked",
9292
track_action: "content_item #{position}",
9393
track_label: part["full_path"],

app/presenters/travel_advice_presenter.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ def print_link
6868
# Feature included as it _could_ still be used
6969
# Remove when alert status boxes no longer in travel advice publisher
7070
def alert_status
71-
allowed_statuses = %w{
71+
allowed_statuses = %w[
7272
avoid_all_but_essential_travel_to_parts
7373
avoid_all_travel_to_parts
7474
avoid_all_but_essential_travel_to_whole_country
7575
avoid_all_travel_to_whole_country
76-
}
76+
]
7777
alert_statuses = content_item["details"]["alert_status"] || []
7878
alert_statuses = alert_statuses.map do |alert|
7979
if allowed_statuses.include?(alert)

config/application.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Application < Rails::Application
2222
config.time_zone = "London"
2323

2424
# Custom directories with classes and modules you want to be autoloadable.
25-
config.autoload_paths += %W(#{config.root}/lib)
25+
config.autoload_paths += %W[#{config.root}/lib]
2626

2727
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
2828
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]

config/initializers/assets.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# Precompile additional assets.
1010
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11-
Rails.application.config.assets.precompile += %w(
11+
Rails.application.config.assets.precompile += %w[
1212
print.css
1313
webchat.js
14-
)
14+
]

config/locales/plurals.rb

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
{
2-
#Dari - this isn't an iso code. Probably should be 'prs' as per ISO 639-3.
2+
# Dari - this isn't an iso code. Probably should be 'prs' as per ISO 639-3.
33
dr: { i18n: { plural: { keys: %i[one other], rule: lambda { |n| n == 1 ? :one : :other } } } },
4-
#Armenian
4+
# Armenian
55
hy: { i18n: { plural: { keys: %i[one other], rule: lambda { |n| n == 1 ? :one : :other } } } },
6-
#Pushto
6+
# Pushto
77
ps: { i18n: { plural: { keys: %i[one other], rule: lambda { |n| n == 1 ? :one : :other } } } },
8-
#Portugese
8+
# Portugese
99
pt: { i18n: { plural: { keys: %i[one other], rule: lambda { |n| n == 1 ? :one : :other } } } },
10-
#Sinhalese
10+
# Sinhalese
1111
si: { i18n: { plural: { keys: %i[one other], rule: lambda { |n| n == 1 ? :one : :other } } } },
12-
#Somali
12+
# Somali
1313
so: { i18n: { plural: { keys: %i[one other], rule: lambda { |n| n == 1 ? :one : :other } } } },
14-
#Albanian
14+
# Albanian
1515
sq: { i18n: { plural: { keys: %i[one other], rule: lambda { |n| n == 1 ? :one : :other } } } },
16-
#Tamil
16+
# Tamil
1717
ta: { i18n: { plural: { keys: %i[one other], rule: lambda { |n| n == 1 ? :one : :other } } } },
18-
#Turkmen
18+
# Turkmen
1919
tk: { i18n: { plural: { keys: %i[one other], rule: lambda { |n| n == 1 ? :one : :other } } } },
20-
#Uzbek
20+
# Uzbek
2121
uz: { i18n: { plural: { keys: %i[one other], rule: lambda { |n| n == 1 ? :one : :other } } } },
22-
#Chinese Hong Kong
22+
# Chinese Hong Kong
2323
"zh-hk" => { i18n: { plural: { keys: %i[one other], rule: lambda { |n| n == 1 ? :one : :other } } } },
24-
#Chinese Taiwan
24+
# Chinese Taiwan
2525
"zh-tw" => { i18n: { plural: { keys: %i[one other], rule: lambda { |n| n == 1 ? :one : :other } } } },
2626
}

config/spring.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
%w(
1+
%w[
22
.ruby-version
33
.rbenv-vars
44
tmp/restart.txt
55
tmp/caching-dev.txt
6-
).each { |path| Spring.watch(path) }
6+
].each { |path| Spring.watch(path) }

lib/helpers/wraith_config_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def create_config(extra_config = {})
2020
private
2121

2222
def load_template
23-
YAML::safe_load(File.open(TEMPLATE_PATH))
23+
YAML.safe_load(File.open(TEMPLATE_PATH))
2424
end
2525

2626
def build_paths

test/components/banner_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def component_name
3333

3434
test "renders a banner with title, text and aside correctly" do
3535
render_component(title: "Summary",
36-
text: "This was published under the 2010 to 2015 Conservative government",
37-
aside: "This consultation ran from 9:30am on 30 January 2017 to 5pm on 28 February 2017")
36+
text: "This was published under the 2010 to 2015 Conservative government",
37+
aside: "This consultation ran from 9:30am on 30 January 2017 to 5pm on 28 February 2017")
3838

3939
assert_select ".app-c-banner--aside"
4040
assert_select ".app-c-banner__title", text: "Summary"

test/controllers/content_items_controller_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class ContentItemsControllerTest < ActionController::TestCase
257257
get :show, params: { path: path_for(content_item, locale), locale: locale }
258258

259259
assert_response :success
260-
assert_select "title", %r(#{translated_schema_name})
260+
assert_select "title", %r{#{translated_schema_name}}
261261
end
262262

263263
test "renders atom feeds" do

test/controllers/step_navigation_controller_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class ContentItemsControllerTest < ActionController::TestCase
44
include GdsApi::TestHelpers::ContentStore
55

6-
%w(guide answer publication).each do |schema_name|
6+
%w[guide answer publication].each do |schema_name|
77
test "#{schema_name} shows step by step navigation where relevant" do
88
content_item = content_store_has_schema_example(schema_name, "#{schema_name}-with-step-navs")
99
content_item["base_path"] = "/pass-plus"

test/helpers/application_helper_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ class ApplicationHelperTest < ActionView::TestCase
44
tests ApplicationHelper
55

66
test "#current_path_without_query_string returns the path of the current request" do
7-
self.stubs(:request).returns(ActionDispatch::TestRequest.create("PATH_INFO" => "/foo/bar"))
7+
stubs(:request).returns(ActionDispatch::TestRequest.create("PATH_INFO" => "/foo/bar"))
88
assert_equal "/foo/bar", current_path_without_query_string
99
end
1010

1111
test "#current_path_without_query_string returns the path of the current request stripping off any query string parameters" do
12-
self.stubs(:request).returns(ActionDispatch::TestRequest.create("PATH_INFO" => "/foo/bar", "QUERY_STRING" => "ham=jam&spam=gram"))
12+
stubs(:request).returns(ActionDispatch::TestRequest.create("PATH_INFO" => "/foo/bar", "QUERY_STRING" => "ham=jam&spam=gram"))
1313
assert_equal "/foo/bar", current_path_without_query_string
1414
end
1515

test/integration/component_guide_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
class ComponentGuideTest < ActionDispatch::IntegrationTest
55
# temporarily disabling to get around an error to do with an image in one of the component pages
6-
#include GovukPublishingComponents::Minitest::ComponentGuideTest
6+
# include GovukPublishingComponents::Minitest::ComponentGuideTest
77
end

test/integration/consultation_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ConsultationTest < ActionDispatch::IntegrationTest
1010
assert_has_publisher_metadata(
1111
published: "Published 4 November 2016",
1212
last_updated: "Last updated 7 November 2016",
13-
metadata: {
13+
metadata: {
1414
"From": { "Department for Education": "/government/organisations/department-for-education" },
1515
},
1616
)

test/integration/travel_advice_atom_feed_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class TravelAdviceAtomFeed < ActionDispatch::IntegrationTest
2727
end
2828

2929
test "it sets the entry's summary correctly" do
30-
summary = Nokogiri::HTML::fragment(@feed.items.first.summary.content)
30+
summary = Nokogiri::HTML.fragment(@feed.items.first.summary.content)
3131
assert_equal summary.text.strip, @content_item["details"]["change_description"].strip
3232
end
3333

test/presenters/contact_presenter_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def schema_name
3838
presented_post_address = presented_item.post[0]
3939
assert_equal post_address["description"].strip, presented_post_address[:description]
4040
rendered_presented_address = presented_post_address[:v_card].reduce("") { |acc, hash| acc << hash[:value].strip }
41-
rendered_input_address = %w(title street_address locality region postal_code world_location).reduce("") do |acc, key|
41+
rendered_input_address = %w[title street_address locality region postal_code world_location].reduce("") do |acc, key|
4242
acc << post_address[key].strip
4343
end
4444
assert_equal rendered_input_address, rendered_presented_address

test/presenters/content_item/linkable_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def initialize
2424
]
2525

2626
expected_from_links = [
27-
%{<a class="govuk-link" href="/government/people/winston-churchill">Winston Churchill</a>},
27+
%(<a class="govuk-link" href="/government/people/winston-churchill">Winston Churchill</a>),
2828
]
2929
assert_equal expected_from_links, item.from
3030
end
@@ -55,7 +55,7 @@ def initialize
5555
]
5656

5757
expected_from_links = [
58-
%{<a class=\"govuk-link\" href="/world/germany/news">Germany</a>},
58+
%(<a class=\"govuk-link\" href="/world/germany/news">Germany</a>),
5959
]
6060
assert_equal expected_from_links, item.part_of
6161
end

test/presenters/content_item/withdrawable_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def content_item
7070
end
7171

7272
test "notice title presents only in English, even if locale is set to another language" do
73-
# This is to prevent the withdrawal notices on translated editions
74-
# displaying a combination of languages in their titles.
73+
# This is to prevent the withdrawal notices on translated editions
74+
# displaying a combination of languages in their titles.
7575
class << @withdrawable
7676
def schema_name
7777
"publication"

test/presenters/content_item_presenter_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ class ContentItemPresenterTest < ActiveSupport::TestCase
3636
test "available_translations sorts languages by locale with English first" do
3737
translated = govuk_content_schema_example("case_study", "translated")
3838
locales = ContentItemPresenter.new(translated).available_translations
39-
assert_equal %w(en ar es), (locales.map { |t| t[:locale] })
39+
assert_equal %w[en ar es], (locales.map { |t| t[:locale] })
4040
end
4141

4242
test "available_translations returns native locale names using native_language_name_for" do
4343
translated = govuk_content_schema_example("case_study", "translated")
4444
locales = ContentItemPresenter.new(translated).available_translations
4545

46-
assert_equal %w(English العربية Español), (locales.map { |t| t[:text] })
46+
assert_equal %w[English العربية Español], (locales.map { |t| t[:text] })
4747
end
4848

4949
test "part slug is nil when requesting a content item without parts" do

test/presenters/specialist_document_presenter_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,11 @@ def example_facet(overrides = {})
246246
],
247247
}
248248

249-
values = { "facet-key" => %w{one two} }
249+
values = { "facet-key" => %w[one two] }
250250
example = example_with_finder_facets([example_facet(overrides)], values)
251251

252252
presented = present_example(example)
253-
assert_equal %w{One Two}, presented.important_metadata["Facet name"]
253+
assert_equal %w[One Two], presented.important_metadata["Facet name"]
254254
end
255255

256256
test "creates links for filterable friendly values" do

test/presenters/travel_advice_presenter_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def schema_name
200200

201201
test "presents alert statuses" do
202202
example = schema_item("full-country")
203-
example["details"]["alert_status"] = %w{avoid_all_but_essential_travel_to_parts avoid_all_travel_to_parts}
203+
example["details"]["alert_status"] = %w[avoid_all_but_essential_travel_to_parts avoid_all_travel_to_parts]
204204
assert present_example(example).alert_status.include?("advise against all but essential travel")
205205
assert present_example(example).alert_status.include?("advise against all travel to parts")
206206
end

test/support/govuk_content_schema_examples.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def all_examples_for_supported_schemas
3535
end
3636

3737
def supported_schemas
38-
%w{
38+
%w[
3939
case_study
4040
coming_soon
4141
html_publication
@@ -45,7 +45,7 @@ def supported_schemas
4545
topical_event_about_page
4646
unpublishing
4747
working_group
48-
}
48+
]
4949
end
5050
end
5151
end

test/test_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def setup_and_visit_random_content_item(document_type: nil)
160160
.to_return(status: 200, body: content_item.to_json, headers: {})
161161
visit path
162162

163-
assert_selector %{meta[name="govuk:content-id"][content="#{content_id}"]}, visible: false
163+
assert_selector %(meta[name="govuk:content-id"][content="#{content_id}"]), visible: false
164164
end
165165

166166
def get_content_example(name)

0 commit comments

Comments
 (0)