Skip to content

Commit

Permalink
bundle exec rubocop -A
Browse files Browse the repository at this point in the history
  • Loading branch information
1pretz1 committed Oct 2, 2023
1 parent 538984b commit 5e77179
Show file tree
Hide file tree
Showing 32 changed files with 125 additions and 127 deletions.
8 changes: 4 additions & 4 deletions app/models/govuk_publishing_components/audit_applications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ def initialize(path, name, dir)
end

@data = {
name: name,
dir: dir,
application_found: application_found,
components_found: components_found,
name:,
dir:,
application_found:,
components_found:,
gem_style_references: @gem_style_references.flatten.uniq.sort,
jquery_references: @jquery_references.flatten.uniq.sort,
component_locations: @component_locations,
Expand Down
10 changes: 5 additions & 5 deletions app/models/govuk_publishing_components/audit_comparer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def sort_results(results)
dir: result[:dir],
application_found: result[:application_found],
uses_static: application_uses_static,
summary: summary,
warnings: warnings,
summary:,
warnings:,
warning_count: warnings.length,
gem_style_references: result[:gem_style_references],
jquery_references: result[:jquery_references],
Expand Down Expand Up @@ -126,8 +126,8 @@ def include_any_components_within_components(components)

def create_warning(component, message)
{
component: component,
message: message,
component:,
message:,
}
end

Expand Down Expand Up @@ -280,7 +280,7 @@ def get_components_by_application
results << {
name: component_name,
count: locations.length,
locations: locations,
locations:,
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class SupportedContentType
def self.find(content_type, extension = nil)
matching_types = TYPES.select { |type| type[:content_type] == content_type }

return UnsupportedContentType.new(content_type: content_type) if matching_types.empty?
return UnsupportedContentType.new(content_type:) if matching_types.empty?

extension_match = if matching_types.length > 1
matching_types.find { |type| type[:extension] == extension }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def checkbox_markup(checkbox, index)
data[:behaviour] = "exclusive" if checkbox[:exclusive]

capture do
concat check_box_tag checkbox_name, checkbox[:value], checked, class: "govuk-checkboxes__input", id: checkbox_id, data: data
concat check_box_tag(checkbox_name, checkbox[:value], checked, class: "govuk-checkboxes__input", id: checkbox_id, data:)
concat content_tag(:label, checkbox[:label], for: checkbox_id, class: "govuk-label govuk-checkboxes__label")
concat content_tag(:span, checkbox[:hint], id: "#{checkbox_id}-item-hint", class: "govuk-hint govuk-checkboxes__hint") if checkbox[:hint]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/govuk_publishing_components/presenters/content_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def external_links

def as_taxonomy_sidebar_link
{
title: title,
title:,
link: base_path,
}
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require "set"

module GovukPublishingComponents
module Presenters
# @private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def alternative_content_text(name)
nation = I18n.t("components.devolved_nations.#{name}")

if I18n.exists?("components.devolved_nations.type.#{@type}")
I18n.t("components.devolved_nations.type.#{@type}", nation: nation)
I18n.t("components.devolved_nations.type.#{@type}", nation:)
else
I18n.t("components.devolved_nations.type.publication", nation: nation)
I18n.t("components.devolved_nations.type.publication", nation:)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def header(ga4_tracking)
title: current_step_nav.title,
path: current_step_nav.base_path,
tracking_id: current_step_nav.content_id,
ga4_tracking: ga4_tracking,
ga4_tracking:,
}
else
{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def blue_bar_background_colours
def generate_data_attribute(link, track_action)
{
track_category: "footerClicked",
track_action: track_action,
track_action:,
track_label: link[:href],
track_options: {
dimension29: link[:text],
Expand Down
2 changes: 1 addition & 1 deletion spec/components/attachment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def component_name
isbn: "978-1-5286-1173-2",
unique_reference: "2259",
command_paper_number: "Cd. 67",
thumbnail_url: thumbnail_url,
thumbnail_url:,
},
)
assert_thumbnail "custom", src: thumbnail_url
Expand Down
4 changes: 2 additions & 2 deletions spec/components/breadcrumbs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def component_name
end

def assert_link_with_text_in(selector, link, text)
assert_select "#{selector} a[href=\"#{link}\"]", text: text
assert_select "#{selector} a[href=\"#{link}\"]", text:
end

it "no error if no parameters passed in" do
Expand Down Expand Up @@ -110,7 +110,7 @@ def assert_link_with_text_in(selector, link, text)
{ title: "Section 2", url: "/section-2" },
{ title: "Section 3", url: "/section-3" },
]
render_component(breadcrumbs: breadcrumbs)
render_component(breadcrumbs:)

expected_tracking_options = [
{ dimension28: "3", dimension29: "Section 1" },
Expand Down
26 changes: 13 additions & 13 deletions spec/components/contextual_breadcrumbs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def component_name
end

def example_document_for(schema_name, example_name)
GovukSchemas::Example.find(schema_name, example_name: example_name)
GovukSchemas::Example.find(schema_name, example_name:)
end

def remove_mainstream_browse(content_item)
Expand Down Expand Up @@ -41,7 +41,7 @@ def set_live_taxons(content_item)
content_item = remove_mainstream_browse(content_item)
content_item = remove_curated_related_item(content_item)
content_item = set_live_taxons(content_item)
render_component(content_item: content_item)
render_component(content_item:)
assert_select ".gem-c-breadcrumbs.govuk-breadcrumbs--collapse-on-mobile"
end

Expand All @@ -50,7 +50,7 @@ def set_live_taxons(content_item)
content_item = remove_mainstream_browse(content_item)
content_item = remove_curated_related_item(content_item)
content_item = set_live_taxons(content_item)
render_component(content_item: content_item, collapse_on_mobile: false)
render_component(content_item:, collapse_on_mobile: false)
assert_select ".gem-c-breadcrumbs.gem-c-breadcrumbs--collapse-on-mobile", false
end

Expand All @@ -76,7 +76,7 @@ def set_live_taxons(content_item)
it "renders curated related items breadcrumbs if the content_item has curated related items" do
content_item = example_document_for("licence", "licence_without_continuation_link")
content_item = remove_mainstream_browse(content_item)
render_component(content_item: content_item)
render_component(content_item:)
assert_no_selector(".gem-c-step-nav-header")
assert_select "a", text: "Home"
assert_select "a", text: "Business and self-employed"
Expand All @@ -89,7 +89,7 @@ def set_live_taxons(content_item)
content_item = remove_curated_related_item(content_item)
content_item = set_live_taxons(content_item)
content_item = remove_topics(content_item)
render_component(content_item: content_item)
render_component(content_item:)
assert_no_selector(".gem-c-step-nav-header")
assert_select "a", text: "Home"
assert_select "a", text: "School curriculum"
Expand All @@ -101,7 +101,7 @@ def set_live_taxons(content_item)
content_item = remove_mainstream_browse(content_item)
content_item = remove_curated_related_item(content_item)
content_item = set_live_taxons(content_item)
render_component(content_item: content_item, inverse: true)
render_component(content_item:, inverse: true)
assert_select ".gem-c-breadcrumbs.gem-c-breadcrumbs--inverse"
end

Expand Down Expand Up @@ -136,31 +136,31 @@ def set_live_taxons(content_item)
},
]

