Skip to content

Commit 1709949

Browse files
authored
Merge pull request #1760 from alphagov/dependabot/bundler/rubocop-govuk-3.10.0
2 parents 54dd1d4 + 0f9cf29 commit 1709949

27 files changed

+273
-149
lines changed

Gemfile.lock

+3-5
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ GEM
134134
concurrent-ruby (~> 1.0)
135135
image_size (2.0.2)
136136
io-like (0.3.0)
137-
jaro_winkler (1.5.4)
138137
jasmine-core (3.5.0)
139138
jasmine-rails (0.15.0)
140139
jasmine-core (>= 1.3, < 4.0)
@@ -250,16 +249,15 @@ GEM
250249
rexml (3.2.4)
251250
robotex (1.0.0)
252251
rouge (3.18.0)
253-
rubocop (0.82.0)
254-
jaro_winkler (~> 1.5.1)
252+
rubocop (0.83.0)
255253
parallel (~> 1.10)
256254
parser (>= 2.7.0.1)
257255
rainbow (>= 2.2.2, < 4.0)
258256
rexml
259257
ruby-progressbar (~> 1.7)
260258
unicode-display_width (>= 1.4.0, < 2.0)
261-
rubocop-govuk (3.9.0)
262-
rubocop (= 0.82.0)
259+
rubocop-govuk (3.10.0)
260+
rubocop (= 0.83.0)
263261
rubocop-rails (~> 2)
264262
rubocop-rake (~> 0.5.1)
265263
rubocop-rspec (~> 1.28)

app/controllers/content_items_controller.rb

+9-5
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ def load_content_item
6363
content_item["links"]["ordered_related_items"] = content_item["links"].fetch("suggested_ordered_related_items", [])
6464
end
6565

66-
@content_item = PresenterBuilder.new(content_item,
67-
content_item_path,
68-
view_context).presenter
66+
@content_item = PresenterBuilder.new(
67+
content_item,
68+
content_item_path,
69+
view_context,
70+
).presenter
6971
end
7072

7173
def format_banner_links(links, type)
@@ -125,8 +127,10 @@ def set_use_recommended_related_links_header
125127
end
126128

127129
def set_expiry
128-
expires_in(@content_item.cache_control_max_age(request.format),
129-
public: @content_item.cache_control_public?)
130+
expires_in(
131+
@content_item.cache_control_max_age(request.format),
132+
public: @content_item.cache_control_public?,
133+
)
130134
end
131135

132136
def service_url(original_url)

app/controllers/development_controller.rb

+24-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,30 @@ class DevelopmentController < ApplicationController
22
layout false
33

44
def index
5-
@schema_names = %w[answer case_study coming_soon consultation contact
6-
corporate_information_page detailed_guide document_collection
7-
fatality_notice guide help_page html_publication news_article
8-
placeholder_corporate_information_page publication service_sign_in specialist_document
9-
speech statistical_data_set statistics_announcement take_part
10-
topical_event_about_page travel_advice working_group
5+
@schema_names = %w[answer
6+
case_study
7+
coming_soon
8+
consultation
9+
contact
10+
corporate_information_page
11+
detailed_guide
12+
document_collection
13+
fatality_notice
14+
guide
15+
help_page
16+
html_publication
17+
news_article
18+
placeholder_corporate_information_page
19+
publication
20+
service_sign_in
21+
specialist_document
22+
speech
23+
statistical_data_set
24+
statistics_announcement
25+
take_part
26+
topical_event_about_page
27+
travel_advice
28+
working_group
1129
world_location_news_article]
1230

1331
@paths = YAML.load_file("test/wraith/config.yaml")["paths"]

app/presenters/content_item/corporate_information_groups.rb

+10-6
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,22 @@ def corporate_information?
99
def corporate_information
1010
corporate_information_groups.map do |group|
1111
{
12-
heading: view_context.content_tag(:h3,
13-
group["name"],
14-
id: group_title_id(group["name"])),
12+
heading: view_context.content_tag(
13+
:h3,
14+
group["name"],
15+
id: group_title_id(group["name"]),
16+
),
1517
links: normalised_group_links(group),
1618
}
1719
end
1820
end
1921

2022
def corporate_information_heading_tag
21-
view_context.content_tag(:h2,
22-
corporate_information_heading[:text],
23-
id: corporate_information_heading[:id])
23+
view_context.content_tag(
24+
:h2,
25+
corporate_information_heading[:text],
26+
id: corporate_information_heading[:id],
27+
)
2428
end
2529

2630
def further_information

app/presenters/content_item/national_applicability.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module NationalApplicability
33
include Metadata
44

55
def applies_to
6-
return nil if !national_applicability
6+
return nil unless national_applicability
77

88
all_nations = national_applicability.values
99
applicable_nations = all_nations.select { |n| n["applicable"] }

app/presenters/content_item/withdrawable.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ def withdrawal_notice_context
3333
end
3434

3535
def withdrawal_notice_time
36-
view_context.content_tag(:time,
37-
english_display_date(withdrawal_notice["withdrawn_at"]),
38-
datetime: withdrawal_notice["withdrawn_at"])
36+
view_context.content_tag(
37+
:time,
38+
english_display_date(withdrawal_notice["withdrawn_at"]),
39+
datetime: withdrawal_notice["withdrawn_at"],
40+
)
3941
end
4042

4143
def english_display_date(timestamp, format = "%-d %B %Y")

app/presenters/document_collection_presenter.rb

+11-7
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ def group_document_links(group, group_index)
4141
},
4242
metadata: {
4343
public_updated_at: link["public_updated_at"]&.then { |time| Time.zone.parse(time) },
44-
document_type: I18n.t("content_item.schema_name.#{link['document_type']}",
45-
count: 1,
46-
default: nil),
44+
document_type: I18n.t(
45+
"content_item.schema_name.#{link['document_type']}",
46+
count: 1,
47+
default: nil,
48+
),
4749
},
4850
}
4951
end
@@ -52,10 +54,12 @@ def group_document_links(group, group_index)
5254
def group_heading(group)
5355
title = group["title"]
5456
heading_level = show_contents_list? ? :h3 : :h2
55-
view_context.content_tag(heading_level,
56-
title,
57-
class: "group-title",
58-
id: group_title_id(title))
57+
view_context.content_tag(
58+
heading_level,
59+
title,
60+
class: "group-title",
61+
id: group_title_id(title),
62+
)
5963
end
6064

