chore(rubocop): fix Rails/CompactBlank

This commit is contained in:
Colin Darie 2023-04-19 10:59:21 +02:00
parent b273e7b67e
commit bd8e8633e7
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
6 changed files with 9 additions and 9 deletions

View file

@ -73,7 +73,7 @@ class SupportController < ApplicationController
[params[:tags], params[:type]].flatten.compact [params[:tags], params[:type]].flatten.compact
.map { |tag| tag.split(',') } .map { |tag| tag.split(',') }
.flatten .flatten
.reject(&:blank?).uniq .compact_blank.uniq
end end
def browser_name def browser_name

View file

@ -118,7 +118,7 @@ class Champs::MultipleDropDownListChamp < Champ
private private
def values_are_in_options def values_are_in_options
json = selected_options.reject(&:blank?) json = selected_options.compact_blank
return if json.empty? return if json.empty?
return if (json - enabled_non_empty_options).empty? return if (json - enabled_non_empty_options).empty?

View file

@ -144,7 +144,7 @@ class Etablissement < ApplicationRecord
"#{numero_voie} #{type_voie} #{nom_voie}", "#{numero_voie} #{type_voie} #{nom_voie}",
complement_adresse, complement_adresse,
"#{code_postal} #{localite}" "#{code_postal} #{localite}"
].reject(&:blank?).join(', ').squeeze(' ') ].compact_blank.join(', ').squeeze(' ')
end end
def association? def association?

View file

@ -431,7 +431,7 @@ class TypeDeChamp < ApplicationRecord
# then rails decided to add this blank ("") option when the select is required # then rails decided to add this blank ("") option when the select is required
# so we revert this change # so we revert this change
def options_without_empty_value_when_mandatory(options) def options_without_empty_value_when_mandatory(options)
mandatory? ? options.reject(&:blank?) : options mandatory? ? options.compact_blank : options
end end
def drop_down_list_options? def drop_down_list_options?

View file

@ -18,7 +18,7 @@ class TypesDeChamp::PrefillRepetitionTypeDeChamp < TypesDeChamp::PrefillTypeDeCh
value.map.with_index do |repetition, index| value.map.with_index do |repetition, index|
PrefillRepetitionRow.new(champ, repetition, index, @revision).to_assignable_attributes PrefillRepetitionRow.new(champ, repetition, index, @revision).to_assignable_attributes
end.reject(&:blank?) end.compact_blank
end end
private private

View file

@ -154,7 +154,7 @@ def render_single_champ(pdf, champ)
add_libelle(pdf, champ) add_libelle(pdf, champ)
add_optionnal_description(pdf, champ) add_optionnal_description(pdf, champ)
add_explanation(pdf, 'Cochez la mention applicable, une seule valeur possible') add_explanation(pdf, 'Cochez la mention applicable, une seule valeur possible')
champ.options.reject(&:blank?).each do |option| champ.options.compact_blank.each do |option|
format_with_checkbox(pdf, option) format_with_checkbox(pdf, option)
end end
pdf.text "\n" pdf.text "\n"
@ -162,15 +162,15 @@ def render_single_champ(pdf, champ)
add_libelle(pdf, champ) add_libelle(pdf, champ)
add_optionnal_description(pdf, champ) add_optionnal_description(pdf, champ)
add_explanation(pdf, 'Cochez la mention applicable, plusieurs valeurs possibles') add_explanation(pdf, 'Cochez la mention applicable, plusieurs valeurs possibles')
champ.options.reject(&:blank?).each do |option| champ.options.compact_blank.each do |option|
format_with_checkbox(pdf, option) format_with_checkbox(pdf, option)
end end
pdf.text "\n" pdf.text "\n"
when 'Champs::LinkedDropDownListChamp' when 'Champs::LinkedDropDownListChamp'
add_libelle(pdf, champ) add_libelle(pdf, champ)
champ.primary_options.reject(&:blank?).each do |o| champ.primary_options.compact_blank.each do |o|
format_with_checkbox(pdf, o) format_with_checkbox(pdf, o)
champ.secondary_options[o].reject(&:blank?).each do |secondary_option| champ.secondary_options[o].compact_blank.each do |secondary_option|
format_with_checkbox(pdf, secondary_option, 15) format_with_checkbox(pdf, secondary_option, 15)
end end
end end