Merge pull request #953 from sgmap/rubocop-perf

Enable all the rubicop perf cops
This commit is contained in:
gregoirenovel 2017-11-21 10:31:43 +01:00 committed by GitHub
commit e8d7322ee3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 36 additions and 36 deletions

View file

@ -444,76 +444,76 @@ Metrics/PerceivedComplexity:
Enabled: false
Performance/Caller:
Enabled: false
Enabled: true
Performance/CaseWhenSplat:
Enabled: false
Enabled: true
Performance/Casecmp:
Enabled: false
Enabled: true
Performance/CompareWithBlock:
Enabled: false
Enabled: true
Performance/Count:
Enabled: false
Enabled: true
Performance/Detect:
Enabled: false
Enabled: true
Performance/DoubleStartEndWith:
Enabled: false
Enabled: true
Performance/EndWith:
Enabled: false
Enabled: true
Performance/FixedSize:
Enabled: false
Enabled: true
Performance/FlatMap:
Enabled: false
Enabled: true
Performance/HashEachMethods:
Enabled: false
Enabled: true
Performance/LstripRstrip:
Enabled: false
Enabled: true
Performance/RangeInclude:
Enabled: false
Enabled: true
Performance/RedundantBlockCall:
Enabled: false
Enabled: true
Performance/RedundantMatch:
Enabled: false
Enabled: true
Performance/RedundantMerge:
Enabled: false
Enabled: true
Performance/RedundantSortBy:
Enabled: false
Enabled: true
Performance/RegexpMatch:
Enabled: false
Enabled: true
Performance/ReverseEach:
Enabled: false
Enabled: true
Performance/Sample:
Enabled: false
Enabled: true
Performance/Size:
Enabled: false
Enabled: true
Performance/StartWith:
Enabled: false
Enabled: true
Performance/StringReplacement:
Enabled: false
Enabled: true
Performance/TimesMap:
Enabled: false
Enabled: true
Rails/ActionFilter:
Enabled: false

View file

@ -63,8 +63,8 @@ class Admin::AttestationTemplatesController < AdminController
.permit(:title, :body, :footer, :signature)
.merge(activated: true)
@activated_attestation_params.merge!(logo: uninterlaced_png(params['attestation_template']['logo']))
@activated_attestation_params.merge!(signature: uninterlaced_png(params['attestation_template']['signature']))
@activated_attestation_params[:logo] = uninterlaced_png(params['attestation_template']['logo'])
@activated_attestation_params[:signature] = uninterlaced_png(params['attestation_template']['signature'])
end
@activated_attestation_params

View file

@ -52,7 +52,7 @@ class StatsController < ApplicationController
.group("DATE_TRUNC('month', #{date_attribute.to_s})")
.count
.to_a
.sort{ |x, y| x[0] <=> y[0] }
.sort_by { |a| a[0] }
.map { |e| [I18n.l(e.first, format: "%B %Y"), e.last] }
end
@ -63,7 +63,7 @@ class StatsController < ApplicationController
.group("DATE_TRUNC('month', #{date_attribute.to_s})")
.count
.to_a
.sort{ |x, y| x[0] <=> y[0] }
.sort_by { |a| a[0] }
.map { |x, y| { x => (sum += y)} }
.reduce({}, :merge)
end

View file

@ -27,7 +27,7 @@ class SIADE::API
end
def self.call(url, params = {})
params.merge!(token: SIADETOKEN)
params[:token] = SIADETOKEN
verify_ssl_mode = OpenSSL::SSL::VERIFY_NONE

View file

@ -1,5 +1,5 @@
class EtablissementCsvSerializer < EtablissementSerializer
def adresse
object.adresse.chomp.gsub("\r\n", ' ').gsub("\r", '')
object.adresse.chomp.gsub("\r\n", ' ').delete("\r")
end
end

View file

@ -43,8 +43,8 @@ class DossierService
unless @france_connect_information.nil?
mandataires_list.each do |mandataire|
return true if mandataire[:nom].upcase == @france_connect_information.family_name.upcase &&
mandataire[:prenom].upcase == @france_connect_information.given_name.upcase &&
return true if mandataire[:nom].casecmp(@france_connect_information.family_name).zero? &&
mandataire[:prenom].casecmp(@france_connect_information.given_name).zero? &&
mandataire[:date_naissance_timestamp] == @france_connect_information.birthdate.to_time.to_i
end
end

View file

@ -132,7 +132,7 @@ class DossiersListGestionnaireService
def where_filter
filter_preference_list.inject('') do |acc, preference|
unless preference.filter.blank?
filter = preference.filter.gsub('*', '%').gsub("'", "''")
filter = preference.filter.tr('*', '%').gsub("'", "''")
filter = "%" + filter + "%" unless filter.include? '%'
value = preference.table_with_s_attr

View file

@ -4,7 +4,7 @@ class ModuleApiCartoService
qp_list = generate_qp JSON.parse(json_latlngs)
qp_list.each_value do |qp|
qp.merge!({dossier_id: dossier.id})
qp[:dossier_id] = dossier.id
qp[:geometry] = qp[:geometry].to_json
QuartierPrioritaire.create(qp)
end
@ -16,7 +16,7 @@ class ModuleApiCartoService
cadastre_list = generate_cadastre JSON.parse(json_latlngs)
cadastre_list.each do |cadastre|
cadastre.merge!({dossier_id: dossier.id})
cadastre[:dossier_id] = dossier.id
cadastre[:geometry] = cadastre[:geometry].to_json
Cadastre.create(cadastre)
end

View file

@ -12,7 +12,7 @@ namespace :dev do
task :generate_token_file do
puts 'creating token.rb file'
res = `rake secret`.gsub("\n", '')
res = `rake secret`.delete("\n")
file = File.new('config/initializers/token.rb', 'w+')
comment = <<EOF
EOF