diff --git a/app/controllers/admin/instructeurs_controller.rb b/app/controllers/admin/instructeurs_controller.rb index a79dea1fd..85e3a91e1 100644 --- a/app/controllers/admin/instructeurs_controller.rb +++ b/app/controllers/admin/instructeurs_controller.rb @@ -16,7 +16,10 @@ class Admin::InstructeursController < AdminController array: true not_assign_scope = current_administrateur.gestionnaires.where.not(id: assign_scope.ids) - not_assign_scope = not_assign_scope.where("email LIKE ?", "%#{params[:filter]}%") if params[:filter] + + if params[:filter] + not_assign_scope = not_assign_scope.where("email LIKE ?", "%#{params[:filter]}%") + end @instructeurs_not_assign = smart_listing_create :instructeurs_not_assign, not_assign_scope, diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index cd6671683..f8f283c79 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -55,7 +55,9 @@ class Admin::ProceduresController < AdminController def destroy procedure = current_administrateur.procedures.find(params[:id]) - return render json: {}, status: 401 if procedure.publiee_ou_archivee? + if procedure.publiee_ou_archivee? + return render json: {}, status: 401 + end procedure.destroy @@ -72,7 +74,11 @@ class Admin::ProceduresController < AdminController def create @procedure = Procedure.new(procedure_params) - @procedure.module_api_carto = ModuleAPICarto.new(create_module_api_carto_params) if @procedure.valid? + + if @procedure.valid? + @procedure.module_api_carto = ModuleAPICarto.new(create_module_api_carto_params) + end + @path = params.require(:procedure).permit(:path)[:path] @available = !ProcedurePath.exists?(path: @path) @mine = ProcedurePath.mine?(current_administrateur, @path) diff --git a/app/controllers/administrations/sessions_controller.rb b/app/controllers/administrations/sessions_controller.rb index 5c1c66000..78de713c8 100644 --- a/app/controllers/administrations/sessions_controller.rb +++ b/app/controllers/administrations/sessions_controller.rb @@ -5,7 +5,10 @@ class Administrations::SessionsController < ApplicationController end def destroy - sign_out :administration if administration_signed_in? + if administration_signed_in? + sign_out :administration + end + redirect_to root_path end end diff --git a/app/controllers/commentaires_controller.rb b/app/controllers/commentaires_controller.rb index af77f59d0..d54a0e0d0 100644 --- a/app/controllers/commentaires_controller.rb +++ b/app/controllers/commentaires_controller.rb @@ -1,7 +1,10 @@ class CommentairesController < ApplicationController def create @commentaire = Commentaire.new - @commentaire.champ = @commentaire.dossier.champs.find(params[:champ_id]) if params[:champ_id] + + if params[:champ_id] + @commentaire.champ = @commentaire.dossier.champs.find(params[:champ_id]) + end dossier_id = params['dossier_id'] @commentaire.email = current_user.email diff --git a/app/controllers/france_connect/particulier_controller.rb b/app/controllers/france_connect/particulier_controller.rb index 33e9d6fd9..8535493d6 100644 --- a/app/controllers/france_connect/particulier_controller.rb +++ b/app/controllers/france_connect/particulier_controller.rb @@ -36,9 +36,17 @@ class FranceConnect::ParticulierController < ApplicationController end def connect_france_connect_particulier(user) - sign_out :user if user_signed_in? - sign_out :gestionnaire if gestionnaire_signed_in? - sign_out :administrateur if administrateur_signed_in? + if user_signed_in? + sign_out :user + end + + if gestionnaire_signed_in? + sign_out :gestionnaire + end + + if administrateur_signed_in? + sign_out :administrateur + end sign_in user diff --git a/app/controllers/gestionnaires/passwords_controller.rb b/app/controllers/gestionnaires/passwords_controller.rb index 87373d162..df49d7a13 100644 --- a/app/controllers/gestionnaires/passwords_controller.rb +++ b/app/controllers/gestionnaires/passwords_controller.rb @@ -36,14 +36,20 @@ class Gestionnaires::PasswordsController < Devise::PasswordsController def try_to_authenticate_user if gestionnaire_signed_in? user = User.find_by(email: current_gestionnaire.email) - sign_in user if user + + if user + sign_in user + end end end def try_to_authenticate_administrateur if gestionnaire_signed_in? administrateur = Administrateur.find_by(email: current_gestionnaire.email) - sign_in administrateur if administrateur + + if administrateur + sign_in administrateur + end end end end diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 76950e5a4..44d6d0789 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -131,7 +131,10 @@ module NewGestionnaire def position etablissement = dossier.etablissement - point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) if etablissement.present? + + if etablissement.present? + point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) + end lon = "2.428462" lat = "46.538192" diff --git a/app/controllers/sessions/sessions_controller.rb b/app/controllers/sessions/sessions_controller.rb index e30c51fc8..ed30ce252 100644 --- a/app/controllers/sessions/sessions_controller.rb +++ b/app/controllers/sessions/sessions_controller.rb @@ -2,9 +2,20 @@ class Sessions::SessionsController < Devise::SessionsController before_action :before_sign_in, only: [:create] def before_sign_in - sign_out :user if user_signed_in? - sign_out :gestionnaire if gestionnaire_signed_in? - sign_out :administrateur if administrateur_signed_in? - sign_out :administration if administration_signed_in? + if user_signed_in? + sign_out :user + end + + if gestionnaire_signed_in? + sign_out :gestionnaire + end + + if administrateur_signed_in? + sign_out :administrateur + end + + if administration_signed_in? + sign_out :administration + end end end diff --git a/app/controllers/users/carte_controller.rb b/app/controllers/users/carte_controller.rb index e8ce6d116..1e277dd06 100644 --- a/app/controllers/users/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -35,7 +35,9 @@ class Users::CarteController < UsersController etablissement = nil end - point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) if etablissement.present? + if etablissement.present? + point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) + end lon = '2.428462' lat = '46.538192' diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index e70091633..9e382270e 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -2,7 +2,10 @@ class Users::DescriptionController < UsersController def pieces_justificatives invite = current_user.invite? params[:dossier_id] - @dossier ||= Dossier.find(params[:dossier_id]) if invite + if invite + @dossier ||= Dossier.find(params[:dossier_id]) + end + @dossier ||= current_user_dossier if (errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params)).present? @@ -13,10 +16,14 @@ class Users::DescriptionController < UsersController end else - flash.notice = 'Nouveaux fichiers envoyés' if flash.alert.nil? + if flash.alert.nil? + flash.notice = 'Nouveaux fichiers envoyés' + end end - return redirect_to users_dossiers_invite_path(id: current_user.invites.find_by(dossier_id: @dossier.id).id) if invite + if invite + return redirect_to users_dossiers_invite_path(id: current_user.invites.find_by(dossier_id: @dossier.id).id) + end redirect_to users_dossier_recapitulatif_path end diff --git a/app/controllers/users/dossiers/add_siret_controller.rb b/app/controllers/users/dossiers/add_siret_controller.rb index 35251ed3f..9b39f38c8 100644 --- a/app/controllers/users/dossiers/add_siret_controller.rb +++ b/app/controllers/users/dossiers/add_siret_controller.rb @@ -2,10 +2,13 @@ class Users::Dossiers::AddSiretController < ApplicationController def show @facade = DossierFacades.new params[:dossier_id], current_user.email - raise ActiveRecord::RecordNotFound if !@facade.procedure.individual_with_siret? - - @siret = current_user.siret if current_user.siret.present? + if !@facade.procedure.individual_with_siret? + raise ActiveRecord::RecordNotFound + end + if current_user.siret.present? + @siret = current_user.siret + end rescue ActiveRecord::RecordNotFound flash.alert = t('errors.messages.dossier_not_found') redirect_to url_for dossiers_path diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 9349d72d5..9ff440f37 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -54,7 +54,9 @@ class Users::DossiersController < UsersController dossier = Dossier.create!(procedure: procedure, user: current_user, state: Dossier.states.fetch(:brouillon)) siret = params[:siret] || current_user.siret - update_current_user_siret! siret if siret.present? + if siret.present? + update_current_user_siret! siret + end if dossier.procedure.for_individual redirect_to identite_dossier_path(dossier) @@ -67,7 +69,9 @@ class Users::DossiersController < UsersController def show @facade = facade - @siret = current_user.siret if current_user.siret.present? + if current_user.siret.present? + @siret = current_user.siret + end if @facade.procedure.for_individual? && current_user.loged_in_with_france_connect? individual = @facade.dossier.individual @@ -165,7 +169,9 @@ class Users::DossiersController < UsersController private def check_siret - errors_valid_siret if !Siret.new(siret: siret).valid? + if !Siret.new(siret: siret).valid? + errors_valid_siret + end end def errors_valid_siret diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb index 0c199841d..92ffda801 100644 --- a/app/controllers/users/passwords_controller.rb +++ b/app/controllers/users/passwords_controller.rb @@ -36,14 +36,20 @@ class Users::PasswordsController < Devise::PasswordsController def try_to_authenticate_gestionnaire if user_signed_in? gestionnaire = Gestionnaire.find_by(email: current_user.email) - sign_in gestionnaire if gestionnaire + + if gestionnaire + sign_in gestionnaire + end end end def try_to_authenticate_administrateur if user_signed_in? administrateur = Administrateur.find_by(email: current_user.email) - sign_in administrateur if administrateur + + if administrateur + sign_in administrateur + end end end end diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 89af9412d..85964b628 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -13,7 +13,10 @@ class Users::RegistrationsController < Devise::RegistrationsController # Allow pre-filling the user email from a query parameter build_resource({ email: sign_up_params[:email] }) - yield resource if block_given? + if block_given? + yield resource + end + respond_with resource end diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index 14b93bab5..5d43d18e6 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -39,8 +39,13 @@ class Users::SessionsController < Sessions::SessionsController # DELETE /resource/sign_out def destroy - sign_out :gestionnaire if gestionnaire_signed_in? - sign_out :administrateur if administrateur_signed_in? + if gestionnaire_signed_in? + sign_out :gestionnaire + end + + if administrateur_signed_in? + sign_out :administrateur + end if user_signed_in? connected_with_france_connect = current_user.loged_in_with_france_connect @@ -72,7 +77,9 @@ class Users::SessionsController < Sessions::SessionsController end def user_return_to_procedure_id - return nil if session["user_return_to"].nil? + if session["user_return_to"].nil? + return nil + end NumberService.to_number session["user_return_to"].split("?procedure_id=").second end diff --git a/app/decorators/champ_decorator.rb b/app/decorators/champ_decorator.rb index b3621337b..9722cfb66 100644 --- a/app/decorators/champ_decorator.rb +++ b/app/decorators/champ_decorator.rb @@ -30,6 +30,8 @@ class ChampDecorator < Draper::Decorator end def description_with_links - description.gsub(URI.regexp, '\0') if description + if description + description.gsub(URI.regexp, '\0') + end end end diff --git a/app/decorators/type_de_piece_justificative_decorator.rb b/app/decorators/type_de_piece_justificative_decorator.rb index eb2bb6200..3f6e6b382 100644 --- a/app/decorators/type_de_piece_justificative_decorator.rb +++ b/app/decorators/type_de_piece_justificative_decorator.rb @@ -1,11 +1,15 @@ class TypeDePieceJustificativeDecorator < Draper::Decorator delegate_all def button_up(params) - h.link_to '', params[:url], class: up_classes, id: "btn_up_#{params[:index]}", remote: true, method: :post if display_up_button?(params[:index]) + if display_up_button?(params[:index]) + h.link_to '', params[:url], class: up_classes, id: "btn_up_#{params[:index]}", remote: true, method: :post + end end def button_down(params) - h.link_to '', params[:url], class: down_classes, id: "btn_down_#{params[:index]}", remote: true, method: :post if display_down_button?(params[:index]) + if display_down_button?(params[:index]) + h.link_to '', params[:url], class: down_classes, id: "btn_down_#{params[:index]}", remote: true, method: :post + end end private diff --git a/app/lib/file_size_validator.rb b/app/lib/file_size_validator.rb index 43f1cbcd4..8537ce414 100644 --- a/app/lib/file_size_validator.rb +++ b/app/lib/file_size_validator.rb @@ -10,9 +10,15 @@ class FileSizeValidator < ActiveModel::EachValidator range = options.delete(:in) || options.delete(:within) if range.present? - raise ArgumentError, ":in and :within must be a Range" if !range.is_a?(Range) + if !range.is_a?(Range) + raise ArgumentError, ":in and :within must be a Range" + end + options[:minimum], options[:maximum] = range.begin, range.end - options[:maximum] -= 1 if range.exclude_end? + + if range.exclude_end? + options[:maximum] -= 1 + end end super @@ -35,12 +41,18 @@ class FileSizeValidator < ActiveModel::EachValidator end def validate_each(record, attribute, value) - raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") if !value.kind_of? CarrierWave::Uploader::Base + if !value.kind_of? CarrierWave::Uploader::Base + raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") + end - value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String) + if value.kind_of?(String) + value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) + end CHECKS.each do |key, validity_check| - next if !check_value = options[key] + if !check_value = options[key] + next + end check_value = case check_value @@ -50,16 +62,22 @@ class FileSizeValidator < ActiveModel::EachValidator record.send(check_value) end - value ||= [] if key == :maximum + if key == :maximum + value ||= [] + end value_size = value.size - next if value_size.send(validity_check, check_value) + if value_size.send(validity_check, check_value) + next + end errors_options = options.except(*RESERVED_OPTIONS) errors_options[:file_size] = help.number_to_human_size check_value default_message = options[MESSAGES[key]] - errors_options[:message] ||= default_message if default_message + if default_message + errors_options[:message] ||= default_message + end record.errors.add(attribute, MESSAGES[key], errors_options) end diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 97dc3c65f..b06068620 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -31,7 +31,9 @@ class Gestionnaire < ApplicationRecord end def follow(dossier) - return if follow?(dossier) + if follow?(dossier) + return + end followed_dossiers << dossier end diff --git a/app/models/module_api_carto.rb b/app/models/module_api_carto.rb index 94d7a34c5..179d89ef2 100644 --- a/app/models/module_api_carto.rb +++ b/app/models/module_api_carto.rb @@ -6,10 +6,15 @@ class ModuleAPICarto < ApplicationRecord validates :cadastre, presence: true, allow_blank: true, allow_nil: false def classes - modules = '' + modules = '' - modules += 'qp ' if quartiers_prioritaires? - modules += 'cadastre ' if cadastre? + if quartiers_prioritaires? + modules += 'qp ' + end + + if cadastre? + modules += 'cadastre ' + end modules end diff --git a/app/models/siret.rb b/app/models/siret.rb index f1b9cda8a..6aff5363c 100644 --- a/app/models/siret.rb +++ b/app/models/siret.rb @@ -10,6 +10,8 @@ class Siret before_validation :remove_whitespace def remove_whitespace - siret.delete!(' ') if siret.present? + if siret.present? + siret.delete!(' ') + end end end diff --git a/app/services/clamav_service.rb b/app/services/clamav_service.rb index e8e04a021..3ebf065af 100644 --- a/app/services/clamav_service.rb +++ b/app/services/clamav_service.rb @@ -1,7 +1,9 @@ class ClamavService def self.safe_file?(file_path) if Rails.env == 'development' - return CLAMAV[:response] if CLAMAV[:mock?] + if CLAMAV[:mock?] + return CLAMAV[:response] + end end FileUtils.chmod 0666, file_path @@ -9,7 +11,10 @@ class ClamavService client = ClamAV::Client.new response = client.execute(ClamAV::Commands::ScanCommand.new(file_path)) - return false if response.first.class == ClamAV::VirusResponse + if response.first.class == ClamAV::VirusResponse + return false + end + true end end diff --git a/app/services/number_service.rb b/app/services/number_service.rb index bc399d5ef..981f47d9c 100644 --- a/app/services/number_service.rb +++ b/app/services/number_service.rb @@ -1,5 +1,5 @@ class NumberService def self.to_number(string) - string.to_s if Float(string) rescue nil + string.to_s end end diff --git a/app/uploaders/piece_justificative_uploader.rb b/app/uploaders/piece_justificative_uploader.rb index 3168a9804..c9bf93278 100644 --- a/app/uploaders/piece_justificative_uploader.rb +++ b/app/uploaders/piece_justificative_uploader.rb @@ -48,6 +48,8 @@ class PieceJustificativeUploader < BaseUploader end def set_original_filename(file) - model.original_filename ||= file.original_filename if file.respond_to?(:original_filename) + if file.respond_to?(:original_filename) + model.original_filename ||= file.original_filename + end end end diff --git a/app/validators/procedure_path_format_validator.rb b/app/validators/procedure_path_format_validator.rb index 19951bc67..7c5e1f5b9 100644 --- a/app/validators/procedure_path_format_validator.rb +++ b/app/validators/procedure_path_format_validator.rb @@ -4,7 +4,12 @@ class ProcedurePathFormatValidator < ActiveModel::Validator end def validate(record) - return false if record.path.blank? - record.errors[:path] << "Path invalide" if !path_regex.match(record.path) + if record.path.blank? + return false + end + + if !path_regex.match(record.path) + record.errors[:path] << "Path invalide" + end end end diff --git a/db/migrate/20160120094750_create_france_connect_information.rb b/db/migrate/20160120094750_create_france_connect_information.rb index 3363092c0..97dde9ccd 100644 --- a/db/migrate/20160120094750_create_france_connect_information.rb +++ b/db/migrate/20160120094750_create_france_connect_information.rb @@ -18,15 +18,17 @@ class CreateFranceConnectInformation < ActiveRecord::Migration add_reference :france_connect_informations, :user, references: :users User.all.each do |user| - FranceConnectInformation.create({ - gender: user.gender, - given_name: user.given_name, - family_name: user.family_name, - birthdate: user.birthdate, - birthplace: user.birthplace, - france_connect_particulier_id: user.france_connect_particulier_id, - user_id: user.id - }) if user.france_connect_particulier_id.present? + if user.france_connect_particulier_id.present? + FranceConnectInformation.create({ + gender: user.gender, + given_name: user.given_name, + family_name: user.family_name, + birthdate: user.birthdate, + birthplace: user.birthplace, + france_connect_particulier_id: user.france_connect_particulier_id, + user_id: user.id + }) + end end remove_column :users, :gender