render_component(content_item: content_item)
render_component(content_item:)

assert_select "a", text: "Home"
assert_select "a", text: "Competition and Markets Authority cases"
end

it "renders parent finder breadcrumb if content has a finder linked" do
content_item = example_document_for("guide", "guide-with-facet-groups")
render_component(content_item: content_item)
render_component(content_item:)

assert_select "a", text: "Home"
assert_select "a", text: "EU Withdrawal Act 2018 statutory instruments"
end

it "renders parent finder breadcrumb if content has a finder linked and taxon is prioritised" do
content_item = example_document_for("guide", "guide-with-facet-groups")
render_component(content_item: content_item, prioritise_taxon_breadcrumbs: true)
render_component(content_item:, prioritise_taxon_breadcrumbs: true)

assert_select "a", text: "Home"
assert_select "a", text: "EU Withdrawal Act 2018 statutory instruments"
end

it "renders inverse parent finder breadcrumb" do
content_item = example_document_for("guide", "guide-with-facet-groups")
render_component(content_item: content_item, prioritise_taxon_breadcrumbs: true, inverse: true)
render_component(content_item:, prioritise_taxon_breadcrumbs: true, inverse: true)
assert_select ".gem-c-breadcrumbs.gem-c-breadcrumbs--inverse"
end

Expand All @@ -177,7 +177,7 @@ def set_live_taxons(content_item)
content_item = example_document_for("guide", "guide")
content_item = set_parent_titles_to_businesses(content_item)
content_item = set_live_taxons(content_item)
render_component(content_item: content_item, prioritise_taxon_breadcrumbs: true)
render_component(content_item:, prioritise_taxon_breadcrumbs: true)
assert_select "a", text: "Home"
assert_no_selector "a", text: "Business and self-employed"
assert_no_selector "a", text: "Licences and licence applications"
Expand All @@ -189,7 +189,7 @@ def set_live_taxons(content_item)
content_item = example_document_for("guide", "guide")
content_item = set_parent_titles_to_businesses(content_item)
content_item = set_live_taxons(content_item)
render_component(content_item: content_item, prioritise_taxon_breadcrumbs: false)
render_component(content_item:, prioritise_taxon_breadcrumbs: false)
assert_select "a", text: "Home"
assert_select "a", text: "Business and self-employed"
assert_select "a", text: "Licences and licence applications"
Expand All @@ -201,7 +201,7 @@ def set_live_taxons(content_item)
content_item = example_document_for("guide", "guide")
content_item = set_parent_titles_to_businesses(content_item)
content_item = set_live_taxons(content_item)
render_component(content_item: content_item)
render_component(content_item:)
assert_select "a", text: "Home"
assert_select "a", text: "Business and self-employed"
assert_select "a", text: "Licences and licence applications"
Expand Down
4 changes: 2 additions & 2 deletions spec/components/contextual_footer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def component_name
payload
end

