From 9e0e553f8013a14d087fe90926a5ac3374dfd92e Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 18:54:57 +0100 Subject: [PATCH] Enable the Layout/IndentArray cop --- .rubocop.yml | 3 +- app/models/gestionnaire.rb | 2 +- app/services/geojson_service.rb | 24 +++++----- config/deploy.rb | 48 +++++++++---------- ...2_build_default_preference_list_dossier.rb | 42 ++++++++-------- ...95443_reset_all_preference_list_dossier.rb | 42 ++++++++-------- .../api/v1/dossiers_controller_spec.rb | 42 ++++++++-------- spec/controllers/stats_controller_spec.rb | 18 +++---- spec/lib/carto/sgmap/cadastre/adapter_spec.rb | 26 +++++----- spec/services/geojson_service_spec.rb | 10 ++-- 10 files changed, 129 insertions(+), 128 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index c7d98218a..29cf584a4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -98,7 +98,8 @@ Layout/FirstParameterIndentation: Enabled: true Layout/IndentArray: - Enabled: false + Enabled: true + EnforcedStyle: consistent Layout/IndentAssignment: Enabled: false diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index cd952b0de..b3655b169 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -217,6 +217,6 @@ class Gestionnaire < ActiveRecord::Base updated_annotations, updated_avis, updated_messagerie - ].map { |query| query.distinct.ids }.flatten.uniq + ].map { |query| query.distinct.ids }.flatten.uniq end end diff --git a/app/services/geojson_service.rb b/app/services/geojson_service.rb index 1f6562089..27a80aa4e 100644 --- a/app/services/geojson_service.rb +++ b/app/services/geojson_service.rb @@ -1,10 +1,10 @@ class GeojsonService def self.to_json_polygon_for_qp coordinates polygon = { - geo: { - type: "Polygon", - coordinates: [coordinates] - } + geo: { + type: "Polygon", + coordinates: [coordinates] + } } polygon.to_json @@ -12,15 +12,15 @@ class GeojsonService def self.to_json_polygon_for_cadastre coordinates polygon = { - geom: { - type: "Feature", - geometry: { - type: "Polygon", - coordinates: [ - coordinates - ] - } + geom: { + type: "Feature", + geometry: { + type: "Polygon", + coordinates: [ + coordinates + ] } + } } polygon.to_json diff --git a/config/deploy.rb b/config/deploy.rb index 00ae5579b..f5b8304cd 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -45,30 +45,30 @@ set :rails_env, ENV["to"] # Manually create these paths in shared/ (eg: shared/config/database.yml) in your server. # They will be linked in the 'deploy:link_shared_paths' step. set :shared_paths, [ - 'log', - 'bin', - 'uploads', - 'tmp/pids', - 'tmp/cache', - 'tmp/sockets', - 'public/system', - 'public/uploads', - 'config/database.yml', - "config/skylight.yml", - "config/fog_credentials.yml", - 'config/initializers/secret_token.rb', - 'config/initializers/features.yml', - "config/environments/#{rails_env}.rb", - "config/initializers/token.rb", - "config/initializers/urls.rb", - "config/initializers/super_admin.rb", - "config/unicorn.rb", - "config/initializers/raven.rb", - 'config/france_connect.yml', - 'config/github_secrets.yml', - 'config/initializers/mailjet.rb', - 'config/initializers/storage_url.rb' - ] + 'log', + 'bin', + 'uploads', + 'tmp/pids', + 'tmp/cache', + 'tmp/sockets', + 'public/system', + 'public/uploads', + 'config/database.yml', + "config/skylight.yml", + "config/fog_credentials.yml", + 'config/initializers/secret_token.rb', + 'config/initializers/features.yml', + "config/environments/#{rails_env}.rb", + "config/initializers/token.rb", + "config/initializers/urls.rb", + "config/initializers/super_admin.rb", + "config/unicorn.rb", + "config/initializers/raven.rb", + 'config/france_connect.yml', + 'config/github_secrets.yml', + 'config/initializers/mailjet.rb', + 'config/initializers/storage_url.rb' +] set :rbenv_path, "/usr/local/rbenv/bin/rbenv" diff --git a/db/migrate/20160802113112_build_default_preference_list_dossier.rb b/db/migrate/20160802113112_build_default_preference_list_dossier.rb index 4f73c4263..b8b7a40e9 100644 --- a/db/migrate/20160802113112_build_default_preference_list_dossier.rb +++ b/db/migrate/20160802113112_build_default_preference_list_dossier.rb @@ -21,27 +21,27 @@ class BuildDefaultPreferenceListDossier < ActiveRecord::Migration 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 - } - ] + { + 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 diff --git a/db/migrate/20161007095443_reset_all_preference_list_dossier.rb b/db/migrate/20161007095443_reset_all_preference_list_dossier.rb index 629822722..77b34cda9 100644 --- a/db/migrate/20161007095443_reset_all_preference_list_dossier.rb +++ b/db/migrate/20161007095443_reset_all_preference_list_dossier.rb @@ -119,27 +119,27 @@ class ResetAllPreferenceListDossier < ActiveRecord::Migration 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 - } - ] + { + 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 diff --git a/spec/controllers/api/v1/dossiers_controller_spec.rb b/spec/controllers/api/v1/dossiers_controller_spec.rb index 8765cd6ee..fa0fe0008 100644 --- a/spec/controllers/api/v1/dossiers_controller_spec.rb +++ b/spec/controllers/api/v1/dossiers_controller_spec.rb @@ -132,7 +132,8 @@ describe API::V1::DossiersController do it { expect(subject.keys).to match_array(field_list) } describe 'entreprise' do - let(:field_list) { [ + let(:field_list) { + [ :siren, :capital_social, :numero_tva_intracommunautaire, @@ -144,7 +145,8 @@ describe API::V1::DossiersController do :code_effectif_entreprise, :date_creation, :nom, - :prenom] + :prenom + ] } subject { super()[:entreprise] } @@ -162,11 +164,7 @@ describe API::V1::DossiersController do end describe 'types_de_piece_justificative' do - let(:field_list) { [ - :id, - :libelle, - :description] - } + let(:field_list) { [:id, :libelle, :description] } subject { super()[:types_de_piece_justificative] } it { expect(subject.length).to eq 2 } @@ -185,9 +183,7 @@ describe API::V1::DossiersController do create :piece_justificative, :rib, dossier: dossier, type_de_piece_justificative: dossier.procedure.types_de_piece_justificative.first, user: dossier.user end - let(:field_list) { [ - :url, :created_at, :type_de_piece_justificative_id] - } + let(:field_list) { [:url, :created_at, :type_de_piece_justificative_id] } subject { super()[:pieces_justificatives].first } it { expect(subject.keys.include?(:content_url)).to be_truthy } @@ -204,8 +200,7 @@ describe API::V1::DossiersController do end describe 'champs' do - let(:field_list) { [ - :url] + let(:field_list) { [:url] } subject { super()[:champs] } @@ -218,12 +213,14 @@ describe API::V1::DossiersController do it { expect(subject.keys.include?(:type_de_champ)).to be_truthy } describe 'type de champ' do - let(:field_list) { [ + let(:field_list) { + [ :id, :libelle, :description, :order_place, - :type] + :type + ] } subject { super()[:type_de_champ] } @@ -277,9 +274,7 @@ describe API::V1::DossiersController do end describe 'champs_private' do - let(:field_list) { [ - :url] - } + let(:field_list) { [:url] } subject { super()[:champs_private] } it { expect(subject.length).to eq 1 } @@ -291,12 +286,14 @@ describe API::V1::DossiersController do it { expect(subject.keys.include?(:type_de_champ)).to be_truthy } describe 'type de champ' do - let(:field_list) { [ + let(:field_list) { + [ :id, :libelle, :description, :order_place, - :type] + :type + ] } subject { super()[:type_de_champ] } @@ -343,9 +340,7 @@ describe API::V1::DossiersController do end describe 'user' do - let(:field_list) { [ - :url, :created_at, :type_de_piece_justificative_id] - } + let(:field_list) { [:url, :created_at, :type_de_piece_justificative_id] } subject { super()[:user] } it { expect(subject[:email]).not_to be_nil } @@ -353,7 +348,8 @@ describe API::V1::DossiersController do end describe 'etablissement' do - let(:field_list) { [ + let(:field_list) { + [ :siret, :siege_social, :naf, diff --git a/spec/controllers/stats_controller_spec.rb b/spec/controllers/stats_controller_spec.rb index d8dedd133..35dfb3bcf 100644 --- a/spec/controllers/stats_controller_spec.rb +++ b/spec/controllers/stats_controller_spec.rb @@ -18,11 +18,12 @@ describe StatsController, type: :controller do subject { @controller.send(:last_four_months_hash, association, :updated_at) } - it { expect(subject).to match_array([ - [I18n.l(62.days.ago.beginning_of_month, format: "%B %Y"), 2], - [I18n.l(31.days.ago.beginning_of_month, format: "%B %Y"), 1] + it do + expect(subject).to match_array([ + [I18n.l(62.days.ago.beginning_of_month, format: "%B %Y"), 2], + [I18n.l(31.days.ago.beginning_of_month, format: "%B %Y"), 1] ]) - } + end end context "while a super admin is logged in" do @@ -41,11 +42,12 @@ describe StatsController, type: :controller do subject { @controller.send(:last_four_months_hash, association, :updated_at) } - it { expect(subject).to eq([ - [I18n.l(45.days.ago.beginning_of_month, format: "%B %Y"), 1], - [I18n.l(1.days.ago.beginning_of_month, format: "%B %Y"), 2] + it do + expect(subject).to eq([ + [I18n.l(45.days.ago.beginning_of_month, format: "%B %Y"), 1], + [I18n.l(1.days.ago.beginning_of_month, format: "%B %Y"), 2] ]) - } + end end end diff --git a/spec/lib/carto/sgmap/cadastre/adapter_spec.rb b/spec/lib/carto/sgmap/cadastre/adapter_spec.rb index 3e33ae2f8..d3c7246a6 100644 --- a/spec/lib/carto/sgmap/cadastre/adapter_spec.rb +++ b/spec/lib/carto/sgmap/cadastre/adapter_spec.rb @@ -23,18 +23,20 @@ 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 do + expect(subject.keys).to eq + [ + :surface_intersection, + :surface_parcelle, + :numero, + :feuille, + :section, + :code_dep, + :nom_com, + :code_com, + :code_arr + ] + end end describe 'Attributes' do diff --git a/spec/services/geojson_service_spec.rb b/spec/services/geojson_service_spec.rb index 7837e7d72..8887d27d0 100644 --- a/spec/services/geojson_service_spec.rb +++ b/spec/services/geojson_service_spec.rb @@ -3,11 +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] ] }