Enable the Layout/SpaceInsideArrayLiteralBrackets

This commit is contained in:
gregoirenovel 2018-12-24 17:29:46 +01:00 committed by Pierre de La Morinerie
parent 386fbce776
commit 186e362701
12 changed files with 36 additions and 35 deletions

View file

@ -252,7 +252,8 @@ Layout/SpaceInsideHashLiteralBraces:
Enabled: true Enabled: true
Layout/SpaceInsideArrayLiteralBrackets: Layout/SpaceInsideArrayLiteralBrackets:
Enabled: false Enabled: true
EnforcedStyle: no_space
Layout/SpaceInsideParens: Layout/SpaceInsideParens:
Enabled: true Enabled: true

View file

@ -36,7 +36,7 @@ class Champ < ApplicationRecord
end end
def search_terms def search_terms
[ to_s ] [to_s]
end end
def to_s def to_s

View file

@ -1,7 +1,7 @@
class Champs::CheckboxChamp < Champ class Champs::CheckboxChamp < Champ
def search_terms def search_terms
if value == 'on' if value == 'on'
[ libelle ] [libelle]
end end
end end

View file

@ -1,7 +1,7 @@
class Champs::EngagementChamp < Champs::CheckboxChamp class Champs::EngagementChamp < Champs::CheckboxChamp
def search_terms def search_terms
if value == 'on' if value == 'on'
[ libelle ] [libelle]
end end
end end
end end

View file

@ -38,7 +38,7 @@ class Champs::LinkedDropDownListChamp < Champ
end end
def search_terms def search_terms
[ primary_value, secondary_value ] [primary_value, secondary_value]
end end
private private
@ -52,6 +52,6 @@ class Champs::LinkedDropDownListChamp < Champ
end end
def pack_value(primary, secondary) def pack_value(primary, secondary)
self.value = JSON.generate([ primary, secondary ]) self.value = JSON.generate([primary, secondary])
end end
end end

View file

@ -40,6 +40,6 @@ class Champs::SiretChamp < Champ
accepts_nested_attributes_for :etablissement, allow_destroy: true, update_only: true accepts_nested_attributes_for :etablissement, allow_destroy: true, update_only: true
def search_terms def search_terms
etablissement.present? ? etablissement.search_terms : [ value ] etablissement.present? ? etablissement.search_terms : [value]
end end
end end

View file

@ -1,7 +1,7 @@
class Champs::YesNoChamp < Champs::CheckboxChamp class Champs::YesNoChamp < Champs::CheckboxChamp
def search_terms def search_terms
if value == 'true' if value == 'true'
[ libelle ] [libelle]
end end
end end

View file

@ -215,7 +215,7 @@ class ProcedurePresentation < ApplicationRecord
def valid_columns_for_table(table) def valid_columns_for_table(table)
@column_whitelist ||= fields @column_whitelist ||= fields
.group_by { |field| field['table'] } .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 .to_h
@column_whitelist[table] || [] @column_whitelist[table] || []

View file

@ -10,7 +10,7 @@ class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
t.string :checksum, null: false t.string :checksum, null: false
t.datetime :created_at, null: false t.datetime :created_at, null: false
t.index [ :key ], unique: true t.index [:key], unique: true
end end
create_table :active_storage_attachments do |t| create_table :active_storage_attachments do |t|
@ -20,7 +20,7 @@ class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
t.datetime :created_at, null: false 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 end
end end

View file

@ -10,21 +10,21 @@ RSpec.describe ConservationDeDonneesHelper, type: :helper do
let(:dans_ds) { 3 } let(:dans_ds) { 3 }
let(:hors_ds) { 6 } let(:hors_ds) { 6 }
it { is_expected.to eq([ "Dans demarches-simplifiees.fr : 3 mois", "Par ladministration : 6 mois" ]) } it { is_expected.to eq(["Dans demarches-simplifiees.fr : 3 mois", "Par ladministration : 6 mois"]) }
end end
context "when only in-app retention time is set" do context "when only in-app retention time is set" do
let(:dans_ds) { 3 } let(:dans_ds) { 3 }
let(:hors_ds) { nil } 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 end
context "when only out of app retention time is set" do context "when only out of app retention time is set" do
let(:dans_ds) { nil } let(:dans_ds) { nil }
let(:hors_ds) { 6 } let(:hors_ds) { 6 }
it { is_expected.to eq([ "Par ladministration : 6 mois" ]) } it { is_expected.to eq(["Par ladministration : 6 mois"]) }
end end
context "when the retention time is not set" do context "when the retention time is not set" do

View file

