Merge pull request #5616 from Keirua/bump-rubocop

Bump rubocop
This commit is contained in:
Keirua 2020-09-25 15:22:47 +02:00 committed by GitHub
commit a21e26bd82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 74 additions and 54 deletions

View file

@ -289,7 +289,7 @@ Layout/SpaceInsideReferenceBrackets:
Layout/SpaceInsideStringInterpolation: Layout/SpaceInsideStringInterpolation:
Enabled: true Enabled: true
Layout/Tab: Layout/IndentationStyle:
Enabled: true Enabled: true
Layout/TrailingEmptyLines: Layout/TrailingEmptyLines:
@ -506,7 +506,7 @@ Lint/UselessAssignment:
Exclude: Exclude:
- "spec/**/*" - "spec/**/*"
Lint/UselessComparison: Lint/BinaryOperatorWithIdenticalOperands:
Enabled: true Enabled: true
Lint/UselessElseWithoutRescue: Lint/UselessElseWithoutRescue:
@ -1045,7 +1045,7 @@ Style/MethodCalledOnDoEndBlock:
Style/MethodDefParentheses: Style/MethodDefParentheses:
Enabled: true Enabled: true
Style/MethodMissingSuper: Lint/MissingSuper:
Enabled: false Enabled: false
Style/MinMax: Style/MinMax:
@ -1315,3 +1315,34 @@ Style/YodaCondition:
Style/ZeroLengthPredicate: Style/ZeroLengthPredicate:
Enabled: true Enabled: true
Rails/ActiveRecordCallbacksOrder:
Enabled: false
Rails/AfterCommitOverride:
Enabled: true
Rails/FindById:
Enabled: true
Rails/Inquiry:
Enabled: true
Rails/MailerName:
Enabled: true
Rails/MatchRoute:
Enabled: true
Rails/NegateInclude:
Enabled: false
Rails/Pluck:
Enabled: false
Rails/PluckInWhere:
Enabled: true
Rails/RenderInline:
Enabled: true
Rails/RenderPlainText:
Enabled: true
Rails/ShortI18n:
Enabled: true
Rails/SquishedSQLHeredocs:
Enabled: true
Rails/WhereExists:
Enabled: true
Rails/WhereNot:
Enabled: true

View file

@ -3,8 +3,8 @@ source 'https://rubygems.org'
gem 'aasm' gem 'aasm'
gem 'active_link_to' # Automatically set a class on active links gem 'active_link_to' # Automatically set a class on active links
gem 'active_model_serializers' gem 'active_model_serializers'
gem 'active_storage_validations'
gem 'activestorage-openstack' gem 'activestorage-openstack'
gem 'active_storage_validations'
gem 'administrate' gem 'administrate'
gem 'after_party' gem 'after_party'
gem 'anchored' gem 'anchored'
@ -31,13 +31,13 @@ gem 'flipper-active_record'
gem 'flipper-ui' gem 'flipper-ui'
gem 'font-awesome-rails' gem 'font-awesome-rails'
gem 'fugit' gem 'fugit'
gem 'geo_coord', require: "geo/coord"
gem 'geocoder' gem 'geocoder'
gem 'geo_coord', require: "geo/coord"
gem 'gon' gem 'gon'
gem 'graphql' gem 'graphql'
gem 'graphql-batch' gem 'graphql-batch'
gem 'graphql-rails_logger'
gem 'graphql_playground-rails' gem 'graphql_playground-rails'
gem 'graphql-rails_logger'
gem 'groupdate' gem 'groupdate'
gem 'haml-rails' gem 'haml-rails'
gem 'hashie' gem 'hashie'
@ -118,8 +118,8 @@ group :development, :test do
gem 'graphql-schema_comparator' gem 'graphql-schema_comparator'
gem 'mina', git: 'https://github.com/mina-deploy/mina.git', require: false # Deploy gem 'mina', git: 'https://github.com/mina-deploy/mina.git', require: false # Deploy
gem 'pry-byebug' gem 'pry-byebug'
gem 'rspec-rails'
gem 'rspec_junit_formatter', require: false gem 'rspec_junit_formatter', require: false
gem 'rspec-rails'
gem 'ruby-debug-ide', require: false gem 'ruby-debug-ide', require: false
gem 'simple_xlsx_reader' gem 'simple_xlsx_reader'
gem 'spring' # Spring speeds up development by keeping your application running in the background gem 'spring' # Spring speeds up development by keeping your application running in the background

