From e452fa83431dd71f2a5a54c65ed89797c58e834a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chai=CC=88b=20Martinez?= Date: Tue, 2 Oct 2018 17:43:40 +0200 Subject: [PATCH 01/17] [Fix #2432] Warn admins to always share a direct link to their demarche --- app/views/admin/procedures/_modal_publish.html.haml | 3 +++ app/views/admin/procedures/show.html.haml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/app/views/admin/procedures/_modal_publish.html.haml b/app/views/admin/procedures/_modal_publish.html.haml index 03a3faff8..2109792ae 100644 --- a/app/views/admin/procedures/_modal_publish.html.haml +++ b/app/views/admin/procedures/_modal_publish.html.haml @@ -28,6 +28,9 @@ class: 'form-control', maxlength: 50, style: 'width: 300px; display: inline;') + %br + .alert.alert-info + Attention, diffusez toujours le lien complet affiché ci-dessus, et non pas un lien générique vers demarches-simplifiees.fr. Ne dites pas non plus aux usagers de se rendre sur le site générique demarches-simplifiees.fr, donnez-leur toujours le lien complet. #path-messages #path_is_mine.text-warning.center.message Ce lien est déjà utilisé par une de vos démarche. diff --git a/app/views/admin/procedures/show.html.haml b/app/views/admin/procedures/show.html.haml index cb4492a9c..46bfef62c 100644 --- a/app/views/admin/procedures/show.html.haml +++ b/app/views/admin/procedures/show.html.haml @@ -55,6 +55,9 @@ Cette démarche est archivée et n’est donc pas accessible par le public. - elsif @procedure.publiee? = link_to procedure_lien(@procedure), sanitize_url(procedure_lien(@procedure)), target: :blank + %br + %br + Attention, diffusez toujours le lien complet affiché ci-dessus, et non pas un lien générique vers demarches-simplifiees.fr. Ne dites pas non plus aux usagers de se rendre sur le site générique demarches-simplifiees.fr, donnez-leur toujours le lien complet. - elsif @procedure.brouillon_avec_lien? - if @procedure.gestionnaires.present? && @procedure.service.present? = link_to procedure_lien(@procedure), sanitize_url(procedure_lien(@procedure)), target: :blank From bdc0ee61261486793f979c01d037be0dd8921a8e Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Tue, 2 Oct 2018 18:46:08 +0200 Subject: [PATCH 02/17] Remove unused column --- ...move_old_displayed_fields_from_procedure_presentations.rb | 5 +++++ db/schema.rb | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20181002164310_remove_old_displayed_fields_from_procedure_presentations.rb diff --git a/db/migrate/20181002164310_remove_old_displayed_fields_from_procedure_presentations.rb b/db/migrate/20181002164310_remove_old_displayed_fields_from_procedure_presentations.rb new file mode 100644 index 000000000..f77f9de26 --- /dev/null +++ b/db/migrate/20181002164310_remove_old_displayed_fields_from_procedure_presentations.rb @@ -0,0 +1,5 @@ +class RemoveOldDisplayedFieldsFromProcedurePresentations < ActiveRecord::Migration[5.2] + def change + remove_column :procedure_presentations, :old_displayed_fields + end +end diff --git a/db/schema.rb b/db/schema.rb index 38f6cfb18..b93d621b6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_10_02_162757) do +ActiveRecord::Schema.define(version: 2018_10_02_164310) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -425,7 +425,6 @@ ActiveRecord::Schema.define(version: 2018_10_02_162757) do create_table "procedure_presentations", id: :serial, force: :cascade do |t| t.integer "assign_to_id" - t.text "old_displayed_fields", default: ["{\"label\":\"Demandeur\",\"table\":\"user\",\"column\":\"email\"}"], null: false, array: true t.jsonb "sort", default: {"order"=>"desc", "table"=>"notifications", "column"=>"notifications"}, null: false t.jsonb "filters", default: {"tous"=>[], "suivis"=>[], "traites"=>[], "a-suivre"=>[], "archives"=>[]}, null: false t.datetime "created_at" From 1f4ef0074ff84c912addc171cc6655f004c77d43 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 13:53:15 +0200 Subject: [PATCH 03/17] Enable Style/ZeroLengthPredicate --- .rubocop.yml | 2 +- app/lib/carto/bano/address_retriever.rb | 2 +- app/lib/carto/bano/point_retriever.rb | 2 +- ...2017_10_30_copy_commentaire_piece_justificative_to_file.rake | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d18be6e24..1bc6c1a48 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1268,4 +1268,4 @@ Style/YodaCondition: Enabled: false Style/ZeroLengthPredicate: - Enabled: false + Enabled: true diff --git a/app/lib/carto/bano/address_retriever.rb b/app/lib/carto/bano/address_retriever.rb index 895320adc..9b29e02c2 100644 --- a/app/lib/carto/bano/address_retriever.rb +++ b/app/lib/carto/bano/address_retriever.rb @@ -20,7 +20,7 @@ module Carto def convert_driver_result_to_full_address result = JSON.parse(driver.call) - if result['features'].size == 0 + if result['features'].empty? Rails.logger.error "unable to find location for address #{@address}" return [] end diff --git a/app/lib/carto/bano/point_retriever.rb b/app/lib/carto/bano/point_retriever.rb index 56adf42f3..274e264e2 100644 --- a/app/lib/carto/bano/point_retriever.rb +++ b/app/lib/carto/bano/point_retriever.rb @@ -19,7 +19,7 @@ module Carto def convert_driver_result_to_point result = JSON.parse(driver.call) - if result['features'].size == 0 + if result['features'].empty? Rails.logger.error "unable to find location for address #{@address}" return nil end 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 6aa945773..660f24df3 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 @@ -24,7 +24,7 @@ namespace :'2017_10_30_copy_commentaire_piece_justificative_to_file' do def sanitize_name(name) # from https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/sanitized_file.rb#L323 name = name.gsub(/[^[:word:]\.\-\+]/,"_") name = "_#{name}" if name.match?(/\A\.+\z/) - name = "unnamed" if name.size == 0 + name = "unnamed" if name.empty? return name.mb_chars.to_s end From d1439f8a52a4c9de86b7c1658534c4d9dc9c4059 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 13:53:55 +0200 Subject: [PATCH 04/17] Enable Style/YodaCondition --- .rubocop.yml | 2 +- app/controllers/stats_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1bc6c1a48..e825e97b8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1265,7 +1265,7 @@ Style/WordArray: Enabled: false Style/YodaCondition: - Enabled: false + Enabled: true Style/ZeroLengthPredicate: Enabled: true diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 4d2c54ee5..54cce84a2 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -211,7 +211,7 @@ class StatsController < ApplicationController { 'Une démarche' => count_per_administrateur.select { |count| count == 1 }.count, 'Entre deux et cinq démarches' => count_per_administrateur.select { |count| count.in?(2..5) }.count, - 'Plus de cinq démarches' => count_per_administrateur.select { |count| 5 < count }.count + 'Plus de cinq démarches' => count_per_administrateur.select { |count| count > 5 }.count } end From 6eeba14885a24b8eb6b9257e02d5c14eae330db7 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 13:55:12 +0200 Subject: [PATCH 05/17] Enable Style/WordArray --- .rubocop.yml | 3 ++- Guardfile | 2 +- app/decorators/type_de_champ_decorator.rb | 2 +- app/decorators/type_de_piece_justificative_decorator.rb | 2 +- app/helpers/string_to_html_helper.rb | 2 +- app/services/dossier_field_service.rb | 2 +- app/uploaders/attestation_template_logo_uploader.rb | 2 +- app/uploaders/attestation_template_signature_uploader.rb | 2 +- app/uploaders/commentaire_file_uploader.rb | 2 +- app/uploaders/piece_justificative_uploader.rb | 2 +- app/uploaders/procedure_logo_uploader.rb | 2 +- config/application.rb | 4 ++-- config/initializers/assets.rb | 2 +- db/migrate/20161005144657_purge_draft_dossier.rb | 2 +- lib/tasks/deploy.rake | 2 +- spec/controllers/application_controller_spec.rb | 2 +- spec/models/dossier_spec.rb | 6 +++--- spec/spec_helper.rb | 2 +- spec/support/database_cleaner.rb | 2 +- 19 files changed, 23 insertions(+), 22 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e825e97b8..5e5112f4c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1262,7 +1262,8 @@ Style/WhileUntilModifier: Enabled: false Style/WordArray: - Enabled: false + Enabled: true + EnforcedStyle: brackets Style/YodaCondition: Enabled: true diff --git a/Guardfile b/Guardfile index ed798d43e..acfab00d5 100644 --- a/Guardfile +++ b/Guardfile @@ -39,7 +39,7 @@ guard 'livereload' do # less: :less, # uncomment if you want LESS stylesheets done in browser } - rails_view_exts = %w(erb haml slim) + rails_view_exts = ['erb', 'haml', 'slim'] # file types LiveReload may optimize refresh for compiled_exts = extensions.values diff --git a/app/decorators/type_de_champ_decorator.rb b/app/decorators/type_de_champ_decorator.rb index 1c2225159..8e3bc8118 100644 --- a/app/decorators/type_de_champ_decorator.rb +++ b/app/decorators/type_de_champ_decorator.rb @@ -28,7 +28,7 @@ class TypeDeChampDecorator < Draper::Decorator end def base_classes - %w(btn btn-default form-control fa) + ['btn', 'btn-default', 'form-control', 'fa'] end def display_up_button?(index, private) diff --git a/app/decorators/type_de_piece_justificative_decorator.rb b/app/decorators/type_de_piece_justificative_decorator.rb index 3f6e6b382..906e61864 100644 --- a/app/decorators/type_de_piece_justificative_decorator.rb +++ b/app/decorators/type_de_piece_justificative_decorator.rb @@ -23,7 +23,7 @@ class TypeDePieceJustificativeDecorator < Draper::Decorator end def base_classes - %w(btn btn-default form-control fa) + ['btn', 'btn-default', 'form-control', 'fa'] end def display_up_button?(index) diff --git a/app/helpers/string_to_html_helper.rb b/app/helpers/string_to_html_helper.rb index 793bc8b58..2e01ab99b 100644 --- a/app/helpers/string_to_html_helper.rb +++ b/app/helpers/string_to_html_helper.rb @@ -2,6 +2,6 @@ module StringToHtmlHelper def string_to_html(str) html_formatted = simple_format(str) with_links = html_formatted.gsub(URI.regexp, '\0') - sanitize(with_links, attributes: %w(href target)) + sanitize(with_links, attributes: ['href', 'target']) end end diff --git a/app/services/dossier_field_service.rb b/app/services/dossier_field_service.rb index 8de8d50bd..1d82db39f 100644 --- a/app/services/dossier_field_service.rb +++ b/app/services/dossier_field_service.rb @@ -174,7 +174,7 @@ class DossierFieldService end def assert_valid_order(order) - if !%w[asc desc].include?(order) + if !["asc", "desc"].include?(order) raise "Invalid order #{order}" end end diff --git a/app/uploaders/attestation_template_logo_uploader.rb b/app/uploaders/attestation_template_logo_uploader.rb index 64eba474f..53bc01a56 100644 --- a/app/uploaders/attestation_template_logo_uploader.rb +++ b/app/uploaders/attestation_template_logo_uploader.rb @@ -21,7 +21,7 @@ class AttestationTemplateLogoUploader < BaseUploader # Add a white list of extensions which are allowed to be uploaded. # For images you might use something like this: def extension_white_list - %w(jpg jpeg png) + ['jpg', 'jpeg', 'png'] end def filename diff --git a/app/uploaders/attestation_template_signature_uploader.rb b/app/uploaders/attestation_template_signature_uploader.rb index f5e50903c..e42f81996 100644 --- a/app/uploaders/attestation_template_signature_uploader.rb +++ b/app/uploaders/attestation_template_signature_uploader.rb @@ -21,7 +21,7 @@ class AttestationTemplateSignatureUploader < BaseUploader # Add a white list of extensions which are allowed to be uploaded. # For images you might use something like this: def extension_white_list - %w(jpg jpeg png) + ['jpg', 'jpeg', 'png'] end def filename diff --git a/app/uploaders/commentaire_file_uploader.rb b/app/uploaders/commentaire_file_uploader.rb index 18ef15c21..eaa738b14 100644 --- a/app/uploaders/commentaire_file_uploader.rb +++ b/app/uploaders/commentaire_file_uploader.rb @@ -14,7 +14,7 @@ class CommentaireFileUploader < BaseUploader end def extension_white_list - %w(pdf doc docx xls xlsx ppt pptx odt ods odp jpg jpeg png zip txt) + ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'odt', 'ods', 'odp', 'jpg', 'jpeg', 'png', 'zip', 'txt'] end def accept_extension_list diff --git a/app/uploaders/piece_justificative_uploader.rb b/app/uploaders/piece_justificative_uploader.rb index c9bf93278..83d277c8f 100644 --- a/app/uploaders/piece_justificative_uploader.rb +++ b/app/uploaders/piece_justificative_uploader.rb @@ -19,7 +19,7 @@ class PieceJustificativeUploader < BaseUploader # Add a white list of extensions which are allowed to be uploaded. # For images you might use something like this: def extension_white_list - %w(pdf doc docx xls xlsx ppt pptx odt ods odp jpg jpeg png) + ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'odt', 'ods', 'odp', 'jpg', 'jpeg', 'png'] end def filename diff --git a/app/uploaders/procedure_logo_uploader.rb b/app/uploaders/procedure_logo_uploader.rb index 598f619a1..29e499c9d 100644 --- a/app/uploaders/procedure_logo_uploader.rb +++ b/app/uploaders/procedure_logo_uploader.rb @@ -21,7 +21,7 @@ class ProcedureLogoUploader < BaseUploader # Add a white list of extensions which are allowed to be uploaded. # For images you might use something like this: def extension_white_list - %w(jpg jpeg png) + ['jpg', 'jpeg', 'png'] end def filename diff --git a/config/application.rb b/config/application.rb index 8100c4c97..bbb513db5 100644 --- a/config/application.rb +++ b/config/application.rb @@ -24,10 +24,10 @@ module TPS config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] config.i18n.available_locales = [:fr] - config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/validators #{config.root}/app/facades) + config.autoload_paths += ["#{config.root}/lib", "#{config.root}/app/validators", "#{config.root}/app/facades"] config.assets.paths << Rails.root.join('app', 'assets', 'javascript') config.assets.paths << Rails.root.join('app', 'assets', 'fonts') - config.assets.precompile += %w(.woff) + config.assets.precompile += ['.woff'] URL = ENV['APP_HOST'] || "http://localhost:3000/" diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 38de183f3..87cf30a15 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -8,4 +8,4 @@ Rails.application.config.assets.version = '1.0' # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -Rails.application.config.assets.precompile += %w(print.css new_design/new_application.css new_design/print.css new_design/application.js new_design/manager.css) +Rails.application.config.assets.precompile += ['print.css', 'new_design/new_application.css', 'new_design/print.css', 'new_design/application.js', 'new_design/manager.css'] diff --git a/db/migrate/20161005144657_purge_draft_dossier.rb b/db/migrate/20161005144657_purge_draft_dossier.rb index 87d604803..2457d210f 100644 --- a/db/migrate/20161005144657_purge_draft_dossier.rb +++ b/db/migrate/20161005144657_purge_draft_dossier.rb @@ -1,6 +1,6 @@ class PurgeDraftDossier < ActiveRecord::Migration class Dossier < ApplicationRecord - BROUILLON = %w(draft) + BROUILLON = ['draft'] def brouillon? BROUILLON.include?(state) diff --git a/lib/tasks/deploy.rake b/lib/tasks/deploy.rake index e111efa73..d117fe39f 100644 --- a/lib/tasks/deploy.rake +++ b/lib/tasks/deploy.rake @@ -1,5 +1,5 @@ task :deploy do - domains = %w(149.202.72.152 149.202.198.6) + domains = ['149.202.72.152', '149.202.198.6'] domains.each do |domain| sh "mina deploy domain=#{domain}" end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index e2d1db65e..0fc0ec700 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -113,7 +113,7 @@ describe ApplicationController, type: :controller do it { expect(@controller).to have_received(:redirect_to).with(root_path) } context 'when the path is safe' do - %w(/ /manager /administrations).each do |path| + ['/', '/manager', '/administrations'].each do |path| let(:path_info) { path } it { expect(@controller).not_to have_received(:sign_out) } diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 901599bfb..3b7dbfc10 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -23,7 +23,7 @@ describe Dossier do end it do - expect(Dossier.with_champs.find(dossier.id).champs.map(&:libelle)).to match(%w(l1 l2 l3)) + expect(Dossier.with_champs.find(dossier.id).champs.map(&:libelle)).to match(['l1', 'l2', 'l3']) end end @@ -379,7 +379,7 @@ describe Dossier do create(:type_de_champ, libelle: 'l2', order_place: 2, procedure: procedure) end - it { expect(dossier.champs.pluck(:libelle)).to match(%w(l1 l2 l3)) } + it { expect(dossier.champs.pluck(:libelle)).to match(['l1', 'l2', 'l3']) } end describe '#champs_private' do @@ -392,7 +392,7 @@ describe Dossier do create :type_de_champ, :private, libelle: 'l2', order_place: 2, procedure: procedure end - it { expect(dossier.champs_private.pluck(:libelle)).to match(%w(l1 l2 l3)) } + it { expect(dossier.champs_private.pluck(:libelle)).to match(['l1', 'l2', 'l3']) } end describe '#total_follow' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0bb43cb55..ba3da562a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -39,7 +39,7 @@ end Capybara.register_driver :headless_chrome do |app| capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( - chromeOptions: { args: %w(headless disable-gpu disable-dev-shm-usage disable-software-rasterizer mute-audio window-size=1440,900) } + chromeOptions: { args: ['headless', 'disable-gpu', 'disable-dev-shm-usage', 'disable-software-rasterizer', 'mute-audio', 'window-size=1440,900'] } ) Capybara::Selenium::Driver.new app, diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index fba37f056..ef931aa87 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -1,5 +1,5 @@ RSpec.configure do |config| - expect_list = %w() + expect_list = [] config.before(:suite) do DatabaseCleaner.clean_with(:truncation, except: expect_list) From c380abeb247b90272c291010915dba91b6e1cde2 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 13:58:36 +0200 Subject: [PATCH 06/17] Explain why Style/WhileUntilModifier is disabled --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index 5e5112f4c..25d9b1f0d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1258,6 +1258,7 @@ Style/WhenThen: Style/WhileUntilDo: Enabled: false +# Disabled because we don't want to use modifiers Style/WhileUntilModifier: Enabled: false From 106d03d9827ddb98eb0fefbfe44b4179ea039bea Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 13:58:39 +0200 Subject: [PATCH 07/17] Enable Style/WhileUntilDo --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 25d9b1f0d..ac55d46c6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1256,7 +1256,7 @@ Style/WhenThen: Enabled: false Style/WhileUntilDo: - Enabled: false + Enabled: true # Disabled because we don't want to use modifiers Style/WhileUntilModifier: From 9cdad6ce7e335b856cb37f9cc3e53574157eae8f Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 14:00:48 +0200 Subject: [PATCH 08/17] Enable Style/VariableInterpolation --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index ac55d46c6..4b6c7ea9d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1250,7 +1250,7 @@ Style/UnneededPercentQ: Enabled: false Style/VariableInterpolation: - Enabled: false + Enabled: true Style/WhenThen: Enabled: false From 82f0df089d2017fbbb34c45806005ce34ac2ba39 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 14:01:31 +0200 Subject: [PATCH 09/17] Enable Style/UnneededPercentQ --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 4b6c7ea9d..767e82755 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1247,7 +1247,7 @@ Style/UnneededInterpolation: Enabled: false Style/UnneededPercentQ: - Enabled: false + Enabled: true Style/VariableInterpolation: Enabled: true From ed240cb4d33563b403b45121cc6e9c2d956a38e9 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 14:03:05 +0200 Subject: [PATCH 10/17] Enable Style/UnneededInterpolation --- .rubocop.yml | 2 +- app/services/types_de_champ_service.rb | 2 +- .../20160622081322_add_procedure_path_mapping_table.rb | 2 +- spec/controllers/champs/dossier_link_controller_spec.rb | 2 +- spec/controllers/champs/siret_controller_spec.rb | 2 +- spec/controllers/stats_controller_spec.rb | 8 ++++---- spec/controllers/support_controller_spec.rb | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 767e82755..60dc3a9f3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1244,7 +1244,7 @@ Style/UnneededCapitalW: Enabled: false Style/UnneededInterpolation: - Enabled: false + Enabled: true Style/UnneededPercentQ: Enabled: true diff --git a/app/services/types_de_champ_service.rb b/app/services/types_de_champ_service.rb index ccd1ab898..a1d0ba188 100644 --- a/app/services/types_de_champ_service.rb +++ b/app/services/types_de_champ_service.rb @@ -6,7 +6,7 @@ class TypesDeChampService parameters = params_with_ordered_champs .require(:procedure) - .permit("#{attributes}" => [ + .permit(attributes.to_s => [ :libelle, :description, :order_place, diff --git a/db/migrate/20160622081322_add_procedure_path_mapping_table.rb b/db/migrate/20160622081322_add_procedure_path_mapping_table.rb index ebe600f8f..f29b5cdef 100644 --- a/db/migrate/20160622081322_add_procedure_path_mapping_table.rb +++ b/db/migrate/20160622081322_add_procedure_path_mapping_table.rb @@ -12,7 +12,7 @@ class AddProcedurePathMappingTable < ActiveRecord::Migration add_foreign_key :procedure_paths, :administrateurs Procedure.all.each do |procedure| - ProcedurePath.create(path: "#{procedure.id}", procedure_id: procedure.id, administrateur_id: procedure.administrateur.id) + ProcedurePath.create(path: (procedure.id).to_s, procedure_id: procedure.id, administrateur_id: procedure.administrateur.id) end end end diff --git a/spec/controllers/champs/dossier_link_controller_spec.rb b/spec/controllers/champs/dossier_link_controller_spec.rb index b01b91c41..f2f5be448 100644 --- a/spec/controllers/champs/dossier_link_controller_spec.rb +++ b/spec/controllers/champs/dossier_link_controller_spec.rb @@ -15,7 +15,7 @@ describe Champs::DossierLinkController, type: :controller do { dossier: { champs_attributes: { - '1' => { value: "#{dossier_id}" } + '1' => { value: dossier_id.to_s } } }, position: '1' diff --git a/spec/controllers/champs/siret_controller_spec.rb b/spec/controllers/champs/siret_controller_spec.rb index 6d848a117..e4e62311d 100644 --- a/spec/controllers/champs/siret_controller_spec.rb +++ b/spec/controllers/champs/siret_controller_spec.rb @@ -10,7 +10,7 @@ describe Champs::SiretController, type: :controller do { dossier: { champs_attributes: { - '1' => { value: "#{siret}" } + '1' => { value: siret.to_s } } }, position: '1' diff --git a/spec/controllers/stats_controller_spec.rb b/spec/controllers/stats_controller_spec.rb index 4b459b278..0b9bcb71f 100644 --- a/spec/controllers/stats_controller_spec.rb +++ b/spec/controllers/stats_controller_spec.rb @@ -165,8 +165,8 @@ describe StatsController, type: :controller do Dossier.update_all(state: Dossier.states.fetch(:accepte)) @expected_hash = { - "#{2.months.ago.beginning_of_month}" => 3.0, - "#{1.month.ago.beginning_of_month}" => 5.0 + (2.months.ago.beginning_of_month).to_s => 3.0, + (1.month.ago.beginning_of_month).to_s => 5.0 } end @@ -217,8 +217,8 @@ describe StatsController, type: :controller do Dossier.update_all(state: Dossier.states.fetch(:accepte)) @expected_hash = { - "#{2.months.ago.beginning_of_month}" => 30.0, - "#{1.month.ago.beginning_of_month}" => 50.0 + (2.months.ago.beginning_of_month).to_s => 30.0, + (1.month.ago.beginning_of_month).to_s => 50.0 } end diff --git a/spec/controllers/support_controller_spec.rb b/spec/controllers/support_controller_spec.rb index a075e1b19..438abdb9d 100644 --- a/spec/controllers/support_controller_spec.rb +++ b/spec/controllers/support_controller_spec.rb @@ -24,7 +24,7 @@ describe SupportController, type: :controller do get :index, params: { dossier_id: dossier.id } expect(response.status).to eq(200) - expect(response.body).to include("#{dossier.id}") + expect(response.body).to include((dossier.id).to_s) end end From 2ede598f7711de96ab90b904df6f69fe05dd6ebd Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 14:03:44 +0200 Subject: [PATCH 11/17] Enable Style/UnneededCapitalW --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 60dc3a9f3..9d050e9f4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1241,7 +1241,7 @@ Style/UnlessElse: Enabled: true Style/UnneededCapitalW: - Enabled: false + Enabled: true Style/UnneededInterpolation: Enabled: true From a171186dd8c78734617d6e313698757bef0dcdeb Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 14:06:08 +0200 Subject: [PATCH 12/17] Enable Style/TrailingCommaInHashLiteral --- .rubocop.yml | 2 +- app/controllers/admin/mail_templates_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- app/controllers/manager/administrateurs_controller.rb | 2 +- app/dashboards/dossier_dashboard.rb | 2 +- app/dashboards/procedure_dashboard.rb | 2 +- app/dashboards/service_dashboard.rb | 2 +- app/dashboards/user_dashboard.rb | 2 +- app/lib/pipedrive/deal_adapter.rb | 2 +- app/models/gestionnaire.rb | 2 +- app/models/virus_scan.rb | 2 +- config/initializers/active_job_log_subscriber.rb | 2 +- config/initializers/carrierwave.rb | 2 +- .../20160802113112_build_default_preference_list_dossier.rb | 2 +- .../20161007095443_reset_all_preference_list_dossier.rb | 2 +- spec/controllers/users/passwords_controller_spec.rb | 4 ++-- spec/lib/active_storage/service/cellar_service_spec.rb | 2 +- 17 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9d050e9f4..21bdf98b8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1226,7 +1226,7 @@ Style/TrailingCommaInArrayLiteral: Enabled: false Style/TrailingCommaInHashLiteral: - Enabled: false + Enabled: true Style/TrailingMethodEndStatement: Enabled: true diff --git a/app/controllers/admin/mail_templates_controller.rb b/app/controllers/admin/mail_templates_controller.rb index 3ef952fae..bc7c948ff 100644 --- a/app/controllers/admin/mail_templates_controller.rb +++ b/app/controllers/admin/mail_templates_controller.rb @@ -35,7 +35,7 @@ class Admin::MailTemplatesController < AdminController { procedure_id: params[:procedure_id], subject: params[:mail_template][:subject], - body: params[:mail_template][:body], + body: params[:mail_template][:body] } end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ed758ddbf..2573a9a38 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -123,7 +123,7 @@ class ApplicationController < ActionController::Base payload.merge!({ browser: browser.name, browser_version: browser.version.to_s, - platform: browser.platform.name, + platform: browser.platform.name }) end diff --git a/app/controllers/manager/administrateurs_controller.rb b/app/controllers/manager/administrateurs_controller.rb index 3f0a63438..91866045c 100644 --- a/app/controllers/manager/administrateurs_controller.rb +++ b/app/controllers/manager/administrateurs_controller.rb @@ -8,7 +8,7 @@ module Manager redirect_to manager_administrateurs_path else render :new, locals: { - page: Administrate::Page::Form.new(dashboard, administrateur), + page: Administrate::Page::Form.new(dashboard, administrateur) } end end diff --git a/app/dashboards/dossier_dashboard.rb b/app/dashboards/dossier_dashboard.rb index 79040b995..b329da0cd 100644 --- a/app/dashboards/dossier_dashboard.rb +++ b/app/dashboards/dossier_dashboard.rb @@ -15,7 +15,7 @@ class DossierDashboard < Administrate::BaseDashboard created_at: Field::DateTime, updated_at: Field::DateTime, hidden_at: Field::DateTime, - types_de_champ: TypesDeChampCollectionField, + types_de_champ: TypesDeChampCollectionField }.freeze # COLLECTION_ATTRIBUTES diff --git a/app/dashboards/procedure_dashboard.rb b/app/dashboards/procedure_dashboard.rb index 8191cb6e2..de0520588 100644 --- a/app/dashboards/procedure_dashboard.rb +++ b/app/dashboards/procedure_dashboard.rb @@ -33,7 +33,7 @@ class ProcedureDashboard < Administrate::BaseDashboard received_mail_template: MailTemplateField, closed_mail_template: MailTemplateField, refused_mail_template: MailTemplateField, - without_continuation_mail_template: MailTemplateField, + without_continuation_mail_template: MailTemplateField }.freeze # COLLECTION_ATTRIBUTES diff --git a/app/dashboards/service_dashboard.rb b/app/dashboards/service_dashboard.rb index 4066b9e49..41521e3b9 100644 --- a/app/dashboards/service_dashboard.rb +++ b/app/dashboards/service_dashboard.rb @@ -19,7 +19,7 @@ class ServiceDashboard < Administrate::BaseDashboard telephone: Field::String, horaires: Field::String, adresse: Field::String, - siret: Field::String, + siret: Field::String }.freeze # COLLECTION_ATTRIBUTES diff --git a/app/dashboards/user_dashboard.rb b/app/dashboards/user_dashboard.rb index c61cc424b..c95e30bd0 100644 --- a/app/dashboards/user_dashboard.rb +++ b/app/dashboards/user_dashboard.rb @@ -14,7 +14,7 @@ class UserDashboard < Administrate::BaseDashboard created_at: Field::DateTime, updated_at: Field::DateTime, current_sign_in_at: Field::DateTime, - dossiers: Field::HasMany, + dossiers: Field::HasMany }.freeze # COLLECTION_ATTRIBUTES diff --git a/app/lib/pipedrive/deal_adapter.rb b/app/lib/pipedrive/deal_adapter.rb index 725a62936..5e8cd77ef 100644 --- a/app/lib/pipedrive/deal_adapter.rb +++ b/app/lib/pipedrive/deal_adapter.rb @@ -55,7 +55,7 @@ class Pipedrive::DealAdapter user_id: Pipedrive::PersonAdapter::PIPEDRIVE_ROBOT_ID, "#{PIPEDRIVE_NB_OF_PROCEDURES_ATTRIBUTE_ID}": nb_of_procedures, value: nb_of_dossiers, - "#{PIPEDRIVE_DEADLINE_ATTRIBUTE_ID}": deadline, + "#{PIPEDRIVE_DEADLINE_ATTRIBUTE_ID}": deadline } Pipedrive::API.post_deal(params) diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index b06068620..675cafebb 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -76,7 +76,7 @@ class Gestionnaire < ApplicationRecord else { start_date: start_date, - procedure_overviews: active_procedure_overviews, + procedure_overviews: active_procedure_overviews } end end diff --git a/app/models/virus_scan.rb b/app/models/virus_scan.rb index f0a45ca31..e6e0db4c9 100644 --- a/app/models/virus_scan.rb +++ b/app/models/virus_scan.rb @@ -4,7 +4,7 @@ class VirusScan < ApplicationRecord enum status: { pending: 'pending', safe: 'safe', - infected: 'infected', + infected: 'infected' } validates :champ_id, uniqueness: { scope: :blob_key } diff --git a/config/initializers/active_job_log_subscriber.rb b/config/initializers/active_job_log_subscriber.rb index cfcddc188..202820450 100644 --- a/config/initializers/active_job_log_subscriber.rb +++ b/config/initializers/active_job_log_subscriber.rb @@ -50,7 +50,7 @@ class ActiveJobLogSubscriber < ::ActiveJob::Logging::LogSubscriber job_id: event.payload[:job].job_id, queue_name: queue_name(event), job_class: event.payload[:job].class.to_s, - job_args: args_info(event.payload[:job]), + job_args: args_info(event.payload[:job]) } end diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index 299105185..a3dd7d654 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -11,7 +11,7 @@ CarrierWave.configure do |config| openstack_api_key: Rails.application.secrets.fog[:openstack_api_key], openstack_username: Rails.application.secrets.fog[:openstack_username], openstack_auth_url: Rails.application.secrets.fog[:openstack_auth_url], - openstack_region: Rails.application.secrets.fog[:openstack_region], + openstack_region: Rails.application.secrets.fog[:openstack_region] } end diff --git a/db/migrate/20160802113112_build_default_preference_list_dossier.rb b/db/migrate/20160802113112_build_default_preference_list_dossier.rb index 0c7f442d8..7cbfe5868 100644 --- a/db/migrate/20160802113112_build_default_preference_list_dossier.rb +++ b/db/migrate/20160802113112_build_default_preference_list_dossier.rb @@ -88,7 +88,7 @@ class BuildDefaultPreferenceListDossier < ActiveRecord::Migration nom_commercial: create_column('Nom commercial', table, 'nom_commercial', 'nom_commercial', 3), raison_sociale: create_column('Raison sociale', table, 'raison_sociale', 'raison_sociale', 3), siret_siege_social: create_column('SIRET siège social', table, 'siret_siege_social', 'siret_siege_social', 2), - date_creation: create_column('Date de création', table, 'date_creation', 'date_creation', 2), + date_creation: create_column('Date de création', table, 'date_creation', 'date_creation', 2) } end diff --git a/db/migrate/20161007095443_reset_all_preference_list_dossier.rb b/db/migrate/20161007095443_reset_all_preference_list_dossier.rb index 6a14ddc6b..c886bdf70 100644 --- a/db/migrate/20161007095443_reset_all_preference_list_dossier.rb +++ b/db/migrate/20161007095443_reset_all_preference_list_dossier.rb @@ -47,7 +47,7 @@ class ResetAllPreferenceListDossier < ActiveRecord::Migration nom_commercial: create_column('Nom commercial', table, 'nom_commercial', 'nom_commercial', 3), raison_sociale: create_column('Raison sociale', table, 'raison_sociale', 'raison_sociale', 3), siret_siege_social: create_column('SIRET siège social', table, 'siret_siege_social', 'siret_siege_social', 2), - date_creation: create_column('Date de création', table, 'date_creation', 'date_creation', 2), + date_creation: create_column('Date de création', table, 'date_creation', 'date_creation', 2) } end diff --git a/spec/controllers/users/passwords_controller_spec.rb b/spec/controllers/users/passwords_controller_spec.rb index 8ee43dc24..5ee6c2020 100644 --- a/spec/controllers/users/passwords_controller_spec.rb +++ b/spec/controllers/users/passwords_controller_spec.rb @@ -22,7 +22,7 @@ describe Users::PasswordsController, type: :controller do user: { reset_password_token: @token, password: "mot de passe super secret", - password_confirmation: "mot de passe super secret", + password_confirmation: "mot de passe super secret" } } expect(subject.current_user).to eq(user) @@ -34,7 +34,7 @@ describe Users::PasswordsController, type: :controller do user: { reset_password_token: @token, password: "mot de passe super secret", - password_confirmation: "mot de passe super secret", + password_confirmation: "mot de passe super secret" } } expect(subject.current_user).to eq(user) diff --git a/spec/lib/active_storage/service/cellar_service_spec.rb b/spec/lib/active_storage/service/cellar_service_spec.rb index 5bbe76d87..c9bcacda0 100644 --- a/spec/lib/active_storage/service/cellar_service_spec.rb +++ b/spec/lib/active_storage/service/cellar_service_spec.rb @@ -47,7 +47,7 @@ describe 'CellarService' do 'Expires' => ['1475366700'], 'Signature' => ['nzCsB6cip8oofkuOdvvJs6FafkA='], 'response-content-disposition' => ["attachment; filename=\"toto.png\"; filename*=UTF-8''toto.png"], - 'response-content-type' => ['image/png'], + 'response-content-type' => ['image/png'] } ) end From 275bb64c1f38ee91b4e7a32d279d9b9d1dadd97c Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 14:06:57 +0200 Subject: [PATCH 13/17] Enable Style/TrailingCommaInArrayLiteral --- .rubocop.yml | 2 +- app/dashboards/administrateur_dashboard.rb | 4 ++-- app/dashboards/gestionnaire_dashboard.rb | 4 ++-- app/dashboards/procedure_dashboard.rb | 4 ++-- app/dashboards/service_dashboard.rb | 4 ++-- app/dashboards/user_dashboard.rb | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 21bdf98b8..55079ab2a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1223,7 +1223,7 @@ Style/TrailingCommaInArguments: Enabled: false Style/TrailingCommaInArrayLiteral: - Enabled: false + Enabled: true Style/TrailingCommaInHashLiteral: Enabled: true diff --git a/app/dashboards/administrateur_dashboard.rb b/app/dashboards/administrateur_dashboard.rb index 7f581595d..18aa6fd2e 100644 --- a/app/dashboards/administrateur_dashboard.rb +++ b/app/dashboards/administrateur_dashboard.rb @@ -27,7 +27,7 @@ class AdministrateurDashboard < Administrate::BaseDashboard :email, :created_at, :procedures, - :registration_state, + :registration_state ].freeze # SHOW_PAGE_ATTRIBUTES @@ -40,7 +40,7 @@ class AdministrateurDashboard < Administrate::BaseDashboard :registration_state, :current_sign_in_at, :features, - :procedures, + :procedures ].freeze # FORM_ATTRIBUTES diff --git a/app/dashboards/gestionnaire_dashboard.rb b/app/dashboards/gestionnaire_dashboard.rb index 02b8ad37e..a1666edf7 100644 --- a/app/dashboards/gestionnaire_dashboard.rb +++ b/app/dashboards/gestionnaire_dashboard.rb @@ -24,7 +24,7 @@ class GestionnaireDashboard < Administrate::BaseDashboard # Feel free to add, remove, or rearrange items. COLLECTION_ATTRIBUTES = [ :email, - :created_at, + :created_at ].freeze # SHOW_PAGE_ATTRIBUTES @@ -35,7 +35,7 @@ class GestionnaireDashboard < Administrate::BaseDashboard :id, :email, :current_sign_in_at, - :created_at, + :created_at ].freeze # FORM_ATTRIBUTES diff --git a/app/dashboards/procedure_dashboard.rb b/app/dashboards/procedure_dashboard.rb index de0520588..b04ad40d0 100644 --- a/app/dashboards/procedure_dashboard.rb +++ b/app/dashboards/procedure_dashboard.rb @@ -47,7 +47,7 @@ class ProcedureDashboard < Administrate::BaseDashboard :libelle, :organisation, :dossiers, - :published_at, + :published_at ].freeze # SHOW_PAGE_ATTRIBUTES @@ -77,7 +77,7 @@ class ProcedureDashboard < Administrate::BaseDashboard :received_mail_template, :closed_mail_template, :refused_mail_template, - :without_continuation_mail_template, + :without_continuation_mail_template ].freeze # FORM_ATTRIBUTES diff --git a/app/dashboards/service_dashboard.rb b/app/dashboards/service_dashboard.rb index 41521e3b9..5e3ea65fe 100644 --- a/app/dashboards/service_dashboard.rb +++ b/app/dashboards/service_dashboard.rb @@ -29,7 +29,7 @@ class ServiceDashboard < Administrate::BaseDashboard # Feel free to add, remove, or rearrange items. COLLECTION_ATTRIBUTES = [ :nom, - :type_organisme, + :type_organisme ].freeze # SHOW_PAGE_ATTRIBUTES @@ -46,7 +46,7 @@ class ServiceDashboard < Administrate::BaseDashboard :telephone, :horaires, :adresse, - :siret, + :siret ].freeze # FORM_ATTRIBUTES diff --git a/app/dashboards/user_dashboard.rb b/app/dashboards/user_dashboard.rb index c95e30bd0..2ad8886c8 100644 --- a/app/dashboards/user_dashboard.rb +++ b/app/dashboards/user_dashboard.rb @@ -24,7 +24,7 @@ class UserDashboard < Administrate::BaseDashboard # Feel free to add, remove, or rearrange items. COLLECTION_ATTRIBUTES = [ :email, - :created_at, + :created_at ].freeze # SHOW_PAGE_ATTRIBUTES @@ -35,7 +35,7 @@ class UserDashboard < Administrate::BaseDashboard :email, :confirmed?, :current_sign_in_at, - :created_at, + :created_at ].freeze # FORM_ATTRIBUTES From 7e4268db678b5550e820967ffebb5f571dd0377f Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 14:08:12 +0200 Subject: [PATCH 14/17] Enable Style/TrailingCommaInArguments --- .rubocop.yml | 2 +- app/lib/carto/sgmap/api.rb | 2 +- spec/models/procedure_spec.rb | 2 +- .../dossiers/_envoyer_dossier_block.html.haml_spec.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 55079ab2a..09c61cf36 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1220,7 +1220,7 @@ Style/TrailingBodyOnModule: Enabled: true Style/TrailingCommaInArguments: - Enabled: false + Enabled: true Style/TrailingCommaInArrayLiteral: Enabled: true diff --git a/app/lib/carto/sgmap/api.rb b/app/lib/carto/sgmap/api.rb index e084caebd..4dce78f16 100644 --- a/app/lib/carto/sgmap/api.rb +++ b/app/lib/carto/sgmap/api.rb @@ -19,7 +19,7 @@ class CARTO::SGMAP::API RestClient::Resource.new( url, - verify_ssl: verify_ssl_mode, + verify_ssl: verify_ssl_mode ).post params[:geojson], content_type: 'application/json' rescue RestClient::InternalServerError diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 9642789c0..f2c2d9082 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -753,7 +753,7 @@ describe Procedure do p = create( :procedure, juridique_required: false, - cadre_juridique: nil, + cadre_juridique: nil ) expect(p.juridique_required).to be_falsey diff --git a/spec/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml_spec.rb b/spec/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml_spec.rb index f64785c14..464a42089 100644 --- a/spec/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml_spec.rb +++ b/spec/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml_spec.rb @@ -5,7 +5,7 @@ describe 'new_gestionnaire/dossiers/envoyer_dossier_block.html.haml', type: :vie render( 'new_gestionnaire/dossiers/envoyer_dossier_block.html.haml', dossier: dossier, - potential_recipients: potential_recipients, + potential_recipients: potential_recipients ) end From d9d4f6fe205fd5621071233147031b59fed0ef9d Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 14:20:14 +0200 Subject: [PATCH 15/17] Enable Style/SymbolProc --- .rubocop.yml | 3 ++- app/controllers/france_connect/particulier_controller.rb | 2 +- app/controllers/new_user/demarches_controller.rb | 2 +- app/jobs/administrateurs/activate_before_expiration_job.rb | 4 +--- app/jobs/auto_archive_procedure_job.rb | 4 +--- app/services/champs_service.rb | 2 +- app/services/types_de_champ_service.rb | 2 +- .../20160802113112_build_default_preference_list_dossier.rb | 4 +--- .../20161007095443_reset_all_preference_list_dossier.rb | 4 +--- db/migrate/20170215102943_remove_duplicate_email_received.rb | 2 +- lib/cellar/cellar_adapter.rb | 2 +- lib/mailers/attestation_closed_mail_discrepancy_mailer.rb | 2 +- lib/tasks/2018_01_18_clean_datetime_in_champs.rake | 2 +- lib/tasks/2018_06_04_scan_pjs.rake | 4 +--- lib/tasks/2018_06_06_users_for_admins_and_gestionnaires.rake | 2 +- lib/tasks/support.rake | 2 +- 16 files changed, 17 insertions(+), 26 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 09c61cf36..286ec3383 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1205,7 +1205,8 @@ Style/SymbolLiteral: Enabled: false Style/SymbolProc: - Enabled: false + Enabled: true + IgnoredMethods: [after] Style/TernaryParentheses: Enabled: false diff --git a/app/controllers/france_connect/particulier_controller.rb b/app/controllers/france_connect/particulier_controller.rb index 8535493d6..ce042a8a2 100644 --- a/app/controllers/france_connect/particulier_controller.rb +++ b/app/controllers/france_connect/particulier_controller.rb @@ -10,7 +10,7 @@ class FranceConnect::ParticulierController < ApplicationController fci = FranceConnectInformation .find_by(france_connect_particulier_id: fetched_fci[:france_connect_particulier_id]) || - fetched_fci.tap { |object| object.save } + fetched_fci.tap(&:save) if fci.user.nil? user = User.find_or_create_by(email: fci.email_france_connect) do |new_user| diff --git a/app/controllers/new_user/demarches_controller.rb b/app/controllers/new_user/demarches_controller.rb index 9d788ad39..7423002a2 100644 --- a/app/controllers/new_user/demarches_controller.rb +++ b/app/controllers/new_user/demarches_controller.rb @@ -6,7 +6,7 @@ module NewUser .includes(:procedure) .map(&:procedure) .uniq - .select { |p| p.publiee? } + .select(&:publiee?) @popular_demarches = Procedure .includes(:service) diff --git a/app/jobs/administrateurs/activate_before_expiration_job.rb b/app/jobs/administrateurs/activate_before_expiration_job.rb index fbf609828..889875d78 100644 --- a/app/jobs/administrateurs/activate_before_expiration_job.rb +++ b/app/jobs/administrateurs/activate_before_expiration_job.rb @@ -2,8 +2,6 @@ class Administrateurs::ActivateBeforeExpirationJob < ApplicationJob queue_as :cron def perform(*args) - Administrateur.inactive.where(created_at: 3.days.ago.all_day).each do |a| - a.remind_invitation! - end + Administrateur.inactive.where(created_at: 3.days.ago.all_day).each(&:remind_invitation!) end end diff --git a/app/jobs/auto_archive_procedure_job.rb b/app/jobs/auto_archive_procedure_job.rb index 0d5665bee..0821ba5ed 100644 --- a/app/jobs/auto_archive_procedure_job.rb +++ b/app/jobs/auto_archive_procedure_job.rb @@ -3,9 +3,7 @@ class AutoArchiveProcedureJob < ApplicationJob def perform(*args) Procedure.publiees.where("auto_archive_on <= ?", Date.today).each do |procedure| - procedure.dossiers.state_en_construction.each do |dossier| - dossier.en_instruction! - end + procedure.dossiers.state_en_construction.each(&:en_instruction!) procedure.archive! end diff --git a/app/services/champs_service.rb b/app/services/champs_service.rb index 52eac78ed..888465efe 100644 --- a/app/services/champs_service.rb +++ b/app/services/champs_service.rb @@ -14,7 +14,7 @@ class ChampsService def check_piece_justificative_files(champs) champs.select do |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) - end.map { |c| c.piece_justificative_file_errors }.flatten + end.map(&:piece_justificative_file_errors).flatten end private diff --git a/app/services/types_de_champ_service.rb b/app/services/types_de_champ_service.rb index a1d0ba188..fa4b3b126 100644 --- a/app/services/types_de_champ_service.rb +++ b/app/services/types_de_champ_service.rb @@ -70,6 +70,6 @@ class TypesDeChampService end def self.clean_value(value) - value.split("\r\n").map{ |v| v.strip }.join("\r\n") + value.split("\r\n").map(&:strip).join("\r\n") end end diff --git a/db/migrate/20160802113112_build_default_preference_list_dossier.rb b/db/migrate/20160802113112_build_default_preference_list_dossier.rb index 7cbfe5868..67e4687f3 100644 --- a/db/migrate/20160802113112_build_default_preference_list_dossier.rb +++ b/db/migrate/20160802113112_build_default_preference_list_dossier.rb @@ -124,9 +124,7 @@ class BuildDefaultPreferenceListDossier < ActiveRecord::Migration end def up - Gestionnaire.all.each do |gestionnaire| - gestionnaire.build_default_preferences_list_dossier - end + Gestionnaire.all.each(&:build_default_preferences_list_dossier) end def down diff --git a/db/migrate/20161007095443_reset_all_preference_list_dossier.rb b/db/migrate/20161007095443_reset_all_preference_list_dossier.rb index c886bdf70..f66180bfa 100644 --- a/db/migrate/20161007095443_reset_all_preference_list_dossier.rb +++ b/db/migrate/20161007095443_reset_all_preference_list_dossier.rb @@ -159,8 +159,6 @@ class ResetAllPreferenceListDossier < ActiveRecord::Migration end end - Gestionnaire.all.each do |gestionnaire| - gestionnaire.build_default_preferences_list_dossier - end + Gestionnaire.all.each(&:build_default_preferences_list_dossier) end end diff --git a/db/migrate/20170215102943_remove_duplicate_email_received.rb b/db/migrate/20170215102943_remove_duplicate_email_received.rb index 4464e7ffd..93f052b10 100644 --- a/db/migrate/20170215102943_remove_duplicate_email_received.rb +++ b/db/migrate/20170215102943_remove_duplicate_email_received.rb @@ -1,7 +1,7 @@ class RemoveDuplicateEmailReceived < ActiveRecord::Migration[5.0] def change all_mails = MailReceived.all - groupped = all_mails.group_by { |m| m.procedure_id } + groupped = all_mails.group_by(&:procedure_id) filtered = groupped.reject { |k, v| v.length < 2 } filtered.each_value do |duplicate_mails| duplicate_mails.pop diff --git a/lib/cellar/cellar_adapter.rb b/lib/cellar/cellar_adapter.rb index 9daf79572..999ecbc9b 100644 --- a/lib/cellar/cellar_adapter.rb +++ b/lib/cellar/cellar_adapter.rb @@ -119,7 +119,7 @@ module Cellar doc = Nokogiri::XML(bucket_listing_xml) doc .xpath('//xmlns:Contents/xmlns:Key') - .map{ |k| k.text } + .map(&:text) end def bulk_deletion_request_body(keys) diff --git a/lib/mailers/attestation_closed_mail_discrepancy_mailer.rb b/lib/mailers/attestation_closed_mail_discrepancy_mailer.rb index 01b5ac992..205e08e98 100644 --- a/lib/mailers/attestation_closed_mail_discrepancy_mailer.rb +++ b/lib/mailers/attestation_closed_mail_discrepancy_mailer.rb @@ -13,7 +13,7 @@ module Mailers if procedures.count == 1 procedure_ids = "votre démarche nº #{procedures.first.id}" else - procedure_ids = 'vos démarches nº ' + procedures.map{ |p| p.id }.join(', ') + procedure_ids = 'vos démarches nº ' + procedures.map(&:id).join(', ') end "demarches-simplifiees.fr – mise à jour nécessaire de l’accusé d’acceptation de #{procedure_ids}" end 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 6b5d48e0c..fead2d063 100644 --- a/lib/tasks/2018_01_18_clean_datetime_in_champs.rake +++ b/lib/tasks/2018_01_18_clean_datetime_in_champs.rake @@ -2,7 +2,7 @@ require Rails.root.join("lib", "tasks", "task_helper") namespace :'2018_01_18_clean_datetime_in_champs' do task clean: :environment do - datetime_champs = TypeDeChamp.where(type_champ: "datetime").flat_map{ |t| t.champ } + datetime_champs = TypeDeChamp.where(type_champ: "datetime").flat_map(&:champ) # Match " HH:MM" => nil a datetime is not valid if not composed by date AND time datetime_champs.select { |c| /^\s\d{2}:\d{2}$/.match(c.value) }.each do |c| diff --git a/lib/tasks/2018_06_04_scan_pjs.rake b/lib/tasks/2018_06_04_scan_pjs.rake index 3ad0e15dc..524486e42 100644 --- a/lib/tasks/2018_06_04_scan_pjs.rake +++ b/lib/tasks/2018_06_04_scan_pjs.rake @@ -1,7 +1,5 @@ namespace :'2018_06_04_scan_pjs' do task scan_all: :environment do - Champs::PieceJustificativeChamp.all.each do |pj_champ| - pj_champ.create_virus_scan - end + Champs::PieceJustificativeChamp.all.each(&:create_virus_scan) end end diff --git a/lib/tasks/2018_06_06_users_for_admins_and_gestionnaires.rake b/lib/tasks/2018_06_06_users_for_admins_and_gestionnaires.rake index 418642734..d99423ab2 100644 --- a/lib/tasks/2018_06_06_users_for_admins_and_gestionnaires.rake +++ b/lib/tasks/2018_06_06_users_for_admins_and_gestionnaires.rake @@ -3,7 +3,7 @@ require Rails.root.join("lib", "tasks", "task_helper") namespace :'2018_06_06_users_for_admins_and_gestionnaires' do task preactivate: :environment do preactivate_users(Gestionnaire, 'accompagnateur') { |g| g.reset_password_token.nil? } - preactivate_users(Administrateur) { |a| a.active? } + preactivate_users(Administrateur, &:active?) end def preactivate_users(model, role_name = nil, &block) diff --git a/lib/tasks/support.rake b/lib/tasks/support.rake index f4bbb82cc..e4832dd67 100644 --- a/lib/tasks/support.rake +++ b/lib/tasks/support.rake @@ -45,7 +45,7 @@ namespace :support do if user.dossiers.state_instruction_commencee.any? fail "Cannot delete this user because instruction has started for some dossiers" end - user.dossiers.each { |d| d.delete_and_keep_track } + user.dossiers.each(&:delete_and_keep_track) user.destroy end end From 2004b9a86445b48d72369646c84024bd38d02973 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 14:22:01 +0200 Subject: [PATCH 16/17] Enable Style/SymbolLiteral --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 286ec3383..b752a9656 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1202,7 +1202,7 @@ Style/SymbolArray: Enabled: false Style/SymbolLiteral: - Enabled: false + Enabled: true Style/SymbolProc: Enabled: true From c91a1cf474f7e1031781d4fe041218d3b01e4fd0 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 1 Oct 2018 14:26:45 +0200 Subject: [PATCH 17/17] Enable Style/SymbolArray --- .rubocop.yml | 3 ++- app/controllers/application_controller.rb | 2 +- app/controllers/gestionnaires/passwords_controller.rb | 4 ++-- app/controllers/users/passwords_controller.rb | 4 ++-- app/models/attestation_template.rb | 2 +- app/models/procedure.rb | 2 +- lib/tasks/2017_12_04_translate_dossier_state_to_french.rake | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b752a9656..4d0d06dfa 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1199,7 +1199,8 @@ Style/StructInheritance: Enabled: false Style/SymbolArray: - Enabled: false + Enabled: true + EnforcedStyle: brackets Style/SymbolLiteral: Enabled: true diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2573a9a38..a97facd7a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -143,7 +143,7 @@ class ApplicationController < ActionController::Base elsif api_request render json: { error: MAINTENANCE_MESSAGE }.to_json, status: :service_unavailable else - %i(user gestionnaire administrateur).each { |role| sign_out(role) } + [:user, :gestionnaire, :administrateur].each { |role| sign_out(role) } flash[:alert] = MAINTENANCE_MESSAGE redirect_to root_path end diff --git a/app/controllers/gestionnaires/passwords_controller.rb b/app/controllers/gestionnaires/passwords_controller.rb index df49d7a13..44049eebc 100644 --- a/app/controllers/gestionnaires/passwords_controller.rb +++ b/app/controllers/gestionnaires/passwords_controller.rb @@ -1,6 +1,6 @@ class Gestionnaires::PasswordsController < Devise::PasswordsController - after_action :try_to_authenticate_user, only: %i(update) - after_action :try_to_authenticate_administrateur, only: %i(update) + after_action :try_to_authenticate_user, only: [:update] + after_action :try_to_authenticate_administrateur, only: [:update] # GET /resource/password/new # def new diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb index 92ffda801..f65b71202 100644 --- a/app/controllers/users/passwords_controller.rb +++ b/app/controllers/users/passwords_controller.rb @@ -1,6 +1,6 @@ class Users::PasswordsController < Devise::PasswordsController - after_action :try_to_authenticate_gestionnaire, only: %i(update) - after_action :try_to_authenticate_administrateur, only: %i(update) + after_action :try_to_authenticate_gestionnaire, only: [:update] + after_action :try_to_authenticate_administrateur, only: [:update] # GET /resource/password/new # def new diff --git a/app/models/attestation_template.rb b/app/models/attestation_template.rb index d44d4196f..0cf20c5c4 100644 --- a/app/models/attestation_template.rb +++ b/app/models/attestation_template.rb @@ -61,7 +61,7 @@ class AttestationTemplate < ApplicationRecord end def logo_signature_file_size - %i[logo signature] + [:logo, :signature] .select { |file_name| send(file_name).present? } .each { |file_name| file_size_check(file_name) } end diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 8f9c31861..6ffe9a620 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -224,7 +224,7 @@ class Procedure < ApplicationRecord procedure.logo_secure_token = nil procedure.remote_logo_url = self.logo_url - %i(notice deliberation).each { |attachment| clone_attachment(procedure, attachment) } + [:notice, :deliberation].each { |attachment| clone_attachment(procedure, attachment) } procedure.administrateur = admin procedure.initiated_mail = initiated_mail&.dup diff --git a/lib/tasks/2017_12_04_translate_dossier_state_to_french.rake b/lib/tasks/2017_12_04_translate_dossier_state_to_french.rake index be3a6fd6c..8c54200f2 100644 --- a/lib/tasks/2017_12_04_translate_dossier_state_to_french.rake +++ b/lib/tasks/2017_12_04_translate_dossier_state_to_french.rake @@ -23,7 +23,7 @@ namespace :'2017_12_04_translate_dossier_state_to_french' do Dossier.unscoped.where(state: 'without_continuation').update_all(state: 'sans_suite') end - task all: %i(brouillon en_construction en_instruction accepte refuse sans_suite) do + task all: [:brouillon, :en_construction, :en_instruction, :accepte, :refuse, :sans_suite] do end task revert: :environment do