From 7ffe40868b3ca0e08b5cd4bb3d9f8c16486339e3 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 24 Dec 2018 16:32:23 +0100 Subject: [PATCH 01/12] Use parentheses --- config/initializers/active_job_log_subscriber.rb | 6 +++--- config/initializers/lograge.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/initializers/active_job_log_subscriber.rb b/config/initializers/active_job_log_subscriber.rb index 202820450..d9b2d6f4d 100644 --- a/config/initializers/active_job_log_subscriber.rb +++ b/config/initializers/active_job_log_subscriber.rb @@ -32,9 +32,9 @@ class ActiveJobLogSubscriber < ::ActiveJob::Logging::LogSubscriber def process_event(event, type) data = extract_metadata(event) - data.merge! extract_exception(event) - data.merge! extract_scheduled_at(event) if type == 'enqueue_at' - data.merge! extract_duration(event) if type == 'perform' + data.merge!(extract_exception(event)) + data.merge!(extract_scheduled_at(event)) if type == 'enqueue_at' + data.merge!(extract_duration(event)) if type == 'perform' tags = ['job', type] tags.push('exception') if data[:exception] diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb index cee0b7bd8..5a63f1051 100644 --- a/config/initializers/lograge.rb +++ b/config/initializers/lograge.rb @@ -30,7 +30,7 @@ Rails.application.configure do end config.lograge.keep_original_rails_log = true - config.lograge.logger = ActiveSupport::Logger.new Rails.root.join('log', "logstash_#{Rails.env}.log") + config.lograge.logger = ActiveSupport::Logger.new(Rails.root.join('log', "logstash_#{Rails.env}.log")) if config.lograge.enabled ActiveJobLogSubscriber.attach_to(:active_job) From 8ffcc16ec5e5c5f501a55685e711e02daf0cad54 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 24 Dec 2018 16:33:46 +0100 Subject: [PATCH 02/12] Avoid EOL ifs --- config/initializers/active_job_log_subscriber.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/config/initializers/active_job_log_subscriber.rb b/config/initializers/active_job_log_subscriber.rb index d9b2d6f4d..8929602f5 100644 --- a/config/initializers/active_job_log_subscriber.rb +++ b/config/initializers/active_job_log_subscriber.rb @@ -33,11 +33,18 @@ class ActiveJobLogSubscriber < ::ActiveJob::Logging::LogSubscriber def process_event(event, type) data = extract_metadata(event) data.merge!(extract_exception(event)) - data.merge!(extract_scheduled_at(event)) if type == 'enqueue_at' - data.merge!(extract_duration(event)) if type == 'perform' + + case type + when 'enqueue_at' + data.merge!(extract_scheduled_at(event)) + when 'perform' + data.merge!(extract_duration(event)) + end tags = ['job', type] - tags.push('exception') if data[:exception] + if data[:exception] + tags.push('exception') + end data[:tags] = tags data[:type] = 'tps' data[:source] = ENV['SOURCE'] From cc32516c214e3dda86984d1ec28cba8abaf585d2 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 24 Dec 2018 17:37:45 +0100 Subject: [PATCH 03/12] Enable more cops --- .rubocop.yml | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7abe2b071..5e4ec2474 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -58,7 +58,7 @@ Layout/CommentIndentation: Enabled: true Layout/ConditionPosition: - Enabled: false + Enabled: true Layout/DefEndAlignment: Enabled: false @@ -339,40 +339,40 @@ Lint/EnsureReturn: Enabled: false Lint/FloatOutOfRange: - Enabled: false + Enabled: true Lint/FormatParameterMismatch: - Enabled: false + Enabled: true Lint/HandleExceptions: Enabled: false Lint/ImplicitStringConcatenation: - Enabled: false + Enabled: true Lint/IneffectiveAccessModifier: Enabled: false Lint/InheritException: - Enabled: false + Enabled: true Lint/InterpolationCheck: Enabled: true Lint/LiteralAsCondition: - Enabled: false + Enabled: true Lint/LiteralInInterpolation: - Enabled: false + Enabled: true Lint/Loop: - Enabled: false + Enabled: true Lint/MissingCopEnableDirective: Enabled: true Lint/MultipleCompare: - Enabled: false + Enabled: true Lint/NestedMethodDefinition: Enabled: false @@ -381,7 +381,7 @@ Lint/NestedPercentLiteral: Enabled: true Lint/NextWithoutAccumulator: - Enabled: false + Enabled: true Lint/NonLocalExitFromIterator: Enabled: false @@ -417,16 +417,16 @@ Lint/RequireParentheses: Enabled: false Lint/RescueException: - Enabled: false + Enabled: true Lint/RescueType: - Enabled: false + Enabled: true Lint/ReturnInVoidContext: Enabled: false Lint/SafeNavigationChain: - Enabled: false + Enabled: true Lint/ScriptPermission: Enabled: false @@ -435,7 +435,7 @@ Lint/ShadowedArgument: Enabled: true Lint/ShadowedException: - Enabled: false + Enabled: true Lint/ShadowingOuterLocalVariable: Enabled: false @@ -450,10 +450,10 @@ Lint/UnderscorePrefixedVariableName: Enabled: false Lint/UnifiedInteger: - Enabled: false + Enabled: true Lint/UnneededCopDisableDirective: - Enabled: false + Enabled: true Lint/UnneededCopEnableDirective: Enabled: true @@ -465,7 +465,7 @@ Lint/UnneededSplatExpansion: Enabled: false Lint/UnreachableCode: - Enabled: false + Enabled: true Lint/UnusedBlockArgument: Enabled: false @@ -486,16 +486,16 @@ Lint/UselessAssignment: Enabled: false Lint/UselessComparison: - Enabled: false + Enabled: true Lint/UselessElseWithoutRescue: - Enabled: false + Enabled: true Lint/UselessSetterCall: - Enabled: false + Enabled: true Lint/Void: - Enabled: false + Enabled: true Metrics/AbcSize: Enabled: false From 8b0b8162f0de2f13ca7288185371830bcceca66d Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 24 Dec 2018 17:37:57 +0100 Subject: [PATCH 04/12] Enable the Layout/SpaceAfterComma cop --- .rubocop.yml | 2 +- app/models/champs/datetime_champ.rb | 2 +- app/models/etablissement.rb | 2 +- app/services/render_partial_service.rb | 2 +- ...copy_commentaire_piece_justificative_to_file.rake | 2 +- lib/tasks/2018_01_18_clean_datetime_in_champs.rake | 10 +++++----- lib/tasks/admin.rake | 2 +- spec/models/procedure_presentation_spec.rb | 12 ++++++------ 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 5e4ec2474..7cef58f1e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -200,7 +200,7 @@ Layout/SpaceAfterColon: Enabled: true Layout/SpaceAfterComma: - Enabled: false + Enabled: true Layout/SpaceAfterMethodName: Enabled: true diff --git a/app/models/champs/datetime_champ.rb b/app/models/champs/datetime_champ.rb index 43d59e26f..3995b39e2 100644 --- a/app/models/champs/datetime_champ.rb +++ b/app/models/champs/datetime_champ.rb @@ -12,7 +12,7 @@ class Champs::DatetimeChamp < Champ self.value = begin hash_date = YAML.safe_load(value.gsub('=>', ': ')) - year, month, day, hour, minute = hash_date.values_at(1,2,3,4,5) + year, month, day, hour, minute = hash_date.values_at(1, 2, 3, 4, 5) Time.zone.local(year, month, day, hour, minute).strftime("%d/%m/%Y %H:%M") rescue nil diff --git a/app/models/etablissement.rb b/app/models/etablissement.rb index 4741a5334..1656f1f74 100644 --- a/app/models/etablissement.rb +++ b/app/models/etablissement.rb @@ -91,6 +91,6 @@ class Etablissement < ApplicationRecord def message_for_signature JSON.pretty_generate(as_json(include: { exercices: { only: [:ca, :date_fin_exercice, :date_fin_exercice_timestamp] } - }).delete_if { |k,v| v.blank? }) + }).delete_if { |k, v| v.blank? }) end end diff --git a/app/services/render_partial_service.rb b/app/services/render_partial_service.rb index 82ef25a54..b54a594f7 100644 --- a/app/services/render_partial_service.rb +++ b/app/services/render_partial_service.rb @@ -17,7 +17,7 @@ class RenderPartialService def self.left_panel_exist?(left_panel_url) file = left_panel_url.split('/').last - File.exist?(Rails.root.join('app','views', 'layouts', 'left_panels', "_#{file}.html.haml")) + File.exist?(Rails.root.join('app', 'views', 'layouts', 'left_panels', "_#{file}.html.haml")) end private diff --git a/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake b/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake index 660f24df3..6a721ed00 100644 --- a/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake +++ b/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake @@ -22,7 +22,7 @@ namespace :'2017_10_30_copy_commentaire_piece_justificative_to_file' do end def sanitize_name(name) # from https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/sanitized_file.rb#L323 - name = name.gsub(/[^[:word:]\.\-\+]/,"_") + name = name.gsub(/[^[:word:]\.\-\+]/, "_") name = "_#{name}" if name.match?(/\A\.+\z/) name = "unnamed" if name.empty? return name.mb_chars.to_s diff --git a/lib/tasks/2018_01_18_clean_datetime_in_champs.rake b/lib/tasks/2018_01_18_clean_datetime_in_champs.rake index 004685b7b..a5f5bb627 100644 --- a/lib/tasks/2018_01_18_clean_datetime_in_champs.rake +++ b/lib/tasks/2018_01_18_clean_datetime_in_champs.rake @@ -19,11 +19,11 @@ namespace :'2018_01_18_clean_datetime_in_champs' do # Match "ddmmYYYY HH:MM" => "YYYY-mm-dd HH:MM" datetime_champs.select { |c| /^\d{8}\s\d{2}:\d{2}$/ =~ c.value }.each do |c| - day = c.value[0,2] - month = c.value[2,2] - year = c.value[4,4] - hours = c.value[9,2] - minutes = c.value[12,2] + day = c.value[0, 2] + month = c.value[2, 2] + year = c.value[4, 4] + hours = c.value[9, 2] + minutes = c.value[12, 2] formated_date = "#{year}-#{month}-#{day} #{hours}:#{minutes}" rake_puts "cleaning #{c.value} => #{formated_date}" c.update_columns(value: formated_date) diff --git a/lib/tasks/admin.rake b/lib/tasks/admin.rake index 60155feb1..569b6559a 100644 --- a/lib/tasks/admin.rake +++ b/lib/tasks/admin.rake @@ -2,7 +2,7 @@ namespace :admin do task :create_admin, [:email] => :environment do |t, args| email = args[:email] puts "Creating Administration for #{email}" - a = Administration.new(email: email, password: Devise.friendly_token[0,20]) + a = Administration.new(email: email, password: Devise.friendly_token[0, 20]) if a.save puts "#{a.email} created" else diff --git a/spec/models/procedure_presentation_spec.rb b/spec/models/procedure_presentation_spec.rb index f62afab48..9ed0e79a0 100644 --- a/spec/models/procedure_presentation_spec.rb +++ b/spec/models/procedure_presentation_spec.rb @@ -11,7 +11,7 @@ describe ProcedurePresentation do { "label" => "test1", "table" => "user", "column" => "email" }, { "label" => "test2", "table" => "type_de_champ", "column" => first_type_de_champ_id } ], - sort: { "table" => "user","column" => "email","order" => "asc" }, + sort: { "table" => "user", "column" => "email", "order" => "asc" }, filters: { "a-suivre" => [], "suivis" => [{ "label" => "label1", "table" => "self", "column" => "created_at" }] } ).id } @@ -22,7 +22,7 @@ describe ProcedurePresentation do end describe "#sort" do - it { expect(procedure_presentation.sort).to eq({ "table" => "user","column" => "email","order" => "asc" }) } + it { expect(procedure_presentation.sort).to eq({ "table" => "user", "column" => "email", "order" => "asc" }) } end describe "#filters" do @@ -78,10 +78,10 @@ describe ProcedurePresentation do } before do - procedure.types_de_champ[2].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:header_section)) - procedure.types_de_champ[3].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:explication)) - procedure.types_de_champ_private[2].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:header_section)) - procedure.types_de_champ_private[3].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:explication)) + procedure.types_de_champ[2].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:header_section)) + procedure.types_de_champ[3].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:explication)) + procedure.types_de_champ_private[2].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:header_section)) + procedure.types_de_champ_private[3].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:explication)) end subject { create(:procedure_presentation, assign_to: create(:assign_to, procedure: procedure)) } From 386fbce77665f802ed79170b78a121b516bf42a4 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 24 Dec 2018 17:28:20 +0100 Subject: [PATCH 05/12] Enable the Layout/SpaceBeforeBlockBraces cop --- .rubocop.yml | 2 +- app/controllers/api/v1/dossiers_controller.rb | 2 +- app/models/drop_down_list.rb | 2 +- app/models/procedure_presentation.rb | 2 +- app/uploaders/commentaire_file_uploader.rb | 2 +- .../2017_07_18_clean_followed_dossiers.rake | 2 +- ...17_07_26_clean_birthdate_on_individual.rake | 2 +- lib/tasks/2017_08_01_clean_assign_to.rake | 2 +- .../admin/procedures_controller_spec.rb | 8 ++++---- .../controllers/application_controller_spec.rb | 2 +- .../manager/administrateurs_controller_spec.rb | 2 +- .../administrateur_controller_spec.rb | 2 +- .../services_controller_spec.rb | 2 +- .../dossiers_controller_spec.rb | 8 ++++---- .../gestionnaire_controller_spec.rb | 2 +- .../procedures_controller_spec.rb | 12 ++++++------ .../new_user/dossiers_controller_spec.rb | 12 ++++++------ .../new_user/user_controller_spec.rb | 2 +- spec/controllers/stats_controller_spec.rb | 2 +- spec/models/avis_spec.rb | 18 +++++++++--------- spec/models/champ_spec.rb | 6 +++--- spec/models/gestionnaire_spec.rb | 4 ++-- spec/models/invite_spec.rb | 4 ++-- spec/models/procedure_spec.rb | 2 +- spec/models/service_spec.rb | 2 +- 25 files changed, 53 insertions(+), 53 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7cef58f1e..10eb93318 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -224,7 +224,7 @@ Layout/SpaceAroundOperators: Enabled: true Layout/SpaceBeforeBlockBraces: - Enabled: false + Enabled: true Layout/SpaceBeforeComma: Enabled: true diff --git a/app/controllers/api/v1/dossiers_controller.rb b/app/controllers/api/v1/dossiers_controller.rb index b522e3aca..68cc51c41 100644 --- a/app/controllers/api/v1/dossiers_controller.rb +++ b/app/controllers/api/v1/dossiers_controller.rb @@ -6,7 +6,7 @@ class API::V1::DossiersController < APIController def index dossiers = @dossiers.page(params[:page]).per(per_page) - render json: { dossiers: dossiers.map{ |dossier| DossiersSerializer.new(dossier) }, pagination: pagination(dossiers) }, status: 200 + render json: { dossiers: dossiers.map { |dossier| DossiersSerializer.new(dossier) }, pagination: pagination(dossiers) }, status: 200 rescue ActiveRecord::RecordNotFound render json: {}, status: 404 end diff --git a/app/models/drop_down_list.rb b/app/models/drop_down_list.rb index cc91f8611..b9b4e9a20 100644 --- a/app/models/drop_down_list.rb +++ b/app/models/drop_down_list.rb @@ -7,7 +7,7 @@ class DropDownList < ApplicationRecord end def disabled_options - options.select{ |v| (v =~ /^--.*--$/).present? } + options.select { |v| (v =~ /^--.*--$/).present? } end def selected_options(champ) diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb index 1798ece76..d06e1ece6 100644 --- a/app/models/procedure_presentation.rb +++ b/app/models/procedure_presentation.rb @@ -46,7 +46,7 @@ class ProcedurePresentation < ApplicationRecord ) end - explanatory_types_de_champ = [:header_section, :explication].map{ |k| TypeDeChamp.type_champs.fetch(k) } + explanatory_types_de_champ = [:header_section, :explication].map { |k| TypeDeChamp.type_champs.fetch(k) } fields.concat procedure.types_de_champ .reject { |tdc| explanatory_types_de_champ.include?(tdc.type_champ) } diff --git a/app/uploaders/commentaire_file_uploader.rb b/app/uploaders/commentaire_file_uploader.rb index eaa738b14..1249c94c5 100644 --- a/app/uploaders/commentaire_file_uploader.rb +++ b/app/uploaders/commentaire_file_uploader.rb @@ -18,6 +18,6 @@ class CommentaireFileUploader < BaseUploader end def accept_extension_list - extension_white_list.map{ |e| ".#{e}" }.join(",") + extension_white_list.map { |e| ".#{e}" }.join(",") end end diff --git a/lib/tasks/2017_07_18_clean_followed_dossiers.rake b/lib/tasks/2017_07_18_clean_followed_dossiers.rake index 89058da02..2c9a5f4ce 100644 --- a/lib/tasks/2017_07_18_clean_followed_dossiers.rake +++ b/lib/tasks/2017_07_18_clean_followed_dossiers.rake @@ -3,7 +3,7 @@ namespace :'2017_07_18_clean_followed_dossiers' do Follow.where(gestionnaire_id: nil).destroy_all Follow.where(dossier_id: nil).destroy_all - duplicate_follows = Follow.group('gestionnaire_id', 'dossier_id').count.select{ |_gestionnaire_id_dossier_id, count| count > 1 }.keys + duplicate_follows = Follow.group('gestionnaire_id', 'dossier_id').count.select { |_gestionnaire_id_dossier_id, count| count > 1 }.keys duplicate_ids = duplicate_follows.map { |gestionnaire_id, dossier_id| Follow.where(gestionnaire_id: gestionnaire_id, dossier_id: dossier_id).pluck(:id) } diff --git a/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake b/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake index 659d37633..caa4c674f 100644 --- a/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake +++ b/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake @@ -3,7 +3,7 @@ require Rails.root.join("lib", "tasks", "task_helper") namespace :'2017_07_26_clean_birthdate_on_individual' do task clean: :environment do # remove duplicates - duplicate_individuals = Individual.group("dossier_id").count.select{ |_dossier_id, count| count > 1 }.keys + duplicate_individuals = Individual.group("dossier_id").count.select { |_dossier_id, count| count > 1 }.keys duplicate_individuals.each { |dossier_id| Individual.where(dossier_id: dossier_id, nom: nil).delete_all } # Match "" => nil diff --git a/lib/tasks/2017_08_01_clean_assign_to.rake b/lib/tasks/2017_08_01_clean_assign_to.rake index fd407a956..bbc2d86dd 100644 --- a/lib/tasks/2017_08_01_clean_assign_to.rake +++ b/lib/tasks/2017_08_01_clean_assign_to.rake @@ -1,6 +1,6 @@ namespace :'2017_08_01_clean_assign_to' do task clean: :environment do - duplicates = AssignTo.group(:gestionnaire_id, :procedure_id).count.select{ |_gestionnaire_id_procedure_id, count| count > 1 }.keys + duplicates = AssignTo.group(:gestionnaire_id, :procedure_id).count.select { |_gestionnaire_id_procedure_id, count| count > 1 }.keys duplicate_ids = duplicates.map { |gestionnaire_id, procedure_id| AssignTo.where(gestionnaire_id: gestionnaire_id, procedure_id: procedure_id).pluck(:id) } diff --git a/spec/controllers/admin/procedures_controller_spec.rb b/spec/controllers/admin/procedures_controller_spec.rb index d6d7b5ffe..10c7f2828 100644 --- a/spec/controllers/admin/procedures_controller_spec.rb +++ b/spec/controllers/admin/procedures_controller_spec.rb @@ -134,7 +134,7 @@ describe Admin::ProceduresController, type: :controller do subject { delete :destroy, params: { id: procedure_not_owned.id } } - it { expect{ subject }.to raise_error(ActiveRecord::RecordNotFound) } + it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) } end end @@ -511,7 +511,7 @@ describe Admin::ProceduresController, type: :controller do subject { get :new_from_existing } let(:grouped_procedures) { subject; assigns(:grouped_procedures) } - let(:response_procedures) { grouped_procedures.map{ |o, procedures| procedures }.flatten } + let(:response_procedures) { grouped_procedures.map { |o, procedures| procedures }.flatten } describe 'selecting' do let!(:large_draft_procedure) { create(:procedure_with_dossiers, dossiers_count: 2) } @@ -542,8 +542,8 @@ describe Admin::ProceduresController, type: :controller do it 'groups procedures with services as well as procedures with organisations' do expect(grouped_procedures.length).to eq 2 - expect(grouped_procedures.find{ |o, p| o == 'DDT des Vosges' }.last).to contain_exactly(procedure_with_service_1) - expect(grouped_procedures.find{ |o, p| o == 'DDT du Loiret' }.last).to contain_exactly(procedure_with_service_2, procedure_without_service) + expect(grouped_procedures.find { |o, p| o == 'DDT des Vosges' }.last).to contain_exactly(procedure_with_service_1) + expect(grouped_procedures.find { |o, p| o == 'DDT du Loiret' }.last).to contain_exactly(procedure_with_service_2, procedure_without_service) end end end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 0fc0ec700..0545d786b 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -5,7 +5,7 @@ describe ApplicationController, type: :controller do it 'is present' do before_actions = ApplicationController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:set_raven_context) diff --git a/spec/controllers/manager/administrateurs_controller_spec.rb b/spec/controllers/manager/administrateurs_controller_spec.rb index 432aa9daa..fb72fb129 100644 --- a/spec/controllers/manager/administrateurs_controller_spec.rb +++ b/spec/controllers/manager/administrateurs_controller_spec.rb @@ -1,5 +1,5 @@ describe Manager::AdministrateursController, type: :controller do - let(:administration){ create(:administration) } + let(:administration) { create(:administration) } describe 'POST #create' do let(:email) { 'plop@plop.com' } diff --git a/spec/controllers/new_administrateur/administrateur_controller_spec.rb b/spec/controllers/new_administrateur/administrateur_controller_spec.rb index 81ac03e93..6dbd65ffd 100644 --- a/spec/controllers/new_administrateur/administrateur_controller_spec.rb +++ b/spec/controllers/new_administrateur/administrateur_controller_spec.rb @@ -3,7 +3,7 @@ describe NewAdministrateur::AdministrateurController, type: :controller do it 'is present' do before_actions = NewAdministrateur::AdministrateurController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:authenticate_administrateur!) diff --git a/spec/controllers/new_administrateur/services_controller_spec.rb b/spec/controllers/new_administrateur/services_controller_spec.rb index bddd7f679..081603342 100644 --- a/spec/controllers/new_administrateur/services_controller_spec.rb +++ b/spec/controllers/new_administrateur/services_controller_spec.rb @@ -118,7 +118,7 @@ describe NewAdministrateur::ServicesController, type: :controller do delete :destroy, params: { id: service.id, procedure_id: 12 } end - it { expect{ service.reload }.to raise_error(ActiveRecord::RecordNotFound) } + it { expect { service.reload }.to raise_error(ActiveRecord::RecordNotFound) } it { expect(flash.alert).to be_nil } it { expect(flash.notice).to eq("#{service.nom} est supprimé") } it { expect(response).to redirect_to(services_path(procedure_id: 12)) } diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 8221c6491..39c9137b5 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -412,7 +412,7 @@ describe NewGestionnaire::DossiersController, type: :controller do subject { delete :purge_champ_piece_justificative, params: { procedure_id: champ.dossier.procedure.id, dossier_id: champ.dossier.id, champ_id: champ.id }, format: :js } context 'when gestionnaire can process dossier' do - let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id, private: true) } + let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id, private: true) } it { is_expected.to have_http_status(200) } @@ -422,7 +422,7 @@ describe NewGestionnaire::DossiersController, type: :controller do end context 'but champ is not linked to this dossier' do - let(:champ){ create(:champ_piece_justificative, dossier: create(:dossier), private: true) } + let(:champ) { create(:champ_piece_justificative, dossier: create(:dossier), private: true) } it { is_expected.to redirect_to(root_path) } @@ -434,8 +434,8 @@ describe NewGestionnaire::DossiersController, type: :controller do end context 'when gestionnaire cannot process dossier' do - let(:dossier){ create(:dossier, procedure: create(:procedure)) } - let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id, private: true) } + let(:dossier) { create(:dossier, procedure: create(:procedure)) } + let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id, private: true) } it { is_expected.to redirect_to(root_path) } diff --git a/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb b/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb index 83c189582..36a31b204 100644 --- a/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb @@ -5,7 +5,7 @@ describe NewGestionnaire::GestionnaireController, type: :controller do it 'is present' do before_actions = NewGestionnaire::GestionnaireController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:authenticate_gestionnaire!) diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index d89d73871..772a9bcff 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -5,7 +5,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do it "is present" do before_actions = NewGestionnaire::ProceduresController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:ensure_ownership!) @@ -46,7 +46,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do it "is present" do before_actions = NewGestionnaire::ProceduresController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:redirect_to_avis_if_needed) @@ -253,10 +253,10 @@ describe NewGestionnaire::ProceduresController, type: :controller do end describe 'statut' do - let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } } - let!(:new_followed_dossier) { Timecop.freeze(2.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } } - let!(:termine_dossier) { Timecop.freeze(3.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:accepte)) } } - let!(:archived_dossier) { Timecop.freeze(4.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction), archived: true) } } + let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } } + let!(:new_followed_dossier) { Timecop.freeze(2.days.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } } + let!(:termine_dossier) { Timecop.freeze(3.days.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:accepte)) } } + let!(:archived_dossier) { Timecop.freeze(4.days.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction), archived: true) } } before do gestionnaire.followed_dossiers << new_followed_dossier diff --git a/spec/controllers/new_user/dossiers_controller_spec.rb b/spec/controllers/new_user/dossiers_controller_spec.rb index d404218fc..d2e42693d 100644 --- a/spec/controllers/new_user/dossiers_controller_spec.rb +++ b/spec/controllers/new_user/dossiers_controller_spec.rb @@ -7,7 +7,7 @@ describe NewUser::DossiersController, type: :controller do it 'are present' do before_actions = NewUser::DossiersController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:ensure_ownership!, :ensure_ownership_or_invitation!, :forbid_invite_submission!) @@ -913,8 +913,8 @@ describe NewUser::DossiersController, type: :controller do subject { delete :purge_champ_piece_justificative, params: { id: champ.dossier.id, champ_id: champ.id }, format: :js } context 'when dossier is owned by user' do - let(:dossier){ create(:dossier, user: user) } - let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id) } + let(:dossier) { create(:dossier, user: user) } + let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id) } it { is_expected.to have_http_status(200) } @@ -924,7 +924,7 @@ describe NewUser::DossiersController, type: :controller do end context 'but champ is not linked to this dossier' do - let(:champ){ create(:champ_piece_justificative, dossier: create(:dossier)) } + let(:champ) { create(:champ_piece_justificative, dossier: create(:dossier)) } it { is_expected.to redirect_to(root_path) } @@ -936,8 +936,8 @@ describe NewUser::DossiersController, type: :controller do end context 'when dossier is not owned by user' do - let(:dossier){ create(:dossier, user: create(:user)) } - let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id) } + let(:dossier) { create(:dossier, user: create(:user)) } + let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id) } it { is_expected.to redirect_to(root_path) } diff --git a/spec/controllers/new_user/user_controller_spec.rb b/spec/controllers/new_user/user_controller_spec.rb index b4e93c10c..82908835d 100644 --- a/spec/controllers/new_user/user_controller_spec.rb +++ b/spec/controllers/new_user/user_controller_spec.rb @@ -5,7 +5,7 @@ describe NewUser::UserController, type: :controller do it 'is present' do before_actions = NewUser::UserController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:authenticate_user!) diff --git a/spec/controllers/stats_controller_spec.rb b/spec/controllers/stats_controller_spec.rb index 4f2632724..6fd3f5c2c 100644 --- a/spec/controllers/stats_controller_spec.rb +++ b/spec/controllers/stats_controller_spec.rb @@ -116,7 +116,7 @@ describe StatsController, type: :controller do create(:procedure, published_at: Time.zone.now, administrateur: administrateur_4) end - let(:association){ Procedure.all } + let(:association) { Procedure.all } subject { StatsController.new.send(:procedures_count_per_administrateur, association) } diff --git a/spec/models/avis_spec.rb b/spec/models/avis_spec.rb index c692f0d60..d55b4afd0 100644 --- a/spec/models/avis_spec.rb +++ b/spec/models/avis_spec.rb @@ -14,21 +14,21 @@ RSpec.describe Avis, type: :model do subject { avis.email_to_display } context 'when gestionnaire is not known' do - it{ is_expected.to eq(invited_email) } + it { is_expected.to eq(invited_email) } end context 'when gestionnaire is known' do let!(:avis) { create(:avis, email: nil, gestionnaire: create(:gestionnaire), dossier: create(:dossier)) } - it{ is_expected.to eq(avis.gestionnaire.email) } + it { is_expected.to eq(avis.gestionnaire.email) } end end describe '.by_latest' do context 'with 3 avis' do - let!(:avis){ create(:avis) } - let!(:avis2){ create(:avis, updated_at: 4.hours.ago) } - let!(:avis3){ create(:avis, updated_at: 3.hours.ago) } + let!(:avis) { create(:avis) } + let!(:avis2) { create(:avis, updated_at: 4.hours.ago) } + let!(:avis3) { create(:avis, updated_at: 3.hours.ago) } subject { Avis.by_latest } @@ -37,13 +37,13 @@ RSpec.describe Avis, type: :model do end describe ".link_avis_to_gestionnaire" do - let(:gestionnaire){ create(:gestionnaire) } + let(:gestionnaire) { create(:gestionnaire) } - subject{ Avis.link_avis_to_gestionnaire(gestionnaire) } + subject { Avis.link_avis_to_gestionnaire(gestionnaire) } context 'when there are 2 avis linked by email to a gestionnaire' do - let!(:avis){ create(:avis, email: gestionnaire.email, gestionnaire: nil) } - let!(:avis2){ create(:avis, email: gestionnaire.email, gestionnaire: nil) } + let!(:avis) { create(:avis, email: gestionnaire.email, gestionnaire: nil) } + let!(:avis2) { create(:avis, email: gestionnaire.email, gestionnaire: nil) } before do subject diff --git a/spec/models/champ_spec.rb b/spec/models/champ_spec.rb index a47d82206..461aa4fdb 100644 --- a/spec/models/champ_spec.rb +++ b/spec/models/champ_spec.rb @@ -385,18 +385,18 @@ describe Champ do context 'and there is a blob' do before { champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain") } - it { expect{ champ.save }.to change(VirusScan, :count).by(1) } + it { expect { champ.save }.to change(VirusScan, :count).by(1) } end context 'and there is no blob' do - it { expect{ champ.save }.to_not change(VirusScan, :count) } + it { expect { champ.save }.to_not change(VirusScan, :count) } end end context 'when type_champ is not type_de_champ_piece_justificative' do let(:type_de_champ) { create(:type_de_champ_textarea) } - it { expect{ champ.save }.to_not change(VirusScan, :count) } + it { expect { champ.save }.to_not change(VirusScan, :count) } end end diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index e24b6d353..d7556d527 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -95,14 +95,14 @@ describe Gestionnaire, type: :model do let(:procedure_to_assign) { procedure_3 } it { is_expected.to be_truthy } - it { expect{ subject }.to change(gestionnaire.procedures, :count) } + it { expect { subject }.to change(gestionnaire.procedures, :count) } end context "with an already assigned procedure" do let(:procedure_to_assign) { procedure } it { is_expected.to be_falsey } - it { expect{ subject }.not_to change(gestionnaire.procedures, :count) } + it { expect { subject }.not_to change(gestionnaire.procedures, :count) } end end diff --git a/spec/models/invite_spec.rb b/spec/models/invite_spec.rb index 66eb762b6..1b3929b91 100644 --- a/spec/models/invite_spec.rb +++ b/spec/models/invite_spec.rb @@ -13,7 +13,7 @@ describe Invite do create(:invite, email: email1, dossier: dossier2) end - it { expect{ subject }.to change(Invite, :count).by(2) } + it { expect { subject }.to change(Invite, :count).by(2) } end context 'when an email is invite twice on a dossier' do @@ -22,7 +22,7 @@ describe Invite do create(:invite, email: email1, dossier: dossier1) end - it { expect{ subject }.to raise_error ActiveRecord::RecordInvalid } + it { expect { subject }.to raise_error ActiveRecord::RecordInvalid } end context "email validation" do diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index f4c2df6d7..355aa27e7 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -537,7 +537,7 @@ describe Procedure do end describe '#default_path' do - let(:procedure){ create(:procedure, libelle: 'A long libelle with àccênts, blabla coucou hello un deux trois voila') } + let(:procedure) { create(:procedure, libelle: 'A long libelle with àccênts, blabla coucou hello un deux trois voila') } subject { procedure.default_path } diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index adf6baefb..2a24cc89f 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -44,7 +44,7 @@ describe Service, type: :model do context 'of type_organisme' do it 'should belong to the enum' do - expect{ Service.new(params.merge(type_organisme: 'choucroute')) }.to raise_error(ArgumentError) + expect { Service.new(params.merge(type_organisme: 'choucroute')) }.to raise_error(ArgumentError) end end end From 186e3627017b2a89ffd6ac8a3cee88e650dbda98 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 24 Dec 2018 17:29:46 +0100 Subject: [PATCH 06/12] Enable the Layout/SpaceInsideArrayLiteralBrackets --- .rubocop.yml | 3 +- app/models/champ.rb | 2 +- app/models/champs/checkbox_champ.rb | 2 +- app/models/champs/engagement_champ.rb | 2 +- .../champs/linked_drop_down_list_champ.rb | 4 +-- app/models/champs/siret_champ.rb | 2 +- app/models/champs/yes_no_champ.rb | 2 +- app/models/procedure_presentation.rb | 2 +- ...te_active_storage_tables.active_storage.rb | 4 +-- .../conservation_de_donnees_helper_spec.rb | 6 ++-- spec/models/champ_spec.rb | 36 +++++++++---------- ...inked_drop_down_list_type_de_champ_spec.rb | 6 ++-- 12 files changed, 36 insertions(+), 35 deletions(-) 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 From d473119f9d81c078a666a755b0c8376217643478 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 24 Dec 2018 17:36:18 +0100 Subject: [PATCH 07/12] Enable the Lint/ParenthesesAsGroupedExpression cop --- .rubocop.yml | 4 +++- app/controllers/admin_controller.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index c48d754f1..37e8dae9d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -394,7 +394,9 @@ Lint/OrderedMagicComments: Enabled: true Lint/ParenthesesAsGroupedExpression: - Enabled: false + Enabled: true + Exclude: + - "spec/**/*" Lint/PercentStringArray: Enabled: false diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 235ef781f..175795308 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -2,7 +2,7 @@ class AdminController < ApplicationController before_action :authenticate_administrateur! def index - redirect_to (admin_procedures_path) + redirect_to(admin_procedures_path) end def retrieve_procedure From baf79777865a2e0ded04dc92b6b12a735dfe77ba Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 24 Dec 2018 17:43:12 +0100 Subject: [PATCH 08/12] Enable the Lint/StringConversionInInterpolation cop --- .rubocop.yml | 2 +- app/controllers/stats_controller.rb | 6 +++--- app/models/champs/piece_justificative_champ.rb | 4 ++-- app/services/render_partial_service.rb | 2 +- lib/tasks/2018_09_12_fix_templates.rake | 2 +- .../20181120133842_remove_footer_from_email_templates.rake | 2 +- .../20181219122438_fix_email_templates_subjects.rake | 2 +- spec/services/render_partial_service_spec.rb | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 37e8dae9d..1c87a465c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -444,7 +444,7 @@ Lint/ShadowingOuterLocalVariable: Enabled: false Lint/StringConversionInInterpolation: - Enabled: false + Enabled: true Lint/Syntax: Enabled: true diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index d37af55f4..28d24a4b8 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -211,7 +211,7 @@ class StatsController < ApplicationController association .where(date_attribute => min_date..max_date) - .group("DATE_TRUNC('month', #{date_attribute.to_s})") + .group("DATE_TRUNC('month', #{date_attribute})") .count .to_a .sort_by { |a| a[0] } @@ -221,8 +221,8 @@ class StatsController < ApplicationController def cumulative_hash(association, date_attribute) sum = 0 association - .where("#{date_attribute.to_s} < ?", max_date) - .group("DATE_TRUNC('month', #{date_attribute.to_s})") + .where("#{date_attribute} < ?", max_date) + .group("DATE_TRUNC('month', #{date_attribute})") .count .to_a .sort_by { |a| a[0] } diff --git a/app/models/champs/piece_justificative_champ.rb b/app/models/champs/piece_justificative_champ.rb index 6aa1c39aa..315cc1988 100644 --- a/app/models/champs/piece_justificative_champ.rb +++ b/app/models/champs/piece_justificative_champ.rb @@ -31,11 +31,11 @@ class Champs::PieceJustificativeChamp < Champ if piece_justificative_file.attached? && piece_justificative_file.previous_changes.present? if piece_justificative_file.blob.byte_size > PIECE_JUSTIFICATIVE_FILE_MAX_SIZE - errors << "Le fichier #{piece_justificative_file.filename.to_s} est trop lourd, il doit faire au plus #{PIECE_JUSTIFICATIVE_FILE_MAX_SIZE.to_s(:human_size, precision: 2)}" + errors << "Le fichier #{piece_justificative_file.filename} est trop lourd, il doit faire au plus #{PIECE_JUSTIFICATIVE_FILE_MAX_SIZE.to_s(:human_size, precision: 2)}" end if !piece_justificative_file.blob.content_type.in?(PIECE_JUSTIFICATIVE_FILE_ACCEPTED_FORMATS) - errors << "Le fichier #{piece_justificative_file.filename.to_s} est dans un format que nous n'acceptons pas" + errors << "Le fichier #{piece_justificative_file.filename} est dans un format que nous n'acceptons pas" end # FIXME: add Clamav check diff --git a/app/services/render_partial_service.rb b/app/services/render_partial_service.rb index b54a594f7..9bfb61445 100644 --- a/app/services/render_partial_service.rb +++ b/app/services/render_partial_service.rb @@ -31,6 +31,6 @@ class RenderPartialService end def retrieve_name - "#{controller.to_s.parameterize.underscore}_#{method.to_s}" + "#{controller.to_s.parameterize.underscore}_#{method}" end end diff --git a/lib/tasks/2018_09_12_fix_templates.rake b/lib/tasks/2018_09_12_fix_templates.rake index 8ca36b559..9c374649c 100644 --- a/lib/tasks/2018_09_12_fix_templates.rake +++ b/lib/tasks/2018_09_12_fix_templates.rake @@ -46,7 +46,7 @@ namespace :'2018_09_12_fix_templates' do .each do |instance| instance.update(body: instance.body.gsub("--libellé procédure--", "--libellé démarche--")) - rake_puts "Body mis-à-jour pour #{klass.to_s}##{instance.id}" + rake_puts "Body mis-à-jour pour #{klass}##{instance.id}" end end end diff --git a/lib/tasks/deployment/20181120133842_remove_footer_from_email_templates.rake b/lib/tasks/deployment/20181120133842_remove_footer_from_email_templates.rake index c411ced10..c42d3f6ed 100644 --- a/lib/tasks/deployment/20181120133842_remove_footer_from_email_templates.rake +++ b/lib/tasks/deployment/20181120133842_remove_footer_from_email_templates.rake @@ -47,7 +47,7 @@ namespace :after_party do def remove_footer(template) matches = template.body.match(FOOTER_REGEXP) if matches && FOOTER_EXCEPTIONS.none? { |exception| matches[0].include?(exception) } - rake_puts "#{template.model_name.to_s} \##{template.id}: removing footer" + rake_puts "#{template.model_name} \##{template.id}: removing footer" template.update(body: matches.pre_match) end end diff --git a/lib/tasks/deployment/20181219122438_fix_email_templates_subjects.rake b/lib/tasks/deployment/20181219122438_fix_email_templates_subjects.rake index f0f9a2704..fb3677251 100644 --- a/lib/tasks/deployment/20181219122438_fix_email_templates_subjects.rake +++ b/lib/tasks/deployment/20181219122438_fix_email_templates_subjects.rake @@ -17,7 +17,7 @@ namespace :after_party do .each do |instance| instance.update(subject: instance.subject.gsub("--libellé procédure--", "--libellé démarche--")) - rake_puts "Subject mis-à-jour pour #{klass.to_s}##{instance.id}" + rake_puts "Subject mis-à-jour pour #{klass}##{instance.id}" end end diff --git a/spec/services/render_partial_service_spec.rb b/spec/services/render_partial_service_spec.rb index 9f0e30533..fa5306e61 100644 --- a/spec/services/render_partial_service_spec.rb +++ b/spec/services/render_partial_service_spec.rb @@ -8,12 +8,12 @@ describe RenderPartialService do describe 'navbar' do subject { service.navbar } - it { is_expected.to eq "layouts/navbars/navbar_#{controller.to_s.parameterize}_#{method.to_s}" } + it { is_expected.to eq "layouts/navbars/navbar_#{controller.to_s.parameterize}_#{method}" } end describe 'left_panel' do subject { service.left_panel } - it { is_expected.to eq "layouts/left_panels/left_panel_#{controller.to_s.parameterize}_#{method.to_s}" } + it { is_expected.to eq "layouts/left_panels/left_panel_#{controller.to_s.parameterize}_#{method}" } end end From ddc71cbacf9fac762b4233b1bea02f563c63bef8 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 24 Dec 2018 17:48:29 +0100 Subject: [PATCH 09/12] Enable the Lint/UnderscorePrefixedVariableName cop --- .rubocop.yml | 2 +- spec/factories/procedure.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1c87a465c..0ca1f41c4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -450,7 +450,7 @@ Lint/Syntax: Enabled: true Lint/UnderscorePrefixedVariableName: - Enabled: false + Enabled: true Lint/UnifiedInteger: Enabled: true diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index c26c4b7ce..d99aa43c6 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -16,8 +16,8 @@ FactoryBot.define do dossiers_count { 1 } end - after(:build) do |procedure, _evaluator| - procedure.dossiers << create_list(:dossier, _evaluator.dossiers_count, procedure: procedure) + after(:build) do |procedure, evaluator| + procedure.dossiers << create_list(:dossier, evaluator.dossiers_count, procedure: procedure) end end From 0596d53ac2cbba82f01ab3334f39992e0e3fda70 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 24 Dec 2018 17:53:16 +0100 Subject: [PATCH 10/12] Enable the Lint/UnusedBlockArgument cop --- .rubocop.yml | 2 +- app/controllers/stats_controller.rb | 2 +- app/models/etablissement.rb | 2 +- config/initializers/after_party.rb | 2 +- config/initializers/env_vars.rb | 2 +- .../20170215102943_remove_duplicate_email_received.rb | 2 +- lib/tasks/2018_02_28_clean_gestionnaire_emails.rake | 4 ++-- lib/tasks/admin.rake | 4 ++-- spec/controllers/admin/procedures_controller_spec.rb | 6 +++--- spec/factories/champ.rb | 6 +++--- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0ca1f41c4..0852a6e43 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -471,7 +471,7 @@ Lint/UnreachableCode: Enabled: true Lint/UnusedBlockArgument: - Enabled: false + Enabled: true Lint/UnusedMethodArgument: Enabled: false diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 28d24a4b8..750d46be1 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -271,7 +271,7 @@ class StatsController < ApplicationController dossiers_grouped_by_procedure = value.group_by { |dossier| dossier[0] } # Compute the mean time for this procedure - procedure_processing_times = dossiers_grouped_by_procedure.map do |procedure_id, procedure_dossiers| + procedure_processing_times = dossiers_grouped_by_procedure.map do |_procedure_id, procedure_dossiers| procedure_dossiers_processing_time = procedure_dossiers.map do |dossier| (dossier[2] - dossier[1]).to_f / (3600 * 24) end diff --git a/app/models/etablissement.rb b/app/models/etablissement.rb index 1656f1f74..44e5142e9 100644 --- a/app/models/etablissement.rb +++ b/app/models/etablissement.rb @@ -91,6 +91,6 @@ class Etablissement < ApplicationRecord def message_for_signature JSON.pretty_generate(as_json(include: { exercices: { only: [:ca, :date_fin_exercice, :date_fin_exercice_timestamp] } - }).delete_if { |k, v| v.blank? }) + }).delete_if { |_k, v| v.blank? }) end end diff --git a/config/initializers/after_party.rb b/config/initializers/after_party.rb index 66c8b1071..e9ef95728 100644 --- a/config/initializers/after_party.rb +++ b/config/initializers/after_party.rb @@ -1,3 +1,3 @@ -AfterParty.setup do |config| +AfterParty.setup do |_config| require "after_party/active_record.rb" end diff --git a/config/initializers/env_vars.rb b/config/initializers/env_vars.rb index 9046a8c80..a3a7cd20b 100644 --- a/config/initializers/env_vars.rb +++ b/config/initializers/env_vars.rb @@ -5,7 +5,7 @@ if ENV['RAILS_ENV'] != 'test' && File.basename($0) != 'rake' reference_env_file = File.join('config', 'env.example') - Dotenv::Environment.new(Rails.root.join(reference_env_file)).each do |key, value| + Dotenv::Environment.new(Rails.root.join(reference_env_file)).each do |key, _value| if !ENV.key?(key.to_s) raise "Configuration error: `#{key}` is not present in the process’ environment variables (declared in `#{reference_env_file}`)" end diff --git a/db/migrate/20170215102943_remove_duplicate_email_received.rb b/db/migrate/20170215102943_remove_duplicate_email_received.rb index 93f052b10..af2c6badd 100644 --- a/db/migrate/20170215102943_remove_duplicate_email_received.rb +++ b/db/migrate/20170215102943_remove_duplicate_email_received.rb @@ -2,7 +2,7 @@ class RemoveDuplicateEmailReceived < ActiveRecord::Migration[5.0] def change all_mails = MailReceived.all groupped = all_mails.group_by(&:procedure_id) - filtered = groupped.reject { |k, v| v.length < 2 } + filtered = groupped.reject { |_k, v| v.length < 2 } filtered.each_value do |duplicate_mails| duplicate_mails.pop duplicate_mails.each(&:destroy) diff --git a/lib/tasks/2018_02_28_clean_gestionnaire_emails.rake b/lib/tasks/2018_02_28_clean_gestionnaire_emails.rake index dc3c581bc..6106ae5ab 100644 --- a/lib/tasks/2018_02_28_clean_gestionnaire_emails.rake +++ b/lib/tasks/2018_02_28_clean_gestionnaire_emails.rake @@ -1,10 +1,10 @@ namespace :'2018_02_28_clean_invalid_emails_accounts' do task clean: :environment do - Gestionnaire.pluck(:email, :id).select { |e, id| e.include?(" ") }.each do |email, id| + Gestionnaire.pluck(:email, :id).select { |e, _id| e.include?(" ") }.each do |_email, id| Gestionnaire.find_by(id: id, current_sign_in_at: nil)&.destroy # ensure account was never used end - User.pluck(:email, :id).select { |e, id| e.include?(" ") }.each do |email, id| + User.pluck(:email, :id).select { |e, _id| e.include?(" ") }.each do |_email, id| User.find_by(id: id, current_sign_in_at: nil)&.destroy # ensure account was never used end end diff --git a/lib/tasks/admin.rake b/lib/tasks/admin.rake index 569b6559a..01dd504e6 100644 --- a/lib/tasks/admin.rake +++ b/lib/tasks/admin.rake @@ -1,5 +1,5 @@ namespace :admin do - task :create_admin, [:email] => :environment do |t, args| + task :create_admin, [:email] => :environment do |_t, args| email = args[:email] puts "Creating Administration for #{email}" a = Administration.new(email: email, password: Devise.friendly_token[0, 20]) @@ -17,7 +17,7 @@ namespace :admin do end end - task :delete_admin, [:email] => :environment do |t, args| + task :delete_admin, [:email] => :environment do |_t, args| email = args[:email] puts "Deleting Administration for #{email}" a = Administration.find_by(email: email) diff --git a/spec/controllers/admin/procedures_controller_spec.rb b/spec/controllers/admin/procedures_controller_spec.rb index 10c7f2828..7a0a0483c 100644 --- a/spec/controllers/admin/procedures_controller_spec.rb +++ b/spec/controllers/admin/procedures_controller_spec.rb @@ -511,7 +511,7 @@ describe Admin::ProceduresController, type: :controller do subject { get :new_from_existing } let(:grouped_procedures) { subject; assigns(:grouped_procedures) } - let(:response_procedures) { grouped_procedures.map { |o, procedures| procedures }.flatten } + let(:response_procedures) { grouped_procedures.map { |_o, procedures| procedures }.flatten } describe 'selecting' do let!(:large_draft_procedure) { create(:procedure_with_dossiers, dossiers_count: 2) } @@ -542,8 +542,8 @@ describe Admin::ProceduresController, type: :controller do it 'groups procedures with services as well as procedures with organisations' do expect(grouped_procedures.length).to eq 2 - expect(grouped_procedures.find { |o, p| o == 'DDT des Vosges' }.last).to contain_exactly(procedure_with_service_1) - expect(grouped_procedures.find { |o, p| o == 'DDT du Loiret' }.last).to contain_exactly(procedure_with_service_2, procedure_without_service) + expect(grouped_procedures.find { |o, _p| o == 'DDT des Vosges' }.last).to contain_exactly(procedure_with_service_1) + expect(grouped_procedures.find { |o, _p| o == 'DDT du Loiret' }.last).to contain_exactly(procedure_with_service_2, procedure_without_service) end end end diff --git a/spec/factories/champ.rb b/spec/factories/champ.rb index 20d04628d..c1cb471e7 100644 --- a/spec/factories/champ.rb +++ b/spec/factories/champ.rb @@ -23,7 +23,7 @@ FactoryBot.define do end trait :with_piece_justificative_file do - after(:create) do |champ, evaluator| + after(:create) do |champ, _evaluator| champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain") end end @@ -147,7 +147,7 @@ FactoryBot.define do factory :champ_piece_justificative, class: 'Champs::PieceJustificativeChamp' do type_de_champ { create(:type_de_champ_piece_justificative) } - after(:create) do |champ, evaluator| + after(:create) do |champ, _evaluator| champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain") end end @@ -161,7 +161,7 @@ FactoryBot.define do association :etablissement, factory: [:etablissement] value { '44011762001530' } - after(:build) do |champ, evaluator| + after(:build) do |champ, _evaluator| champ.etablissement.signature = champ.etablissement.sign end end From 0336ecf639b7a2e32482ae0b422a84108dffe68a Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 24 Dec 2018 17:56:04 +0100 Subject: [PATCH 11/12] Remove useless arguments from some methods --- app/jobs/auto_receive_dossiers_for_procedure_job.rb | 2 +- spec/features/new_gestionnaire/gestionnaire_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/jobs/auto_receive_dossiers_for_procedure_job.rb b/app/jobs/auto_receive_dossiers_for_procedure_job.rb index 6ff7fa117..f55de439f 100644 --- a/app/jobs/auto_receive_dossiers_for_procedure_job.rb +++ b/app/jobs/auto_receive_dossiers_for_procedure_job.rb @@ -1,7 +1,7 @@ class AutoReceiveDossiersForProcedureJob < ApplicationJob queue_as :cron - def perform(procedure_id, state, gestionnaire_id = nil) + def perform(procedure_id, state) procedure = Procedure.find(procedure_id) gestionnaire = procedure.gestionnaire_for_cron_job diff --git a/spec/features/new_gestionnaire/gestionnaire_spec.rb b/spec/features/new_gestionnaire/gestionnaire_spec.rb index 220d28d93..dd0aab750 100644 --- a/spec/features/new_gestionnaire/gestionnaire_spec.rb +++ b/spec/features/new_gestionnaire/gestionnaire_spec.rb @@ -105,7 +105,7 @@ feature 'The gestionnaire part' do avis = dossier.avis.first test_mail(expert_email, sign_up_gestionnaire_avis_path(avis, expert_email)) - avis_sign_up(avis, expert_email, 'a good password') + avis_sign_up(avis, expert_email) expect(page).to have_current_path(gestionnaire_avis_index_path) expect(page).to have_text('avis à donner 1') @@ -225,7 +225,7 @@ feature 'The gestionnaire part' do texts.each { |text| expect(page).to have_text(text) } end - def avis_sign_up(avis, email, password) + def avis_sign_up(avis, email) visit sign_up_gestionnaire_avis_path(avis, email) fill_in 'gestionnaire_password', with: 'a good password' click_on 'Créer un compte' From 0c8b228fbfe4a5dd769679df4972771e2de4d5e9 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 24 Dec 2018 18:00:32 +0100 Subject: [PATCH 12/12] Enable the Lint/UselessAssignment cop --- .rubocop.yml | 4 +++- app/services/pieces_justificatives_service.rb | 2 +- app/services/procedure_export_service.rb | 3 ++- lib/tasks/2018_09_12_fix_templates.rake | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0852a6e43..0217ec321 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -486,7 +486,9 @@ Lint/UselessAccessModifier: Enabled: false Lint/UselessAssignment: - Enabled: false + Enabled: true + Exclude: + - "spec/**/*" Lint/UselessComparison: Enabled: true diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index b9ef0f767..6a68a0d7b 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -10,7 +10,7 @@ class PiecesJustificativesService errors = with_virus .map { |_, content| "#{content.original_filename} : virus détecté" } - errors += without_virus + errors + without_virus .map { |tpj, content| save_pj(content, dossier, tpj, user) } .compact() end diff --git a/app/services/procedure_export_service.rb b/app/services/procedure_export_service.rb index a025c4ee4..98263e9b7 100644 --- a/app/services/procedure_export_service.rb +++ b/app/services/procedure_export_service.rb @@ -212,7 +212,8 @@ class ProcedureExportService etablissement.champ.dossier_id, label_for_export(etablissement.champ.libelle).to_s ] - data += etablissement_data(etablissement) + + data + etablissement_data(etablissement) end end diff --git a/lib/tasks/2018_09_12_fix_templates.rake b/lib/tasks/2018_09_12_fix_templates.rake index 9c374649c..cb4535304 100644 --- a/lib/tasks/2018_09_12_fix_templates.rake +++ b/lib/tasks/2018_09_12_fix_templates.rake @@ -2,7 +2,7 @@ namespace :'2018_09_12_fix_templates' do task run: :environment do dossiers_with_invalid_attestations = find_dossiers_with_sent_and_invalid_attestations fix_templates - fixed_attestations = delete_then_regenerate_attestations(dossiers_with_invalid_attestations) + delete_then_regenerate_attestations(dossiers_with_invalid_attestations) send_regenerated_attestations(dossiers_with_invalid_attestations) end