diff --git a/.rubocop.yml b/.rubocop.yml index 10eb93318..c48d754f1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -252,7 +252,8 @@ Layout/SpaceInsideHashLiteralBraces: Enabled: true Layout/SpaceInsideArrayLiteralBrackets: - Enabled: false + Enabled: true + EnforcedStyle: no_space Layout/SpaceInsideParens: Enabled: true diff --git a/app/models/champ.rb b/app/models/champ.rb index 7771007c6..1a9a98241 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -36,7 +36,7 @@ class Champ < ApplicationRecord end def search_terms - [ to_s ] + [to_s] end def to_s diff --git a/app/models/champs/checkbox_champ.rb b/app/models/champs/checkbox_champ.rb index 9202ca635..8261743f3 100644 --- a/app/models/champs/checkbox_champ.rb +++ b/app/models/champs/checkbox_champ.rb @@ -1,7 +1,7 @@ class Champs::CheckboxChamp < Champ def search_terms if value == 'on' - [ libelle ] + [libelle] end end diff --git a/app/models/champs/engagement_champ.rb b/app/models/champs/engagement_champ.rb index efd968c5e..c3173e69e 100644 --- a/app/models/champs/engagement_champ.rb +++ b/app/models/champs/engagement_champ.rb @@ -1,7 +1,7 @@ class Champs::EngagementChamp < Champs::CheckboxChamp def search_terms if value == 'on' - [ libelle ] + [libelle] end end end diff --git a/app/models/champs/linked_drop_down_list_champ.rb b/app/models/champs/linked_drop_down_list_champ.rb index f965a472c..db12156a0 100644 --- a/app/models/champs/linked_drop_down_list_champ.rb +++ b/app/models/champs/linked_drop_down_list_champ.rb @@ -38,7 +38,7 @@ class Champs::LinkedDropDownListChamp < Champ end def search_terms - [ primary_value, secondary_value ] + [primary_value, secondary_value] end private @@ -52,6 +52,6 @@ class Champs::LinkedDropDownListChamp < Champ end def pack_value(primary, secondary) - self.value = JSON.generate([ primary, secondary ]) + self.value = JSON.generate([primary, secondary]) end end diff --git a/app/models/champs/siret_champ.rb b/app/models/champs/siret_champ.rb index b36e3c1ba..c2eb139b5 100644 --- a/app/models/champs/siret_champ.rb +++ b/app/models/champs/siret_champ.rb @@ -40,6 +40,6 @@ class Champs::SiretChamp < Champ accepts_nested_attributes_for :etablissement, allow_destroy: true, update_only: true def search_terms - etablissement.present? ? etablissement.search_terms : [ value ] + etablissement.present? ? etablissement.search_terms : [value] end end diff --git a/app/models/champs/yes_no_champ.rb b/app/models/champs/yes_no_champ.rb index 27ead824a..7c29930fb 100644 --- a/app/models/champs/yes_no_champ.rb +++ b/app/models/champs/yes_no_champ.rb @@ -1,7 +1,7 @@ class Champs::YesNoChamp < Champs::CheckboxChamp def search_terms if value == 'true' - [ libelle ] + [libelle] end end diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb index d06e1ece6..abcda68bf 100644 --- a/app/models/procedure_presentation.rb +++ b/app/models/procedure_presentation.rb @@ -215,7 +215,7 @@ class ProcedurePresentation < ApplicationRecord def valid_columns_for_table(table) @column_whitelist ||= fields .group_by { |field| field['table'] } - .map { |table, fields| [table, Set.new(fields.map { |field| field['column'] }) ] } + .map { |table, fields| [table, Set.new(fields.map { |field| field['column'] })] } .to_h @column_whitelist[table] || [] diff --git a/db/migrate/20180130180754_create_active_storage_tables.active_storage.rb b/db/migrate/20180130180754_create_active_storage_tables.active_storage.rb index 360e0d1b7..a3b996c1e 100644 --- a/db/migrate/20180130180754_create_active_storage_tables.active_storage.rb +++ b/db/migrate/20180130180754_create_active_storage_tables.active_storage.rb @@ -10,7 +10,7 @@ class CreateActiveStorageTables < ActiveRecord::Migration[5.2] t.string :checksum, null: false t.datetime :created_at, null: false - t.index [ :key ], unique: true + t.index [:key], unique: true end create_table :active_storage_attachments do |t| @@ -20,7 +20,7 @@ class CreateActiveStorageTables < ActiveRecord::Migration[5.2] t.datetime :created_at, null: false - t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true + t.index [:record_type, :record_id, :name, :blob_id], name: "index_active_storage_attachments_uniqueness", unique: true end end end diff --git a/spec/helpers/conservation_de_donnees_helper_spec.rb b/spec/helpers/conservation_de_donnees_helper_spec.rb index e15a59e56..8edacefe9 100644 --- a/spec/helpers/conservation_de_donnees_helper_spec.rb +++ b/spec/helpers/conservation_de_donnees_helper_spec.rb @@ -10,21 +10,21 @@ RSpec.describe ConservationDeDonneesHelper, type: :helper do let(:dans_ds) { 3 } let(:hors_ds) { 6 } - it { is_expected.to eq([ "Dans demarches-simplifiees.fr : 3 mois", "Par l’administration : 6 mois" ]) } + it { is_expected.to eq(["Dans demarches-simplifiees.fr : 3 mois", "Par l’administration : 6 mois"]) } end context "when only in-app retention time is set" do let(:dans_ds) { 3 } let(:hors_ds) { nil } - it { is_expected.to eq([ "Dans demarches-simplifiees.fr : 3 mois" ]) } + it { is_expected.to eq(["Dans demarches-simplifiees.fr : 3 mois"]) } end context "when only out of app retention time is set" do let(:dans_ds) { nil } let(:hors_ds) { 6 } - it { is_expected.to eq([ "Par l’administration : 6 mois" ]) } + it { is_expected.to eq(["Par l’administration : 6 mois"]) } end context "when the retention time is not set" do diff --git a/spec/models/champ_spec.rb b/spec/models/champ_spec.rb index 461aa4fdb..e2c80d524 100644 --- a/spec/models/champ_spec.rb +++ b/spec/models/champ_spec.rb @@ -128,7 +128,7 @@ describe Champ do let(:type_de_champ) { build(:type_de_champ_address) } let(:value) { "10 rue du Pinson qui Piaille" } - it { is_expected.to eq([ value ]) } + it { is_expected.to eq([value]) } end context 'for checkbox champ' do @@ -138,7 +138,7 @@ describe Champ do context 'when the box is checked' do let(:value) { 'on' } - it { is_expected.to eq([ libelle ]) } + it { is_expected.to eq([libelle]) } end context 'when the box is unchecked' do @@ -152,7 +152,7 @@ describe Champ do let(:type_de_champ) { build(:type_de_champ_civilite) } let(:value) { "M." } - it { is_expected.to eq([ value ]) } + it { is_expected.to eq([value]) } end context 'for date champ' do @@ -173,28 +173,28 @@ describe Champ do let(:type_de_champ) { build(:type_de_champ_departements) } let(:value) { "69 - Rhône" } - it { is_expected.to eq([ value ]) } + it { is_expected.to eq([value]) } end context 'for dossier link champ' do let(:type_de_champ) { build(:type_de_champ_dossier_link) } let(:value) { "9103132886" } - it { is_expected.to eq([ value ]) } + it { is_expected.to eq([value]) } end context 'for drop down list champ' do let(:type_de_champ) { build(:type_de_champ_dossier_link) } let(:value) { "HLM" } - it { is_expected.to eq([ value ]) } + it { is_expected.to eq([value]) } end context 'for email champ' do let(:type_de_champ) { build(:type_de_champ_email) } let(:value) { "machin@example.com" } - it { is_expected.to eq([ value ]) } + it { is_expected.to eq([value]) } end context 'for engagement champ' do @@ -204,7 +204,7 @@ describe Champ do context 'when the box is checked' do let(:value) { 'on' } - it { is_expected.to eq([ libelle ]) } + it { is_expected.to eq([libelle]) } end context 'when the box is unchecked' do @@ -239,7 +239,7 @@ describe Champ do let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list) } context 'when there are multiple values selected' do - let(:value) { JSON.generate([ 'goodbye', 'cruel', 'world' ]) } + let(:value) { JSON.generate(['goodbye', 'cruel', 'world']) } it { is_expected.to eq(["goodbye", "cruel", "world"]) } end @@ -255,21 +255,21 @@ describe Champ do let(:type_de_champ) { build(:type_de_champ_number) } let(:value) { "1234" } - it { is_expected.to eq([ value ]) } + it { is_expected.to eq([value]) } end context 'for pays champ' do let(:type_de_champ) { build(:type_de_champ_pays) } let(:value) { "FRANCE" } - it { is_expected.to eq([ value ]) } + it { is_expected.to eq([value]) } end context 'for phone champ' do let(:type_de_champ) { build(:type_de_champ_phone) } let(:value) { "0606060606" } - it { is_expected.to eq([ value ]) } + it { is_expected.to eq([value]) } end context 'for pièce justificative champ' do @@ -283,7 +283,7 @@ describe Champ do let(:type_de_champ) { build(:type_de_champ_regions) } let(:value) { "Île-de-France" } - it { is_expected.to eq([ value ]) } + it { is_expected.to eq([value]) } end context 'for siret champ' do @@ -325,14 +325,14 @@ describe Champ do end let(:champ) { type_de_champ.champ.build(value: etablissement.siret, etablissement: etablissement) } - it { is_expected.to eq([ etablissement.entreprise_siren, etablissement.entreprise_numero_tva_intracommunautaire, etablissement.entreprise_forme_juridique, etablissement.entreprise_forme_juridique_code, etablissement.entreprise_nom_commercial, etablissement.entreprise_raison_sociale, etablissement.entreprise_siret_siege_social, etablissement.entreprise_nom, etablissement.entreprise_prenom, etablissement.association_rna, etablissement.association_titre, etablissement.association_objet, etablissement.siret, etablissement.naf, etablissement.libelle_naf, etablissement.adresse, etablissement.code_postal, etablissement.localite, etablissement.code_insee_localite ]) } + it { is_expected.to eq([etablissement.entreprise_siren, etablissement.entreprise_numero_tva_intracommunautaire, etablissement.entreprise_forme_juridique, etablissement.entreprise_forme_juridique_code, etablissement.entreprise_nom_commercial, etablissement.entreprise_raison_sociale, etablissement.entreprise_siret_siege_social, etablissement.entreprise_nom, etablissement.entreprise_prenom, etablissement.association_rna, etablissement.association_titre, etablissement.association_objet, etablissement.siret, etablissement.naf, etablissement.libelle_naf, etablissement.adresse, etablissement.code_postal, etablissement.localite, etablissement.code_insee_localite]) } end context 'when there is no etablissement' do let(:siret) { "35130347400024" } let(:champ) { type_de_champ.champ.build(value: siret) } - it { is_expected.to eq([ siret ]) } + it { is_expected.to eq([siret]) } end end @@ -340,14 +340,14 @@ describe Champ do let(:type_de_champ) { build(:type_de_champ_text) } let(:value) { "Blah" } - it { is_expected.to eq([ value ]) } + it { is_expected.to eq([value]) } end context 'for text area champ' do let(:type_de_champ) { build(:type_de_champ_textarea) } let(:value) { "Bla\nBlah de bla." } - it { is_expected.to eq([ value ]) } + it { is_expected.to eq([value]) } end context 'for yes/no champ' do @@ -357,7 +357,7 @@ describe Champ do context 'when the box is checked' do let(:value) { "true" } - it { is_expected.to eq([ libelle ]) } + it { is_expected.to eq([libelle]) } end context 'when the box is unchecked' do diff --git a/spec/models/types_de_champ/linked_drop_down_list_type_de_champ_spec.rb b/spec/models/types_de_champ/linked_drop_down_list_type_de_champ_spec.rb index b7ee29bdf..18c551bd4 100644 --- a/spec/models/types_de_champ/linked_drop_down_list_type_de_champ_spec.rb +++ b/spec/models/types_de_champ/linked_drop_down_list_type_de_champ_spec.rb @@ -96,13 +96,13 @@ describe TypesDeChamp::LinkedDropDownListTypeDeChamp do expect(subject.secondary_options).to eq( { '' => [], - 'Primary 1' => [ '', 'secondary 1.1', 'secondary 1.2'], - 'Primary 2' => [ '', 'secondary 2.1', 'secondary 2.2', 'secondary 2.3'] + 'Primary 1' => ['', 'secondary 1.1', 'secondary 1.2'], + 'Primary 2' => ['', 'secondary 2.1', 'secondary 2.2', 'secondary 2.3'] } ) end - it { expect(subject.primary_options).to eq([ '', 'Primary 1', 'Primary 2' ]) } + it { expect(subject.primary_options).to eq(['', 'Primary 1', 'Primary 2']) } end end end