From 1e71188d4d941137118c2888f78ba48ab1396cfb Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 19:12:15 +0100 Subject: [PATCH] Enable the Layout/IndentationConsistency cop --- .rubocop.yml | 2 +- app/controllers/stats_controller.rb | 2 +- .../concerns/credentials_syncable_concern.rb | 22 +++++++++--------- app/uploaders/piece_justificative_uploader.rb | 2 +- ...5102943_remove_duplicate_email_received.rb | 12 +++++----- spec/lib/carto/sgmap/cadastre/adapter_spec.rb | 23 +++++++++---------- .../concern/tags_substitution_concern_spec.rb | 6 ++--- spec/models/gestionnaire_spec.rb | 15 +++++++----- 8 files changed, 43 insertions(+), 41 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 146ebb5d8..1b3601fa4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -112,7 +112,7 @@ Layout/IndentHeredoc: Enabled: true Layout/IndentationConsistency: - Enabled: false + Enabled: true Layout/IndentationWidth: Enabled: true diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index b62d12505..342dcd762 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -47,7 +47,7 @@ class StatsController < ApplicationController def last_four_months_hash(association, date_attribute) min_date = 3.months.ago.beginning_of_month.to_date - association + association .where(date_attribute => min_date..max_date) .group("DATE_TRUNC('month', #{date_attribute.to_s})") .count diff --git a/app/models/concerns/credentials_syncable_concern.rb b/app/models/concerns/credentials_syncable_concern.rb index 64515b393..bddaf5209 100644 --- a/app/models/concerns/credentials_syncable_concern.rb +++ b/app/models/concerns/credentials_syncable_concern.rb @@ -1,18 +1,18 @@ module CredentialsSyncableConcern extend ActiveSupport::Concern - included do - after_update :sync_credentials - end + included do + after_update :sync_credentials + end - def sync_credentials - if email_changed? || encrypted_password_changed? - return force_sync_credentials - end - true + def sync_credentials + if email_changed? || encrypted_password_changed? + return force_sync_credentials end + true + end - def force_sync_credentials - SyncCredentialsService.new(self.class, email_was, email, encrypted_password).change_credentials! - end + def force_sync_credentials + SyncCredentialsService.new(self.class, email_was, email, encrypted_password).change_credentials! + end end diff --git a/app/uploaders/piece_justificative_uploader.rb b/app/uploaders/piece_justificative_uploader.rb index dddab178c..22e44268f 100644 --- a/app/uploaders/piece_justificative_uploader.rb +++ b/app/uploaders/piece_justificative_uploader.rb @@ -26,7 +26,7 @@ class PieceJustificativeUploader < BaseUploader if original_filename.present? || model.content_secure_token if Features.remote_storage filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}" - else original_filename + else filename = "#{model.class.to_s.underscore}.#{file.extension.downcase}" end end diff --git a/db/migrate/20170215102943_remove_duplicate_email_received.rb b/db/migrate/20170215102943_remove_duplicate_email_received.rb index 907762e04..e69945626 100644 --- a/db/migrate/20170215102943_remove_duplicate_email_received.rb +++ b/db/migrate/20170215102943_remove_duplicate_email_received.rb @@ -1,11 +1,11 @@ class RemoveDuplicateEmailReceived < ActiveRecord::Migration[5.0] def change all_mails = MailReceived.all - groupped = all_mails.group_by { |m| m.procedure_id } - filtered = groupped.reject { |k, v| v.length < 2 } - filtered.each do |k, duplicate_mails| - duplicate_mails.pop - duplicate_mails.each(&:destroy) - end + groupped = all_mails.group_by { |m| m.procedure_id } + filtered = groupped.reject { |k, v| v.length < 2 } + filtered.each do |k, duplicate_mails| + duplicate_mails.pop + duplicate_mails.each(&:destroy) + end end end diff --git a/spec/lib/carto/sgmap/cadastre/adapter_spec.rb b/spec/lib/carto/sgmap/cadastre/adapter_spec.rb index d3c7246a6..0e311f5d8 100644 --- a/spec/lib/carto/sgmap/cadastre/adapter_spec.rb +++ b/spec/lib/carto/sgmap/cadastre/adapter_spec.rb @@ -24,18 +24,17 @@ describe CARTO::SGMAP::Cadastre::Adapter do it { expect(subject.size).to eq 9 } it do - expect(subject.keys).to eq - [ - :surface_intersection, - :surface_parcelle, - :numero, - :feuille, - :section, - :code_dep, - :nom_com, - :code_com, - :code_arr - ] + expect(subject.keys).to eq [ + :surface_intersection, + :surface_parcelle, + :numero, + :feuille, + :section, + :code_dep, + :nom_com, + :code_com, + :code_arr + ] end end diff --git a/spec/models/concern/tags_substitution_concern_spec.rb b/spec/models/concern/tags_substitution_concern_spec.rb index 7d6acfa62..911fa29de 100644 --- a/spec/models/concern/tags_substitution_concern_spec.rb +++ b/spec/models/concern/tags_substitution_concern_spec.rb @@ -182,19 +182,19 @@ describe TagsSubstitutionConcern, type: :model do context "with date de dépôt" do let(:template) { '--date de dépôt--' } - it { is_expected.to eq('03/02/2001') } + it { is_expected.to eq('03/02/2001') } end context "with date de passage en instruction" do let(:template) { '--date de passage en instruction--' } - it { is_expected.to eq('06/05/2004') } + it { is_expected.to eq('06/05/2004') } end context "with date de décision" do let(:template) { '--date de décision--' } - it { is_expected.to eq('09/08/2007') } + it { is_expected.to eq('09/08/2007') } end end diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index 206341037..f5425bf79 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -94,9 +94,10 @@ describe Gestionnaire, type: :model do context 'when gestionnaire follow any dossier' do it { is_expected.to eq 0 } it { expect(gestionnaire.follows.count).to eq 0 } - it { expect_any_instance_of(Dossier::ActiveRecord_AssociationRelation).not_to receive(:inject) + it do + expect_any_instance_of(Dossier::ActiveRecord_AssociationRelation).not_to receive(:inject) subject - } + end end context 'when gestionnaire follow any dossier into the procedure past in params' do @@ -106,9 +107,10 @@ describe Gestionnaire, type: :model do it { is_expected.to eq 0 } it { expect(gestionnaire.follows.count).to eq 1 } - it { expect_any_instance_of(Dossier::ActiveRecord_AssociationRelation).not_to receive(:inject) + it do + expect_any_instance_of(Dossier::ActiveRecord_AssociationRelation).not_to receive(:inject) subject - } + end end context 'when gestionnaire follow a dossier with a notification into the procedure past in params' do @@ -121,9 +123,10 @@ describe Gestionnaire, type: :model do it { is_expected.to eq 1 } it { expect(gestionnaire.follows.count).to eq 1 } - it { expect_any_instance_of(Dossier::ActiveRecord_AssociationRelation).to receive(:inject) + it do + expect_any_instance_of(Dossier::ActiveRecord_AssociationRelation).to receive(:inject) subject - } + end end end