@ -128,7 +128,7 @@ describe Champ do
let(:type_de_champ) { build(:type_de_champ_address) } let(:type_de_champ) { build(:type_de_champ_address) }
let(:value) { "10 rue du Pinson qui Piaille" } let(:value) { "10 rue du Pinson qui Piaille" }
it { is_expected.to eq([ value ]) } it { is_expected.to eq([value]) }
end end
context 'for checkbox champ' do context 'for checkbox champ' do
@ -138,7 +138,7 @@ describe Champ do
context 'when the box is checked' do context 'when the box is checked' do
let(:value) { 'on' } let(:value) { 'on' }
it { is_expected.to eq([ libelle ]) } it { is_expected.to eq([libelle]) }
end end
context 'when the box is unchecked' do context 'when the box is unchecked' do
@ -152,7 +152,7 @@ describe Champ do
let(:type_de_champ) { build(:type_de_champ_civilite) } let(:type_de_champ) { build(:type_de_champ_civilite) }
let(:value) { "M." } let(:value) { "M." }
it { is_expected.to eq([ value ]) } it { is_expected.to eq([value]) }
end end
context 'for date champ' do context 'for date champ' do
@ -173,28 +173,28 @@ describe Champ do
let(:type_de_champ) { build(:type_de_champ_departements) } let(:type_de_champ) { build(:type_de_champ_departements) }
let(:value) { "69 - Rhône" } let(:value) { "69 - Rhône" }
it { is_expected.to eq([ value ]) } it { is_expected.to eq([value]) }
end end
context 'for dossier link champ' do context 'for dossier link champ' do
let(:type_de_champ) { build(:type_de_champ_dossier_link) } let(:type_de_champ) { build(:type_de_champ_dossier_link) }
let(:value) { "9103132886" } let(:value) { "9103132886" }
it { is_expected.to eq([ value ]) } it { is_expected.to eq([value]) }
end end
context 'for drop down list champ' do context 'for drop down list champ' do
let(:type_de_champ) { build(:type_de_champ_dossier_link) } let(:type_de_champ) { build(:type_de_champ_dossier_link) }
let(:value) { "HLM" } let(:value) { "HLM" }
it { is_expected.to eq([ value ]) } it { is_expected.to eq([value]) }
end end
context 'for email champ' do context 'for email champ' do
let(:type_de_champ) { build(:type_de_champ_email) } let(:type_de_champ) { build(:type_de_champ_email) }
let(:value) { "machin@example.com" } let(:value) { "machin@example.com" }
it { is_expected.to eq([ value ]) } it { is_expected.to eq([value]) }
end end
context 'for engagement champ' do context 'for engagement champ' do
@ -204,7 +204,7 @@ describe Champ do
context 'when the box is checked' do context 'when the box is checked' do
let(:value) { 'on' } let(:value) { 'on' }
it { is_expected.to eq([ libelle ]) } it { is_expected.to eq([libelle]) }
end end
context 'when the box is unchecked' do 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) } let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list) }
context 'when there are multiple values selected' do 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"]) } it { is_expected.to eq(["goodbye", "cruel", "world"]) }
end end
@ -255,21 +255,21 @@ describe Champ do
let(:type_de_champ) { build(:type_de_champ_number) } let(:type_de_champ) { build(:type_de_champ_number) }
let(:value) { "1234" } let(:value) { "1234" }
it { is_expected.to eq([ value ]) } it { is_expected.to eq([value]) }
end end
context 'for pays champ' do context 'for pays champ' do
let(:type_de_champ) { build(:type_de_champ_pays) } let(:type_de_champ) { build(:type_de_champ_pays) }
let(:value) { "FRANCE" } let(:value) { "FRANCE" }
it { is_expected.to eq([ value ]) } it { is_expected.to eq([value]) }
end end
context 'for phone champ' do context 'for phone champ' do
let(:type_de_champ) { build(:type_de_champ_phone) } let(:type_de_champ) { build(:type_de_champ_phone) }
let(:value) { "0606060606" } let(:value) { "0606060606" }
it { is_expected.to eq([ value ]) } it { is_expected.to eq([value]) }
end end
context 'for pièce justificative champ' do context 'for pièce justificative champ' do
@ -283,7 +283,7 @@ describe Champ do
let(:type_de_champ) { build(:type_de_champ_regions) } let(:type_de_champ) { build(:type_de_champ_regions) }
let(:value) { "Île-de-France" } let(:value) { "Île-de-France" }
it { is_expected.to eq([ value ]) } it { is_expected.to eq([value]) }
end end
context 'for siret champ' do context 'for siret champ' do
@ -325,14 +325,14 @@ describe Champ do
end end
let(:champ) { type_de_champ.champ.build(value: etablissement.siret, etablissement: etablissement) } 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 end
context 'when there is no etablissement' do context 'when there is no etablissement' do
let(:siret) { "35130347400024" } let(:siret) { "35130347400024" }
let(:champ) { type_de_champ.champ.build(value: siret) } let(:champ) { type_de_champ.champ.build(value: siret) }
it { is_expected.to eq([ siret ]) } it { is_expected.to eq([siret]) }
end end
end end
@ -340,14 +340,14 @@ describe Champ do
let(:type_de_champ) { build(:type_de_champ_text) } let(:type_de_champ) { build(:type_de_champ_text) }
let(:value) { "Blah" } let(:value) { "Blah" }
it { is_expected.to eq([ value ]) } it { is_expected.to eq([value]) }
end end
context 'for text area champ' do context 'for text area champ' do
let(:type_de_champ) { build(:type_de_champ_textarea) } let(:type_de_champ) { build(:type_de_champ_textarea) }
let(:value) { "Bla\nBlah de bla." } let(:value) { "Bla\nBlah de bla." }
it { is_expected.to eq([ value ]) } it { is_expected.to eq([value]) }
end end
context 'for yes/no champ' do context 'for yes/no champ' do
@ -357,7 +357,7 @@ describe Champ do
context 'when the box is checked' do context 'when the box is checked' do
let(:value) { "true" } let(:value) { "true" }
it { is_expected.to eq([ libelle ]) } it { is_expected.to eq([libelle]) }
end end
context 'when the box is unchecked' do context 'when the box is unchecked' do

View file

@ -96,13 +96,13 @@ describe TypesDeChamp::LinkedDropDownListTypeDeChamp do
expect(subject.secondary_options).to eq( expect(subject.secondary_options).to eq(
{ {
'' => [], '' => [],
'Primary 1' => [ '', 'secondary 1.1', 'secondary 1.2'], 'Primary 1' => ['', 'secondary 1.1', 'secondary 1.2'],
'Primary 2' => [ '', 'secondary 2.1', 'secondary 2.2', 'secondary 2.3'] 'Primary 2' => ['', 'secondary 2.1', 'secondary 2.2', 'secondary 2.3']
} }
) )
end 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 end
end end