Merge pull request #3182 from betagouv/rubocop

Rubocop
This commit is contained in:
gregoirenovel 2018-12-19 14:39:07 +01:00 committed by GitHub
commit d2b730e2e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 43 deletions

View file

@ -806,37 +806,39 @@ Style/Alias:
Enabled: false
Style/AndOr:
Enabled: false
Enabled: true
Style/ArrayJoin:
Enabled: false
Enabled: true
Style/AsciiComments:
Enabled: false
Style/Attr:
Enabled: false
Enabled: true
Style/AutoResourceCleanup:
Enabled: false
Enabled: true
Style/BarePercentLiterals:
Enabled: false
Style/BeginBlock:
Enabled: false
Enabled: true
Style/BlockComments:
Enabled: false
Enabled: true
Style/BlockDelimiters:
Enabled: false
Enabled: true
Exclude:
- "spec/**/*"
Style/BracesAroundHashParameters:
Enabled: false
Style/CaseEquality:
Enabled: false
Enabled: true
Style/CharacterLiteral:
Enabled: false
@ -845,10 +847,10 @@ Style/ClassAndModuleChildren:
Enabled: false
Style/ClassCheck:
Enabled: false
Enabled: true
Style/ClassMethods:
Enabled: false
Enabled: true
Style/ClassVars:
Enabled: false
@ -857,7 +859,7 @@ Style/CollectionMethods:
Enabled: false
Style/ColonMethodCall:
Enabled: false
Enabled: true
Style/ColonMethodDefinition:
Enabled: true
@ -881,7 +883,7 @@ Style/DateTime:
Enabled: false
Style/DefWithParentheses:
Enabled: false
Enabled: true
Style/Dir:
Enabled: true
@ -896,7 +898,7 @@ Style/DoubleNegation:
Enabled: false
Style/EachForSimpleLoop:
Enabled: false
Enabled: true
Style/EachWithObject:
Enabled: false
@ -914,43 +916,44 @@ Style/EmptyLambdaParameter:
Enabled: true
Style/EmptyLiteral:
Enabled: false
Enabled: true
Style/EmptyMethod:
Enabled: false
Style/Encoding:
Enabled: false
Enabled: true
Style/EndBlock:
Enabled: false
Enabled: true
Style/EvalWithLocation:
Enabled: false
Style/EvenOdd:
Enabled: false
Enabled: true
Style/ExpandPathArguments:
Enabled: true
Style/FlipFlop:
Enabled: false
Enabled: true
Style/For:
Enabled: false
Enabled: true
Style/FormatString:
Enabled: false
Enabled: true
Style/FormatStringToken:
Enabled: false
Enabled: true
EnforcedStyle: template
Style/FrozenStringLiteralComment:
Enabled: false
Style/GlobalVars:
Enabled: false
Enabled: true
Style/GuardClause:
Enabled: false

View file

@ -517,7 +517,7 @@ GEM
rspec-support (3.8.0)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.60.0)
rubocop (0.61.1)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)

View file

@ -93,7 +93,7 @@ class StatsController < ApplicationController
else
evolution = 0
end
formatted_evolution = sprintf("%+d", evolution)
formatted_evolution = format("%+d", evolution)
{
total: total.to_s,
@ -111,7 +111,7 @@ class StatsController < ApplicationController
else
evolution = 0
end
formatted_evolution = sprintf("%+d", evolution)
formatted_evolution = format("%+d", evolution)
{
total: total.to_s,

View file

@ -41,11 +41,11 @@ class FileSizeValidator < ActiveModel::EachValidator
end
def validate_each(record, attribute, value)
if !value.kind_of?(CarrierWave::Uploader::Base)
if !value.is_a?(CarrierWave::Uploader::Base)
raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected")
end
if value.kind_of?(String)
if value.is_a?(String)
value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value)
end

View file

@ -167,13 +167,13 @@ module TagsSubstitutionConcern
end
def types_de_champ_tags(types_de_champ, available_for_states)
types_de_champ.map { |tdc|
types_de_champ.map do |tdc|
{
libelle: tdc.libelle,
description: tdc.description,
available_for_states: available_for_states
}
}
end
end
def replace_tags(text, dossier)

View file

@ -5,5 +5,5 @@ class TypeDePieceJustificative < ApplicationRecord
validates :libelle, presence: true, allow_blank: false, allow_nil: false
validates :lien_demarche, format: { with: URI::regexp }, allow_blank: true, allow_nil: true
validates :lien_demarche, format: { with: URI.regexp }, allow_blank: true, allow_nil: true
end

View file

@ -22,8 +22,8 @@ namespace :cloudstorage do
Rake::Task['cloudstorage:init'].invoke
error_count = 0
[Cerfa, PieceJustificative, Procedure].each { |c|
c.all.each { |entry|
[Cerfa, PieceJustificative, Procedure].each do |c|
c.all.each do |entry|
content = (c == Procedure) ? entry.logo : entry.content
if !(content.current_path.nil? || File.exist?(File.dirname(content.current_path) + '/uploaded'))
secure_token = SecureRandom.uuid
@ -56,8 +56,8 @@ namespace :cloudstorage do
puts "Skipping #{content.current_path}"
end
end
}
}
end
end
puts "There were #{error_count} errors while uploading files. See upload_errors.report file for details."
puts 'Enf of migration'
@ -67,8 +67,8 @@ namespace :cloudstorage do
task :revert do
Rake::Task['cloudstorage:init'].invoke
[Cerfa, PieceJustificative, Procedure].each { |c|
c.all.each { |entry|
[Cerfa, PieceJustificative, Procedure].each do |c|
c.all.each do |entry|
content = (c == Procedure) ? entry.logo : entry.content
if content.current_path.present?
if File.exist?(File.dirname(content.current_path) + '/uploaded')
@ -86,26 +86,26 @@ namespace :cloudstorage do
FileUtils.rm(File.dirname(content.current_path) + '/secure_token_cloudstorage')
end
end
}
}
end
end
end
desc 'Clear old documents in tenant'
task :clear do
Rake::Task['cloudstorage:init'].invoke
@cont.objects.each { |object|
@cont.objects.each do |object|
puts "Removing #{object}"
@cont.delete_object(object)
}
end
end
task :clear_old_objects do
Rake::Task['cloudstorage:init'].invoke
@cont.objects_detail.each { |object, details|
@cont.objects_detail.each do |object, details|
last_modified = Time.zone.parse(details[:last_modified])
@cont.delete_object(object) if last_modified.utc <= (Time.zone.now - 2.years).utc
}
end
end
end

View file

@ -52,7 +52,7 @@ class ProgressReport
def print_progress
elapsed = Time.zone.now - @start
percent = sprintf('%5.1f%%', @per_10_000 / 100.0)
percent = format('%5.1f%%', @per_10_000 / 100.0)
total = @total.to_s
count = @count.to_s.rjust(total.length)
rake_print("\r#{percent} (#{count}/#{total}) [#{format_duration(elapsed)}/#{format_duration(elapsed * 10_000.0 / @per_10_000)}]")