View file

@ -344,7 +344,6 @@ GEM
iban-tools (1.1.0) iban-tools (1.1.0)
ice_nine (0.11.2) ice_nine (0.11.2)
ipaddress (0.8.3) ipaddress (0.8.3)
jaro_winkler (1.5.4)
jquery-rails (4.4.0) jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0) railties (>= 4.2.0)
@ -554,7 +553,7 @@ GEM
execjs execjs
railties (>= 3.2) railties (>= 3.2)
tilt tilt
regexp_parser (1.7.1) regexp_parser (1.8.0)
request_store (1.5.0) request_store (1.5.0)
rack (>= 1.4) rack (>= 1.4)
responders (3.0.1) responders (3.0.1)
@ -597,23 +596,27 @@ GEM
rspec-support (3.9.3) rspec-support (3.9.3)
rspec_junit_formatter (0.4.1) rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0) rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.81.0) rubocop (0.91.1)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 2.7.0.1) parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml rexml
rubocop-ast (>= 0.4.0, < 1.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0) unicode-display_width (>= 1.4.0, < 2.0)
rubocop-performance (1.5.2) rubocop-ast (0.4.2)
rubocop (>= 0.71.0) parser (>= 2.7.1.4)
rubocop-rails (2.5.2) rubocop-performance (1.8.1)
activesupport rubocop (>= 0.87.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.8.1)
activesupport (>= 4.2.0)
rack (>= 1.1) rack (>= 1.1)
rubocop (>= 0.72.0) rubocop (>= 0.87.0)
rubocop-rails_config (0.10.0) rubocop-rails_config (0.12.6)
railties (>= 5.0) railties (>= 5.0)
rubocop (~> 0.80) rubocop (~> 0.82)
rubocop-performance (~> 1.3) rubocop-performance (~> 1.3)
rubocop-rails (~> 2.0) rubocop-rails (~> 2.0)
rubocop-rspec-focused (1.0.0) rubocop-rspec-focused (1.0.0)

View file

@ -360,7 +360,7 @@ class StatsController < ApplicationController
if weekly_dossiers_count == 0 if weekly_dossiers_count == 0
result = 0 result = 0
else else
weekly_dossier_with_avis_count = weekly_dossiers.filter { |dossier| dossier.avis.present? }.count weekly_dossier_with_avis_count = weekly_dossiers.count { |dossier| dossier.avis.present? }
result = percentage(weekly_dossier_with_avis_count, weekly_dossiers_count) result = percentage(weekly_dossier_with_avis_count, weekly_dossiers_count)
end end

View file

@ -37,7 +37,7 @@ module ChampHelper
when GeoArea.sources.fetch(:cadastre) when GeoArea.sources.fetch(:cadastre)
capture do capture do
concat "Parcelle n° #{geo_area.numero} - Feuille #{geo_area.code_arr} #{geo_area.section} #{geo_area.feuille} - #{geo_area.surface_parcelle.round} m" concat "Parcelle n° #{geo_area.numero} - Feuille #{geo_area.code_arr} #{geo_area.section} #{geo_area.feuille} - #{geo_area.surface_parcelle.round} m"
concat content_tag(:sup, "2") concat tag.sup("2")
end end
when GeoArea.sources.fetch(:quartier_prioritaire) when GeoArea.sources.fetch(:quartier_prioritaire)
"#{geo_area.commune} : #{geo_area.nom}" "#{geo_area.commune} : #{geo_area.nom}"
@ -48,7 +48,7 @@ module ChampHelper
if geo_area.area.present? if geo_area.area.present?
capture do capture do
concat "Une aire de surface #{geo_area.area} m" concat "Une aire de surface #{geo_area.area} m"
concat content_tag(:sup, "2") concat tag.sup("2")
end end
else else
"Une aire de surface inconnue" "Une aire de surface inconnue"

