Enable the Layout/FirstArrayElementLineBreak cop

This commit is contained in:
gregoirenovel 2018-01-15 14:42:48 +01:00
parent 8f08e2fdf9
commit 08ed400ec2
17 changed files with 201 additions and 149 deletions

View file

@ -83,7 +83,7 @@ Layout/ExtraSpacing:
- "Guardfile"
Layout/FirstArrayElementLineBreak:
Enabled: false
Enabled: true
Layout/FirstHashElementLineBreak:
Enabled: false

View file

@ -1,8 +1,10 @@
class FindDubiousProceduresJob < ApplicationJob
queue_as :cron
FORBIDDEN_KEYWORDS = ['IBAN', 'NIR', 'NIRPP', 'race', 'religion',
'carte bancaire', 'carte bleue', 'sécurité sociale']
FORBIDDEN_KEYWORDS = [
'IBAN', 'NIR', 'NIRPP', 'race', 'religion',
'carte bancaire', 'carte bleue', 'sécurité sociale'
]
def perform(*args)
# \\y is a word boundary

View file

@ -23,18 +23,20 @@ class SIADE::EntrepriseAdapter
end
def attr_to_fetch
[:siren,
:capital_social,
:numero_tva_intracommunautaire,
:forme_juridique,
:forme_juridique_code,
:nom_commercial,
:raison_sociale,
:siret_siege_social,
:code_effectif_entreprise,
:date_creation,
:nom,
:prenom]
[
:siren,
:capital_social,
:numero_tva_intracommunautaire,
:forme_juridique,
:forme_juridique_code,
:nom_commercial,
:raison_sociale,
:siret_siege_social,
:code_effectif_entreprise,
:date_creation,
:nom,
:prenom
]
end
def mandataires_sociaux

View file