6165
private

app/presenters/specialist_document_presenter.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ def facet_block(facet, allowed_value)
170170

171171
def facet_link(label, value, key)
172172
finder_base_path = finder["base_path"]
173-
view_context.link_to(label,
174-
"#{finder_base_path}?#{key}%5B%5D=#{value}",
175-
class: "govuk-link app-link")
173+
view_context.link_to(
174+
label,
175+
"#{finder_base_path}?#{key}%5B%5D=#{value}",
176+
class: "govuk-link app-link",
177+
)
176178
end
177179

178180
def first_published_at_facet_key

app/services/presenter_builder.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ def presenter
1212
raise RedirectRouteReturned, content_item if redirect_route?
1313
raise GovernmentReturned if government_content_item?
1414

15-
presenter_name.constantize.new(content_item,
16-
content_item_path,
17-
view_context)
15+
presenter_name.constantize.new(
16+
content_item,
17+
content_item_path,
18+
view_context,
19+
)
1820
end
1921

2022
private

config/application.rb

+61-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,67 @@ class Application < Rails::Application
3030

3131
# Explicitly set available locales
3232
config.i18n.available_locales = [
33-
:en, :ar, :az, :be, :bg, :bn, :cs, :cy, :da, :de, :dr, :el,
34-
:es, "es-419", :et, :fa, :fi, :fr, :gd, :he, :hi, :hr, :hu,
35-
:hy, :id, :is, :it, :ja, :ka, :kk, :ko, :lt, :lv, :ms, :mt,
36-
:no, :nl, :pl, :ps, :pt, :ro, :ru, :si, :sk, :sl, :so, :sq,
37-
:sr, :sv, :sw, :ta, :th, :tk, :tr, :uk, :ur, :uz, :vi, :zh,
38-
"zh-hk", "zh-tw"
33+
:en,
34+
:ar,
35+
:az,
36+
:be,
37+
:bg,
38+
:bn,
39+
:cs,
40+
:cy,
41+
:da,
42+
:de,
43+
:dr,
44+
:el,
45+
:es,
46+
"es-419",
47+
:et,
48+
:fa,
49+
:fi,
50+
:fr,
51+
:gd,
52+
:he,
53+
:hi,
54+
:hr,
55+
:hu,
56+
:hy,
57+
:id,
58+
:is,
59+
:it,
60+
:ja,
61+
:ka,
62+
:kk,
63+
:ko,
64+
:lt,
65+
:lv,
66+
:ms,
67+
:mt,
68+
:no,
69+
:nl,
70+
:pl,
71+
:ps,
72+
:pt,
73+
:ro,
74+
:ru,
75+
:si,
76+
:sk,
77+
:sl,
78+
:so,
79+
:sq,
80+
:sr,
81+
:sv,
82+
:sw,
83+
:ta,
84+
:th,
85+
:tk,
86+
:tr,
87+
:uk,
88+
:ur,
89+
:uz,
90+
:vi,
91+
:zh,
92+
"zh-hk",
93+
"zh-tw",
3994
]
4095