View file

@ -75,7 +75,7 @@ module DossierHelper
def status_badge(state) def status_badge(state)
status_text = dossier_display_state(state, lower: true) status_text = dossier_display_state(state, lower: true)
status_class = state.tr('_', '-') status_class = state.tr('_', '-')
content_tag(:span, status_text, class: "label #{status_class} ") tag.span(status_text, class: "label #{status_class} ")
end end
def deletion_reason_badge(reason) def deletion_reason_badge(reason)
@ -87,7 +87,7 @@ module DossierHelper
status_class = 'unknown' status_class = 'unknown'
end end
content_tag(:span, status_text, class: "label #{status_class} ") tag.span(status_text, class: "label #{status_class} ")
end end
def demandeur_dossier(dossier) def demandeur_dossier(dossier)

View file

@ -8,7 +8,7 @@ module ProcedureHelper
end end
def procedure_libelle(procedure) def procedure_libelle(procedure)
parts = procedure.brouillon? ? [content_tag(:span, 'démarche en test', class: 'badge')] : [] parts = procedure.brouillon? ? [tag.span('démarche en test', class: 'badge')] : []
parts << procedure.libelle parts << procedure.libelle
safe_join(parts, ' ') safe_join(parts, ' ')
end end

View file

@ -9,7 +9,7 @@ class ApplicationMailer < ActionMailer::Base
end end
rescue_from Net::SMTPServerBusy do |error| rescue_from Net::SMTPServerBusy do |error|
if error.message =~ /unexpected recipients/ if /unexpected recipients/.match?(error.message)
message.perform_deliveries = false message.perform_deliveries = false
end end
end end

View file

@ -10,7 +10,7 @@ class DeviseUserMailer < Devise::Mailer
end end
rescue_from Net::SMTPServerBusy do |error| rescue_from Net::SMTPServerBusy do |error|
if error.message =~ /unexpected recipients/ if /unexpected recipients/.match?(error.message)
message.perform_deliveries = false message.perform_deliveries = false
end end
end end

View file

@ -295,8 +295,7 @@ class ProcedurePresentation < ApplicationRecord
def valid_columns_for_table(table) def valid_columns_for_table(table)
@column_whitelist ||= fields @column_whitelist ||= fields
.group_by { |field| field['table'] } .group_by { |field| field['table'] }
.map { |table, fields| [table, Set.new(fields.pluck('column'))] } .transform_values { |fields| Set.new(fields.pluck('column')) }
.to_h
@column_whitelist[table] || [] @column_whitelist[table] || []
end end

View file

@ -81,16 +81,12 @@ class AdministrateurUsageStatisticsService
with_default( with_default(
0, 0,
nb_dossiers_by_administrateur_id_and_procedure_id_and_synthetic_state[administrateur_id] nb_dossiers_by_administrateur_id_and_procedure_id_and_synthetic_state[administrateur_id]
.map do |procedure_id, nb_dossiers_by_synthetic_state| .transform_values do |nb_dossiers_by_synthetic_state|
[ nb_dossiers_by_synthetic_state
procedure_id,
nb_dossiers_by_synthetic_state
.reject { |synthetic_state, _count| ['brouillon', 'archive'].include?(synthetic_state) } .reject { |synthetic_state, _count| ['brouillon', 'archive'].include?(synthetic_state) }
.map { |_synthetic_state, count| count } .map { |_synthetic_state, count| count }
.sum .sum
]
end end
.to_h
) )
end end
@ -105,8 +101,7 @@ class AdministrateurUsageStatisticsService
.reject { |procedure_id, _nb_dossiers_by_synthetic_state| is_brouillon(procedure_id) } .reject { |procedure_id, _nb_dossiers_by_synthetic_state| is_brouillon(procedure_id) }
.flat_map { |_procedure_id, nb_dossiers_by_synthetic_state| nb_dossiers_by_synthetic_state.to_a } .flat_map { |_procedure_id, nb_dossiers_by_synthetic_state| nb_dossiers_by_synthetic_state.to_a }
.group_by { |synthetic_state, _count| synthetic_state } .group_by { |synthetic_state, _count| synthetic_state }
.map { |synthetic_state, synthetic_states_and_counts| [synthetic_state, synthetic_states_and_counts.map { |_synthetic_state, count| count }.sum] } .transform_values { |synthetic_states_and_counts| synthetic_states_and_counts.map { |_synthetic_state, count| count }.sum }
.to_h
) )
end end