render_component(content_item: content_item)
render_component(content_item:)

has_selector? ".gem-c-contextual-footer"
end
Expand Down Expand Up @@ -45,7 +45,7 @@ def component_name
],
}

render_component(content_item: content_item, ga4_tracking: true)
render_component(content_item:, ga4_tracking: true)

assert_select ".gem-c-related-navigation[data-module='gem-track-click ga4-link-tracker']"
assert_select ".gem-c-related-navigation__section-link[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"contextual footer\",\"index\":{\"index_section\":\"1\",\"index_link\":\"1\",\"index_section_count\":\"1\"},\"index_total\":\"2\",\"section\":\"Explore the topic\"}']", text: "Skating"
Expand Down
2 changes: 1 addition & 1 deletion spec/components/contextual_sidebar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def component_name

render_component(
ga4_tracking: true,
content_item: content_item,
content_item:,
)
index_total = 4 # have to hard code this here but if ukraine links change this number may change, and test will fail
assert_select ".gem-c-contextual-sidebar .gem-c-contextual-sidebar__cta--ukraine[data-module='gem-track-click ga4-link-tracker']"
Expand Down
6 changes: 3 additions & 3 deletions spec/components/layout_header_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def component_name
{ text: "Hello", href: "/hello", show_only_in_collapsed_menu: true },
]

render_component(environment: "staging", navigation_items: navigation_items)
render_component(environment: "staging", navigation_items:)

assert_select ".govuk-header__navigation .govuk-header__menu-button", text: "Menu"
assert_select ".govuk-header__navigation-item.govuk-header__navigation-item--active", text: "Foo"
Expand All @@ -72,7 +72,7 @@ def component_name
{ text: "Hello", href: "/hello", show_only_in_collapsed_menu: true },
]

render_component(environment: "staging", navigation_items: navigation_items, navigation_aria_label: "My fancy label")
render_component(environment: "staging", navigation_items:, navigation_aria_label: "My fancy label")

assert_select ".gem-c-header__nav[aria-label='My fancy label']"
end
Expand All @@ -95,7 +95,7 @@ def component_name
},
]

render_component(navigation_items: navigation_items)
render_component(navigation_items:)

assert_select ".gem-c-header__nav .govuk-header__link[data-hello='world']", text: "Foo"
assert_select ".gem-c-header__nav .govuk-header__link[data-more-than-one-word='test']", text: "Bar"
Expand Down
2 changes: 1 addition & 1 deletion spec/components/lead_paragraph_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def component_name
end

def assert_lead_paragraph_matches(text, expected_text)
render_component(text: text)
render_component(text:)
assert_select ".gem-c-lead-paragraph", text: expected_text
end

Expand Down
8 changes: 4 additions & 4 deletions spec/components/meta_tags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def component_name
end

def example_document_for(schema_name, example_name)
GovukSchemas::Example.find(schema_name, example_name: example_name)
GovukSchemas::Example.find(schema_name, example_name:)
end

it "renders with an example case study" do
Expand Down Expand Up @@ -49,7 +49,7 @@ def example_document_for(schema_name, example_name)
},
}

render_component(content_item: content_item)
render_component(content_item:)
assert_meta_tag("govuk:analytics:organisations", "<O1><W4>")
end

Expand All @@ -67,7 +67,7 @@ def example_document_for(schema_name, example_name)
},
}

render_component(content_item: content_item)
render_component(content_item:)
assert_meta_tag("govuk:analytics:world-locations", "<WL3><WL123>")
end

Expand Down Expand Up @@ -448,7 +448,7 @@ def example_document_for(schema_name, example_name)
end

def assert_political_status_for(political, current, expected_political_status)
render_component(content_item: { details: { political: political, government: { current: current, slug: "government" } } })
render_component(content_item: { details: { political:, government: { current:, slug: "government" } } })
assert_meta_tag("govuk:political-status", expected_political_status)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/components/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,6 @@ def assert_definition(term, definition)
end

def assert_link_with_text_in(selector, link, text)
assert_select "#{selector} a[href=\"#{link}\"]", text: text
assert_select "#{selector} a[href=\"#{link}\"]", text:
end
end
4 changes: 2 additions & 2 deletions spec/components/organisation_logo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def component_name
},
}

render_component(organisation: { url: "/some-link", data_attributes: data_attributes })
render_component(organisation: { url: "/some-link", data_attributes: })

assert_select ".gem-c-organisation-logo[data-module='gem-track-click']"
assert_select ".gem-c-organisation-logo a.gem-c-organisation-logo__container.gem-c-organisation-logo__link[data-track-category='someLinkClicked']"
Expand All @@ -67,7 +67,7 @@ def component_name
track_category: "someLinkClicked",
}

render_component(organisation: { data_attributes: data_attributes })
render_component(organisation: { data_attributes: })
assert_select ".gem-c-organisation-logo a.gem-c-organisation-logo__container.gem-c-organisation-logo__link[data-track-category='someLinkClicked']", false
end

Expand Down
Loading

0 comments on commit 5e77179

Please sign in to comment.