Skip to content

Commit

Permalink
Merge pull request #2722 from betagouv/rubocop
Browse files Browse the repository at this point in the history
Rubocop
  • Loading branch information
gregoirenovel authored Oct 3, 2018
2 parents 1b8e382 + c91a1cf commit b6e98ac
Show file tree
Hide file tree
Showing 67 changed files with 105 additions and 111 deletions.
32 changes: 18 additions & 14 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1199,13 +1199,15 @@ Style/StructInheritance:
Enabled: false

Style/SymbolArray:
Enabled: false
Enabled: true
EnforcedStyle: brackets

Style/SymbolLiteral:
Enabled: false
Enabled: true

Style/SymbolProc:
Enabled: false
Enabled: true
IgnoredMethods: [after]

Style/TernaryParentheses:
Enabled: false
Expand All @@ -1220,13 +1222,13 @@ Style/TrailingBodyOnModule:
Enabled: true

Style/TrailingCommaInArguments:
Enabled: false
Enabled: true

Style/TrailingCommaInArrayLiteral:
Enabled: false
Enabled: true

Style/TrailingCommaInHashLiteral:
Enabled: false
Enabled: true

Style/TrailingMethodEndStatement:
Enabled: true
Expand All @@ -1241,31 +1243,33 @@ Style/UnlessElse:
Enabled: true

Style/UnneededCapitalW:
Enabled: false
Enabled: true

Style/UnneededInterpolation:
Enabled: false
Enabled: true

Style/UnneededPercentQ:
Enabled: false
Enabled: true

Style/VariableInterpolation:
Enabled: false
Enabled: true

Style/WhenThen:
Enabled: false

Style/WhileUntilDo:
Enabled: false
Enabled: true

# Disabled because we don't want to use modifiers
Style/WhileUntilModifier:
Enabled: false

Style/WordArray:
Enabled: false
Enabled: true
EnforcedStyle: brackets

Style/YodaCondition:
Enabled: false
Enabled: true

Style/ZeroLengthPredicate:
Enabled: false
Enabled: true
2 changes: 1 addition & 1 deletion Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/mail_templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def update_params
{
procedure_id: params[:procedure_id],
subject: params[:mail_template][:subject],
body: params[:mail_template][:body],
body: params[:mail_template][:body]
}
end
end
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def append_info_to_payload(payload)
payload.merge!({
browser: browser.name,
browser_version: browser.version.to_s,
platform: browser.platform.name,
platform: browser.platform.name
})
end

Expand All @@ -143,7 +143,7 @@ def reject
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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/france_connect/particulier_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def callback

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|
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/gestionnaires/passwords_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/manager/administrateurs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def create
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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/new_user/demarches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def index
.includes(:procedure)
.map(&:procedure)
.uniq
.select { |p| p.publiee? }
.select(&:publiee?)

@popular_demarches = Procedure
.includes(:service)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/stats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def procedures_count_per_administrateur(procedures)
{
'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

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/users/passwords_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/dashboards/administrateur_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AdministrateurDashboard < Administrate::BaseDashboard
:email,
:created_at,
:procedures,
:registration_state,
:registration_state
].freeze

# SHOW_PAGE_ATTRIBUTES
Expand All @@ -40,7 +40,7 @@ class AdministrateurDashboard < Administrate::BaseDashboard
:registration_state,
:current_sign_in_at,
:features,
:procedures,
:procedures
].freeze

# FORM_ATTRIBUTES
Expand Down
2 changes: 1 addition & 1 deletion app/dashboards/dossier_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/dashboards/gestionnaire_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,7 +35,7 @@ class GestionnaireDashboard < Administrate::BaseDashboard
:id,
:email,
:current_sign_in_at,
:created_at,
:created_at
].freeze

# FORM_ATTRIBUTES
Expand Down
6 changes: 3 additions & 3 deletions app/dashboards/procedure_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -47,7 +47,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
:libelle,
:organisation,
:dossiers,
:published_at,
:published_at
].freeze

# SHOW_PAGE_ATTRIBUTES
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/dashboards/service_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -46,7 +46,7 @@ class ServiceDashboard < Administrate::BaseDashboard
:telephone,
:horaires,
:adresse,
:siret,
:siret
].freeze

# FORM_ATTRIBUTES
Expand Down
6 changes: 3 additions & 3 deletions app/dashboards/user_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -35,7 +35,7 @@ class UserDashboard < Administrate::BaseDashboard
:email,
:confirmed?,
:current_sign_in_at,
:created_at,
:created_at
].freeze

# FORM_ATTRIBUTES
Expand Down
2 changes: 1 addition & 1 deletion app/decorators/type_de_champ_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def down_classes
end

def base_classes
%w(btn btn-default form-control fa)
['btn', 'btn-default', 'form-control', 'fa']
end

def display_up_button?(index, private)
Expand Down
2 changes: 1 addition & 1 deletion app/decorators/type_de_piece_justificative_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def down_classes
end

def base_classes
%w(btn btn-default form-control fa)
['btn', 'btn-default', 'form-control', 'fa']
end

def display_up_button?(index)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/string_to_html_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module StringToHtmlHelper
def string_to_html(str)
html_formatted = simple_format(str)
with_links = html_formatted.gsub(URI.regexp, '<a target="_blank" href="\0">\0</a>')
sanitize(with_links, attributes: %w(href target))
sanitize(with_links, attributes: ['href', 'target'])
end
end
4 changes: 1 addition & 3 deletions app/jobs/administrateurs/activate_before_expiration_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions app/jobs/auto_archive_procedure_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/lib/carto/bano/address_retriever.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def driver
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
Expand Down
2 changes: 1 addition & 1 deletion app/lib/carto/bano/point_retriever.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def driver

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
Expand Down
2 changes: 1 addition & 1 deletion app/lib/carto/sgmap/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def self.call(url, params = {})

RestClient::Resource.new(
url,
verify_ssl: verify_ssl_mode,
verify_ssl: verify_ssl_mode
).post params[:geojson], content_type: 'application/json'

rescue RestClient::InternalServerError
Expand Down
2 changes: 1 addition & 1 deletion app/lib/pipedrive/deal_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def self.add_deal(organisation_id, person_id, title, nb_of_procedures, nb_of_dos
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)
Expand Down
2 changes: 1 addition & 1 deletion app/models/attestation_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def used_tags
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
Expand Down
2 changes: 1 addition & 1 deletion app/models/gestionnaire.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def last_week_overview
else
{
start_date: start_date,
procedure_overviews: active_procedure_overviews,
procedure_overviews: active_procedure_overviews
}
end
end
Expand Down
Loading

0 comments on commit b6e98ac

Please sign in to comment.