View file

@ -1,5 +1,5 @@
# This file is used by Rack-based servers to start the application. # This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__) require ::File.expand_path('config/environment', __dir__)
run Rails.application run Rails.application

View file

@ -213,8 +213,7 @@ feature 'The routing', js: true do
def register_instructeur_and_log_in(email) def register_instructeur_and_log_in(email)
confirmation_email = emails_sent_to(email) confirmation_email = emails_sent_to(email)
.filter { |m| m.subject == 'Activez votre compte instructeur' } .find { |m| m.subject == 'Activez votre compte instructeur' }
.first
token_params = confirmation_email.body.match(/token=[^"]+/) token_params = confirmation_email.body.match(/token=[^"]+/)
visit "users/activate?#{token_params}" visit "users/activate?#{token_params}"

View file

@ -151,13 +151,11 @@ describe AttestationTemplate, type: :model do
context 'and their value in the dossier are not nil' do context 'and their value in the dossier are not nil' do
before do before do
dossier.champs dossier.champs
.filter { |champ| champ.libelle == 'libelleA' } .find { |champ| champ.libelle == 'libelleA' }
.first
.update(value: 'libelle1') .update(value: 'libelle1')
dossier.champs dossier.champs
.filter { |champ| champ.libelle == 'libelleB' } .find { |champ| champ.libelle == 'libelleB' }
.first
.update(value: 'libelle2') .update(value: 'libelle2')
end end

View file

@ -123,13 +123,11 @@ describe TagsSubstitutionConcern, type: :model do
context 'and their value in the dossier are not nil' do context 'and their value in the dossier are not nil' do
before do before do
dossier.champs dossier.champs
.filter { |champ| champ.libelle == 'libelleA' } .find { |champ| champ.libelle == 'libelleA' }
.first
.update(value: 'libelle1') .update(value: 'libelle1')
dossier.champs dossier.champs
.filter { |champ| champ.libelle == 'libelleB' } .find { |champ| champ.libelle == 'libelleB' }
.first
.update(value: 'libelle2') .update(value: 'libelle2')
end end
@ -151,8 +149,7 @@ describe TagsSubstitutionConcern, type: :model do
context 'and their value in the dossier are not nil' do context 'and their value in the dossier are not nil' do
before do before do
dossier.champs dossier.champs
.filter { |champ| champ.libelle == "Intitulé de l'‘«\"évènement\"»’" } .find { |champ| champ.libelle == "Intitulé de l'‘«\"évènement\"»’" }
.first
.update(value: 'ceci est mon évènement') .update(value: 'ceci est mon évènement')
end end
@ -302,13 +299,11 @@ describe TagsSubstitutionConcern, type: :model do
context 'and its value in the dossier are not nil' do context 'and its value in the dossier are not nil' do
before do before do
dossier.champs dossier.champs
.filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:date) } .find { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:date) }
.first
.update(value: '2017-04-15') .update(value: '2017-04-15')
dossier.champs dossier.champs
.filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:datetime) } .find { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:datetime) }
.first
.update(value: '2017-09-13 09:00') .update(value: '2017-09-13 09:00')
end end