4196
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to

lib/helpers/document_types_helper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ def initialize(sample_size = 10)
99
end
1010

1111
def all_type_paths
12-
response = RestClient.get(format(ALL_SEARCH_ENDPOINT, sample_size: @sample_size))
12+
response = RestClient.get(sprintf(ALL_SEARCH_ENDPOINT, sample_size: @sample_size))
1313
results = extract_results(JSON.parse(response.body))
1414
results.map { |result| extract_type(result) }.reduce({}, :merge)
1515
end
1616

1717
def type_paths(type)
18-
response = RestClient.get(format(SINGLE_SEARCH_ENDPOINT, document_type: type, sample_size: @sample_size))
18+
response = RestClient.get(sprintf(SINGLE_SEARCH_ENDPOINT, document_type: type, sample_size: @sample_size))
1919
JSON.parse(response.body)["results"].map { |result| result["link"] }
2020
end
2121

lib/helpers/wraith_config_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def path_index(prefix, index)
4444
end
4545

4646
def write_config(config)
47-
file_name = format(OUTPUT_PATH, suffix: @name)
47+
file_name = sprintf(OUTPUT_PATH, suffix: @name)
4848
File.open(file_name, "w") { |f| f.write config.to_yaml }
4949
file_name
5050
end

test/components/banner_test.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ def component_name
3232
end
3333

3434
test "renders a banner with title, text and aside correctly" do
35-
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")
35+
render_component(
36+
title: "Summary",
37+
text: "This was published under the 2010 to 2015 Conservative government",
38+
aside: "This consultation ran from 9:30am on 30 January 2017 to 5pm on 28 February 2017",
39+
)
3840

3941
assert_select ".app-c-banner--aside"
4042
assert_select ".app-c-banner__title", text: "Summary"

test/components/published_dates_test.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def component_name
1616

1717
test "renders published date and last updated date" do
1818
render_component(published: "1st November 2000", last_updated: "15th July 2015")
19-
assert_select ".app-c-published-dates", text: "Published 1st November 2000
19+
assert_select ".app-c-published-dates",
20+
text: "Published 1st November 2000
2021
Last updated 15th July 2015"
2122
end
2223

test/controllers/content_items_controller_test.rb

+12-9
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ class ContentItemsControllerTest < ActionController::TestCase
9090
request.headers["Accept"] = "*/*"
9191
content_item = content_store_has_schema_example("travel_advice", "full-country")
9292

93-
get :show, params: {
94-
path: path_for(content_item),
95-
}
93+
get :show,
94+
params: {
95+
path: path_for(content_item),
96+
}
9697

9798
assert_match(/text\/html/, response.headers["Content-Type"])
9899
assert_response :success
@@ -103,9 +104,10 @@ class ContentItemsControllerTest < ActionController::TestCase
103104
request.headers["X-Requested-With"] = "XMLHttpRequest"
104105
content_item = content_store_has_schema_example("case_study", "case_study")
105106

106-
get :show, params: {
107-
path: path_for(content_item),
108-
}
107+
get :show,
108+
params: {
109+
path: path_for(content_item),
110+
}
109111

110112
assert_response :not_acceptable
111113
end
@@ -114,9 +116,10 @@ class ContentItemsControllerTest < ActionController::TestCase
114116
request.headers["Accept"] = "text/javascript"
115117
content_item = content_store_has_schema_example("case_study", "case_study")
116118

117-
get :show, params: {
118-
path: path_for(content_item),
119-
}
119+
get :show,
120+
params: {
121+
path: path_for(content_item),
122+
}
120123

121124
assert_response :not_acceptable
122125
end

test/integration/specialist_document_test.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ def assert_nested_content_item(heading)
173173
test "renders a link to statutory instruments finder" do
174174
setup_and_visit_content_item("eu-withdrawal-act-2018-statutory-instruments")
175175

176-
assert page.has_css?("a[href='/eu-withdrawal-act-2018-statutory-instruments']",
177-
text: "See all EU Withdrawal Act 2018 statutory instruments")
176+
assert page.has_css?(
177+
"a[href='/eu-withdrawal-act-2018-statutory-instruments']",
178+
text: "See all EU Withdrawal Act 2018 statutory instruments",
179+
)
178180
end
179181
end

test/presenter_test_helper.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ def presented_item(type = schema_name, overrides = {})
1818
end
1919

2020
def present_example(example)
21-
create_presenter("#{schema_name.classify}Presenter".safe_constantize,
22-
content_item: example)
21+
create_presenter(
22+
"#{schema_name.classify}Presenter".safe_constantize,
23+
content_item: example,
24+
)
2325
end
2426

2527
def schema_item(type = schema_name)

0 commit comments

Comments
 (0)