From 871fa020a5ca9e57d2706691ae7be4f9d7f0fc89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 28 Sep 2019 23:02:02 +0200 Subject: [PATCH] Add and apply ParenthesesAsGroupedExpression rule --- .rubocop_basic.yml | 3 + .../microsoft/available_locales.rb | 4 +- spec/features/admin/dashboard/actions_spec.rb | 2 +- .../admin/legislation/processes_spec.rb | 12 +-- spec/features/admin/widgets/cards_spec.rb | 4 +- spec/lib/remote_census_api_spec.rb | 98 +++++++++---------- spec/models/budget/phase_spec.rb | 2 +- spec/models/budget_spec.rb | 8 +- spec/models/concerns/sluggable.rb | 2 +- 9 files changed, 69 insertions(+), 66 deletions(-) diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index 71f369571..4cb8f19bc 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -126,6 +126,9 @@ Lint/DuplicateMethods: Lint/LiteralAsCondition: Enabled: true +Lint/ParenthesesAsGroupedExpression: + Enabled: true + Lint/ShadowingOuterLocalVariable: Enabled: true diff --git a/lib/remote_translations/microsoft/available_locales.rb b/lib/remote_translations/microsoft/available_locales.rb index 6afbd910d..bb46b723f 100644 --- a/lib/remote_translations/microsoft/available_locales.rb +++ b/lib/remote_translations/microsoft/available_locales.rb @@ -34,13 +34,13 @@ class RemoteTranslations::Microsoft::AvailableLocales host = "https://api.cognitive.microsofttranslator.com" path = "/languages?api-version=3.0" - uri = URI (host + path) + uri = URI(host + path) request = Net::HTTP::Get.new(uri) request["Ocp-Apim-Subscription-Key"] = Rails.application.secrets.microsoft_api_key response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == "https") do |http| - http.request (request) + http.request(request) end result = response.body.force_encoding("utf-8") diff --git a/spec/features/admin/dashboard/actions_spec.rb b/spec/features/admin/dashboard/actions_spec.rb index e49bb4481..2aa1aee23 100644 --- a/spec/features/admin/dashboard/actions_spec.rb +++ b/spec/features/admin/dashboard/actions_spec.rb @@ -73,7 +73,7 @@ describe "Admin dashboard actions" do before do visit admin_dashboard_actions_path - within ("#dashboard_action_#{action.id}") do + within "#dashboard_action_#{action.id}" do click_link "Edit" end end diff --git a/spec/features/admin/legislation/processes_spec.rb b/spec/features/admin/legislation/processes_spec.rb index f2eea400b..f75b1bfb9 100644 --- a/spec/features/admin/legislation/processes_spec.rb +++ b/spec/features/admin/legislation/processes_spec.rb @@ -51,13 +51,13 @@ describe "Admin collaborative legislation" do visit admin_legislation_processes_path(filter: "all") - expect(page).to have_content (process_1.start_date) - expect(page).to have_content (process_2.start_date) - expect(page).to have_content (process_3.start_date) + expect(page).to have_content process_1.start_date + expect(page).to have_content process_2.start_date + expect(page).to have_content process_3.start_date - expect(page).to have_content (process_1.end_date) - expect(page).to have_content (process_2.end_date) - expect(page).to have_content (process_3.end_date) + expect(page).to have_content process_1.end_date + expect(page).to have_content process_2.end_date + expect(page).to have_content process_3.end_date expect(process_3.title).to appear_before(process_2.title) expect(process_2.title).to appear_before(process_1.title) diff --git a/spec/features/admin/widgets/cards_spec.rb b/spec/features/admin/widgets/cards_spec.rb index bed7e28ef..cafd94fa2 100644 --- a/spec/features/admin/widgets/cards_spec.rb +++ b/spec/features/admin/widgets/cards_spec.rb @@ -161,7 +161,7 @@ describe "Cards" do card_2 = create(:widget_card, page: custom_page, title: "Card medium", columns: 4) card_3 = create(:widget_card, page: custom_page, title: "Card small", columns: 2) - visit (custom_page).url + visit custom_page.url expect(page).to have_css(".card", count: 3) @@ -174,7 +174,7 @@ describe "Cards" do card_1 = create(:widget_card, page: custom_page, title: "Card one", label: "My label") card_2 = create(:widget_card, page: custom_page, title: "Card two") - visit (custom_page).url + visit custom_page.url within("#widget_card_#{card_1.id}") do expect(page).to have_selector("span", text: "My label") diff --git a/spec/lib/remote_census_api_spec.rb b/spec/lib/remote_census_api_spec.rb index 1f6c94283..5a5fe748a 100644 --- a/spec/lib/remote_census_api_spec.rb +++ b/spec/lib/remote_census_api_spec.rb @@ -86,15 +86,15 @@ describe RemoteCensusApi do request = RemoteCensusApi.new.send(:request, document_type, document_number, nil, nil) - expect(request).to eq ({ :request => - { :codigo_institucion => 1, - :codigo_portal => 1, - :codigo_usuario => 1, - :documento => "0123456", - :tipo_documento => "1", - :codigo_idioma => "102", - :nivel => "3" } - }) + expect(request).to eq({ :request => + { :codigo_institucion => 1, + :codigo_portal => 1, + :codigo_usuario => 1, + :documento => "0123456", + :tipo_documento => "1", + :codigo_idioma => "102", + :nivel => "3" } + }) end it "when send date_of_birth and postal_code but are not configured" do @@ -105,15 +105,15 @@ describe RemoteCensusApi do request = RemoteCensusApi.new.send(:request, document_type, document_number, date_of_birth, postal_code) - expect(request).to eq ({ :request => - { :codigo_institucion => 1, - :codigo_portal => 1, - :codigo_usuario => 1, - :documento => "0123456", - :tipo_documento => "1", - :codigo_idioma => "102", - :nivel => "3" } - }) + expect(request).to eq({ :request => + { :codigo_institucion => 1, + :codigo_portal => 1, + :codigo_usuario => 1, + :documento => "0123456", + :tipo_documento => "1", + :codigo_idioma => "102", + :nivel => "3" } + }) end it "when send date_of_birth and postal_code but are configured" do @@ -137,17 +137,17 @@ describe RemoteCensusApi do request = RemoteCensusApi.new.send(:request, document_type, document_number, date_of_birth, postal_code) - expect(request).to eq ({ :request => - { :codigo_institucion => 1, - :codigo_portal => 1, - :codigo_usuario => 1, - :documento => "0123456", - :tipo_documento => "1", - :fecha_nacimiento => "1980-01-01", - :codigo_postal => "28001", - :codigo_idioma => "102", - :nivel => "3" } - }) + expect(request).to eq({ :request => + { :codigo_institucion => 1, + :codigo_portal => 1, + :codigo_usuario => 1, + :documento => "0123456", + :tipo_documento => "1", + :fecha_nacimiento => "1980-01-01", + :codigo_postal => "28001", + :codigo_idioma => "102", + :nivel => "3" } + }) end end @@ -164,26 +164,26 @@ describe RemoteCensusApi do response = RemoteCensusApi.new.send(:get_response_body, document_type, document_number, nil, nil) - expect(response).to eq ({ get_habita_datos_response: { - get_habita_datos_return: { - datos_habitante: { - item: { - fecha_nacimiento_string: "31-12-1980", - identificador_documento: "12345678Z", - descripcion_sexo: "Varón", - nombre: "José", - apellido1: "García" - } - }, - datos_vivienda: { - item: { - codigo_postal: "28013", - codigo_distrito: "01" - } - } - } - } - }) + expect(response).to eq({ get_habita_datos_response: { + get_habita_datos_return: { + datos_habitante: { + item: { + fecha_nacimiento_string: "31-12-1980", + identificador_documento: "12345678Z", + descripcion_sexo: "Varón", + nombre: "José", + apellido1: "García" + } + }, + datos_vivienda: { + item: { + codigo_postal: "28013", + codigo_distrito: "01" + } + } + } + } + }) end end diff --git a/spec/models/budget/phase_spec.rb b/spec/models/budget/phase_spec.rb index 0dc52e170..a54634724 100644 --- a/spec/models/budget/phase_spec.rb +++ b/spec/models/budget/phase_spec.rb @@ -171,7 +171,7 @@ describe Budget::Phase do second_phase.update_attributes(enabled: false, starts_at: Date.current, ends_at: Date.current + 2.days) - end.not_to (change { prev_enabled_phase.ends_at }) + end.not_to change { prev_enabled_phase.ends_at } end it "adjusts next enabled phase start date to its own start date" do diff --git a/spec/models/budget_spec.rb b/spec/models/budget_spec.rb index 55cf323a3..4859621f5 100644 --- a/spec/models/budget_spec.rb +++ b/spec/models/budget_spec.rb @@ -277,28 +277,28 @@ describe Budget do budget.update(currency_symbol: "€") I18n.locale = :es - expect(budget.formatted_amount(1000.00)).to eq ("1.000 €") + expect(budget.formatted_amount(1000.00)).to eq "1.000 €" end it "correctly formats Dollars with Spanish" do budget.update(currency_symbol: "$") I18n.locale = :es - expect(budget.formatted_amount(1000.00)).to eq ("1.000 $") + expect(budget.formatted_amount(1000.00)).to eq "1.000 $" end it "correctly formats Dollars with English" do budget.update(currency_symbol: "$") I18n.locale = :en - expect(budget.formatted_amount(1000.00)).to eq ("$1,000") + expect(budget.formatted_amount(1000.00)).to eq "$1,000" end it "correctly formats Euros with English" do budget.update(currency_symbol: "€") I18n.locale = :en - expect(budget.formatted_amount(1000.00)).to eq ("€1,000") + expect(budget.formatted_amount(1000.00)).to eq "€1,000" end end diff --git a/spec/models/concerns/sluggable.rb b/spec/models/concerns/sluggable.rb index 71cce4779..bb5896f20 100644 --- a/spec/models/concerns/sluggable.rb +++ b/spec/models/concerns/sluggable.rb @@ -23,7 +23,7 @@ shared_examples_for "sluggable" do |updatable_slug_trait:| context "slug updating condition is false" do it "slug isn't updated" do expect { sluggable.update_attributes(name: "New Name") } - .not_to (change { sluggable.slug }) + .not_to change { sluggable.slug } end end end