@ -23,10 +23,11 @@ class SIADE::EtablissementAdapter
end
def attr_to_fetch
[:siret,
:siege_social,
:naf,
:libelle_naf
[
:siret,
:siege_social,
:naf,
:libelle_naf
]
end
@ -41,12 +42,14 @@ class SIADE::EtablissementAdapter
end
def address_attribut_to_fetch
[:numero_voie,
:type_voie,
:nom_voie,
:complement_adresse,
:code_postal,
:localite,
:code_insee_localite]
[
:numero_voie,
:type_voie,
:nom_voie,
:complement_adresse,
:code_postal,
:localite,
:code_insee_localite
]
end
end

View file

@ -23,12 +23,13 @@ class SIADE::RNAAdapter
end
def attr_to_fetch
[:id,
:titre,
:objet,
:date_creation,
:date_declaration,
:date_publication
[
:id,
:titre,
:objet,
:date_creation,
:date_declaration,
:date_publication
]
end
end

View file

@ -28,22 +28,24 @@ module TagsSubstitutionConcern
end
def dossier_tags
[{ libelle: 'motivation',
description: 'Motivation facultative associée à la décision finale dacceptation, refus ou classement sans suite',
target: :motivation,
dossier_termine_only: true },
{ libelle: 'date de dépôt',
description: 'Date du passage en construction du dossier par lusager',
lambda: -> (d) { format_date(d.en_construction_at) } },
{ libelle: 'date de passage en instruction',
description: '',
lambda: -> (d) { format_date(d.en_instruction_at) } },
{ libelle: 'date de décision',
description: 'Date de la décision dacceptation, refus, ou classement sans suite',
lambda: -> (d) { format_date(d.processed_at) },
dossier_termine_only: true },
{ libelle: 'libellé procédure', description: '', lambda: -> (d) { d.procedure.libelle } },
{ libelle: 'numéro du dossier', description: '', target: :id }]
[
{ libelle: 'motivation',
description: 'Motivation facultative associée à la décision finale dacceptation, refus ou classement sans suite',
target: :motivation,
dossier_termine_only: true },
{ libelle: 'date de dépôt',
description: 'Date du passage en construction du dossier par lusager',
lambda: -> (d) { format_date(d.en_construction_at) } },
{ libelle: 'date de passage en instruction',
description: '',
lambda: -> (d) { format_date(d.en_instruction_at) } },
{ libelle: 'date de décision',
description: 'Date de la décision dacceptation, refus, ou classement sans suite',
lambda: -> (d) { format_date(d.processed_at) },
dossier_termine_only: true },
{ libelle: 'libellé procédure', description: '', lambda: -> (d) { d.procedure.libelle } },
{ libelle: 'numéro du dossier', description: '', target: :id }
]
end
def format_date(date)
@ -55,16 +57,20 @@ module TagsSubstitutionConcern
end
def individual_tags
[{ libelle: 'civilité', description: 'M., Mme', target: :gender },
{ libelle: 'nom', description: "nom de l'usager", target: :nom },
{ libelle: 'prénom', description: "prénom de l'usager", target: :prenom }]
[
{ libelle: 'civilité', description: 'M., Mme', target: :gender },
{ libelle: 'nom', description: "nom de l'usager", target: :nom },
{ libelle: 'prénom', description: "prénom de l'usager", target: :prenom }
]
end
def entreprise_tags
[{ libelle: 'SIREN', description: '', target: :siren },
{ libelle: 'numéro de TVA intracommunautaire', description: '', target: :numero_tva_intracommunautaire },
{ libelle: 'SIRET du siège social', description: '', target: :siret_siege_social },
{ libelle: 'raison sociale', description: '', target: :raison_sociale }]
[
{ libelle: 'SIREN', description: '', target: :siren },
{ libelle: 'numéro de TVA intracommunautaire', description: '', target: :numero_tva_intracommunautaire },
{ libelle: 'SIRET du siège social', description: '', target: :siret_siege_social },
{ libelle: 'raison sociale', description: '', target: :raison_sociale }
]
end
def etablissement_tags

View file

@ -154,22 +154,28 @@ class Gestionnaire < ActiveRecord::Base
private
def valid_couple_table_attr? table, column
couples = [{
table: :dossier,
column: :dossier_id
}, {
table: :procedure,
column: :libelle
}, {
table: :etablissement,
column: :siret
}, {
table: :entreprise,
column: :raison_sociale
}, {
table: :dossier,
column: :state
}]
couples = [
{
table: :dossier,
column: :dossier_id
},
{
table: :procedure,
column: :libelle
},
{
table: :etablissement,
column: :siret
},
{
table: :entreprise,
column: :raison_sociale
},
{
table: :dossier,
column: :state
}
]
couples.include?({table: table, column: column})
end
@ -205,10 +211,12 @@ class Gestionnaire < ActiveRecord::Base
.where('commentaires.updated_at > follows.messagerie_seen_at')
.where.not(commentaires: { email: 'contact@tps.apientreprise.fr' })
[updated_demandes,
updated_pieces_justificatives,
updated_annotations,
updated_avis,
updated_messagerie].map { |query| query.distinct.ids }.flatten.uniq
[
updated_demandes,
updated_pieces_justificatives,
updated_annotations,
updated_avis,
updated_messagerie
].map { |query| query.distinct.ids }.flatten.uniq
end
end

View file

@ -30,9 +30,11 @@ class ProcedureOverview
end
def had_some_activities?
[@dossiers_en_instruction_count,
@dossiers_en_construction_count,
@created_dossiers_count].reduce(:+) > 0
[
@dossiers_en_instruction_count,
@dossiers_en_construction_count,
@created_dossiers_count
].reduce(:+) > 0
end
def dossiers_en_construction_description

View file

@ -6,8 +6,16 @@ class TypesDeChampService
parameters = params_with_ordered_champs
.require(:procedure)
.permit("#{attributes}" => [:libelle, :description, :order_place, :type_champ, :id, :mandatory, :type,
drop_down_list_attributes: [:value, :id]])
.permit("#{attributes}" => [
:libelle,
:description,
:order_place,
:type_champ,
:id,
:mandatory,
:type,
drop_down_list_attributes: [:value, :id]
])
parameters[attributes].each do |param_first, param_second|
if param_second[:libelle].empty?

View file

@ -20,22 +20,28 @@ class BuildDefaultPreferenceListDossier < ActiveRecord::Migration
end
def valid_couple_table_attr? table, column
couples = [{
table: :dossier,
column: :dossier_id
}, {
table: :procedure,
column: :libelle
}, {
table: :etablissement,
column: :siret
}, {
table: :entreprise,
column: :raison_sociale
}, {
table: :dossier,
column: :state
}]
couples = [
{
table: :dossier,
column: :dossier_id
},
{
table: :procedure,
column: :libelle
},
{
table: :etablissement,
column: :siret
},
{
table: :entreprise,
column: :raison_sociale
},
{
table: :dossier,
column: :state
}
]
couples.include?({table: table, column: column})
end

View file

@ -118,22 +118,28 @@ class ResetAllPreferenceListDossier < ActiveRecord::Migration
private
def valid_couple_table_attr? table, column
couples = [{
table: :dossier,
column: :dossier_id
}, {
table: :procedure,
column: :libelle
}, {
table: :etablissement,
column: :siret
}, {
table: :entreprise,
column: :raison_sociale
}, {
table: :dossier,
column: :state
}]
couples = [
{
table: :dossier,
column: :dossier_id
},
{
table: :procedure,
column: :libelle
},
{
table: :etablissement,
column: :siret
},
{
table: :entreprise,
column: :raison_sociale
},
{
table: :dossier,
column: :state
}
]
couples.include?({table: table, column: column})
end

View file

@ -16,8 +16,10 @@ RSpec.describe FindDubiousProceduresJob, type: :job do
context 'with suspicious champs' do
let(:forbidden_tdcs) do
[create(:type_de_champ_public, libelle: 'num de securite sociale, stp'),
create(:type_de_champ_public, libelle: "t'aurais une carte bancaire ?")]
[
create(:type_de_champ_public, libelle: 'num de securite sociale, stp'),
create(:type_de_champ_public, libelle: "t'aurais une carte bancaire ?")
]
end
let(:tdcs) { forbidden_tdcs + [allowed_tdc] }

View file

@ -23,15 +23,17 @@ describe CARTO::SGMAP::Cadastre::Adapter do
subject { adapter.filter_properties adapter.data_source }
it { expect(subject.size).to eq 9 }
it { expect(subject.keys).to eq [:surface_intersection,
:surface_parcelle,
:numero,
:feuille,
:section,
:code_dep,
:nom_com,
:code_com,
:code_arr]
it { expect(subject.keys).to eq [
:surface_intersection,
:surface_parcelle,
:numero,
:feuille,
:section,
:code_dep,
:nom_com,
:code_com,
:code_arr
]
}
end

View file

@ -148,8 +148,10 @@ describe AttestationTemplate, type: :model do
context 'when the procedure has a type de champ named libelleA et libelleB' do
let(:types_de_champ) do
[create(:type_de_champ_public, libelle: 'libelleA'),
create(:type_de_champ_public, libelle: 'libelleB')]
[
create(:type_de_champ_public, libelle: 'libelleA'),
create(:type_de_champ_public, libelle: 'libelleB')
]
end
context 'and the are used in the template title and body' do

View file

@ -74,8 +74,10 @@ describe TagsSubstitutionConcern, type: :model do
context 'when the procedure has a type de champ named libelleA et libelleB' do
let(:types_de_champ) do
[create(:type_de_champ_public, libelle: 'libelleA'),
create(:type_de_champ_public, libelle: 'libelleB')]
[
create(:type_de_champ_public, libelle: 'libelleA'),
create(:type_de_champ_public, libelle: 'libelleB')
]
end
context 'and the template is nil' do
@ -142,8 +144,10 @@ describe TagsSubstitutionConcern, type: :model do
context 'when the procedure has 2 types de champ date and datetime' do
let(:types_de_champ) do
[create(:type_de_champ_public, libelle: 'date', type_champ: 'date'),
create(:type_de_champ_public, libelle: 'datetime', type_champ: 'datetime')]
[
create(:type_de_champ_public, libelle: 'date', type_champ: 'date'),
create(:type_de_champ_public, libelle: 'datetime', type_champ: 'datetime')
]
end
context 'and the are used in the template' do

View file

@ -474,15 +474,18 @@ describe Procedure do
subject { create(:procedure) }
before do
allow(subject).to receive(:fields).and_return([{
"label" => "label1",
"table" => "table1",
"column" => "column1"
}, {
"label" => "label2",
"table" => "table2",
"column" => "column2"
}])
allow(subject).to receive(:fields).and_return([
{
"label" => "label1",
"table" => "table1",
"column" => "column1"
},
{
"label" => "label2",
"table" => "table2",
"column" => "column2"
}
])
end
it { expect(subject.fields_for_select).to eq([["label1", "table1/column1"], ["label2", "table2/column2"]]) }

View file

@ -3,16 +3,11 @@ require 'spec_helper'
describe GeojsonService do
let(:good_coordinates) {
[
[5.93536376953125,
48.91888968903368],
[5.93536376953125,
49.26780455063753],
[7.094421386718749,
49.26780455063753],
[7.094421386718749,
48.91888968903368],
[5.93536376953125,
48.91888968903368]
[5.93536376953125, 48.91888968903368],
[5.93536376953125, 49.26780455063753],
[7.094421386718749, 49.26780455063753],
[7.094421386718749, 48.91888968903368],
[5.93536376953125, 48.91888968903368]
]
}