Skip to content

Commit

Permalink
Update rubocop to 0.52
Browse files Browse the repository at this point in the history
  • Loading branch information
hellcp committed Dec 10, 2022
1 parent 3149a0d commit 7884f5d
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 66 deletions.
53 changes: 30 additions & 23 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-06-20 18:29:38 +0530 using RuboCop version 0.49.1.
# on 2022-12-10 14:51:16 +0000 using RuboCop version 0.51.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -28,16 +28,23 @@ Lint/ParenthesesAsGroupedExpression:
- 'config.ru'
- 'spec/models/travel_sponsorship_spec.rb'

# Offense count: 5
# Offense count: 13
Style/RescueStandardError:
Exclude:
- 'app/models/event.rb'
- 'spec/models/reimbursement_spec.rb'
- 'spec/models/shipment_spec.rb'
- 'spec/models/travel_sponsorship_spec.rb'

# Offense count: 4
Lint/UselessAssignment:
Exclude:
- 'app/helpers/application_helper.rb'
- 'app/helpers/events_helper.rb'
- 'app/helpers/reimbursements_helper.rb'
- 'app/models/travel_expense_report.rb'
- 'db/seeds.rb'

# Offense count: 51
# Offense count: 48
Lint/Void:
Exclude:
- 'spec/features/comments_spec.rb'
Expand All @@ -57,27 +64,27 @@ Lint/Void:

# Offense count: 44
Metrics/AbcSize:
Max: 168
Max: 73

# Offense count: 74
# Offense count: 68
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 278
Max: 274

# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 137

# Offense count: 8
# Offense count: 7
Metrics/CyclomaticComplexity:
Max: 31
Max: 28

# Offense count: 396
# Offense count: 419
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 188
Metrics/LineLength:
Max: 181

# Offense count: 45
# Configuration parameters: CountComments.
Expand All @@ -89,25 +96,25 @@ Metrics/MethodLength:
Metrics/ModuleLength:
Max: 152

# Offense count: 6
# Offense count: 7
Metrics/PerceivedComplexity:
Max: 35
Max: 31

# Offense count: 3
# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'Gemfile'

# Offense count: 4
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'lib/fix_state_machine_yard.rb'
- 'test/test_helper.rb'

# Offense count: 69
# Offense count: 77
Style/Documentation:
Enabled: false

# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'Gemfile'
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ group :development do
gem 'state_machines-yard'
gem 'yard-activerecord'
# for static code analisys
gem 'rubocop', '~> 0.50.0', require: false
gem 'rubocop', '~> 0.52.0', require: false
# gem 'rubocop-rails', require: false
# gem 'rubocop-rspec', require: false
end
Expand Down
11 changes: 5 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,7 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
rake
rainbow (3.1.1)
rake (13.0.6)
ransack (2.3.0)
actionpack (>= 5.0)
Expand Down Expand Up @@ -323,11 +322,11 @@ GEM
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.12.0)
rubocop (0.50.0)
rubocop (0.52.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
parser (>= 2.4.0.2, < 3.0)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 3.0)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-graphviz (1.2.5)
Expand Down Expand Up @@ -461,7 +460,7 @@ DEPENDENCIES
redcarpet
responders
rspec-rails
rubocop (~> 0.50.0)
rubocop (~> 0.52.0)
ruby-graphviz
sass-rails
sdoc
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ def set_breadcrumbs
elsif is_a? InheritedResources::Base
@breadcrumbs = [{ label: resource_class.model_name.human(count: 2),
url: collection_path }]
if %w[show edit update].include? action_name
@breadcrumbs << { label: resource, url: resource_path }
end
@breadcrumbs << { label: resource, url: resource_path } if %w[show edit update].include? action_name
else
@breadcrumbs = [{ label: '' }]
end
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ def participants
def collection
@q ||= end_of_association_chain.ransack(params[:q])
# Default, only current and future events are displayed
if params[:q].nil? || params[:q][:end_date_gteq].nil?
@q.end_date_gteq = Date.today
end
@q.end_date_gteq = Date.today if params[:q].nil? || params[:q][:end_date_gteq].nil?
@q.sorts = 'start_date asc' if @q.sorts.empty?
@events ||= @q.result(distinct: true).page(params[:page]).per(20)
end
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/reimbursement_acceptances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def create
format.json { render json: { file: @reimbursement.file.to_s }, status: :created }
else
flash[:error] = I18n.t(:reimbursement_acceptance_failure)
unless @reimbursement.errors.empty?
flash[:error] << "\n<br/>" + @reimbursement.errors.full_messages.map { |i| i.humanize + '.' }.join(' ')
end
flash[:error] << "\n<br/>" + @reimbursement.errors.full_messages.map { |i| i.humanize + '.' }.join(' ') unless @reimbursement.errors.empty?
format.json { render json: @reimbursement.errors, status: :unprocessable_entity }
end
location = request_reimbursement_path(@request)
Expand Down
20 changes: 5 additions & 15 deletions app/helpers/reimbursements_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,8 @@ def reimbursement_acceptance_file(reimbursement)
end

links = []
if can_read_pdf_for?(resource) && resource.editable?
links << link_to(t(:pdf_format), request_reimbursement_path(reimbursement.request, format: :pdf))
end
if can? :submit, reimbursement
links << link_to(t(:send_reimbursement_acceptance), new_request_reimbursement_acceptance_path(resource.request), remote: true)
end
links << link_to(t(:pdf_format), request_reimbursement_path(reimbursement.request, format: :pdf)) if can_read_pdf_for?(resource) && resource.editable?
links << link_to(t(:send_reimbursement_acceptance), new_request_reimbursement_acceptance_path(resource.request), remote: true) if can? :submit, reimbursement

info = if can? :submit, reimbursement
t(:reimbursement_acceptance_intro).html_safe
Expand All @@ -61,9 +57,7 @@ def reimbursement_acceptance_file(reimbursement)
t(:reimbursement_acceptance_update).html_safe
end
end
unless links.empty?
info << content_tag(:p, links.join(' | ').html_safe, class: 'text-right')
end
info << content_tag(:p, links.join(' | ').html_safe, class: 'text-right') unless links.empty?
out << content_tag(:div, info, class: 'alert alert-info') unless info.empty?
out
end
Expand All @@ -90,17 +84,13 @@ def reimbursement_payments(reimbursement)
p << content_tag(:td, payment.subject)
p << content_tag(:td, number_to_currency(payment.amount, unit: payment.currency), class: 'text-right')
links = []
if can? :update, payment
links << link_to(t('helpers.links.edit'), edit_request_reimbursement_payment_path(req, payment))
end
links << link_to(t('helpers.links.edit'), edit_request_reimbursement_payment_path(req, payment)) if can? :update, payment
if can? :destroy, payment
links << link_to(t('helpers.links.destroy'),
request_reimbursement_payment_path(req, payment),
data: { confirm: t('helpers.links.confirm') }, method: :delete)
end
if can?(:update, payment) && !payment.file.blank?
links << link_to(Payment.human_attribute_name(:file), file_request_reimbursement_payment_path(req, payment))
end
links << link_to(Payment.human_attribute_name(:file), file_request_reimbursement_payment_path(req, payment)) if can?(:update, payment) && !payment.file.blank?
p << if links.empty?
content_tag(:td, '')
else
Expand Down
4 changes: 1 addition & 3 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def initialize(user)

# Comments
conds = { machine_type: machine.base_class.to_s }
if machine.superclass != ApplicationRecord
conds[:machine] = { type: machine.to_s }
end
conds[:machine] = { type: machine.to_s } if machine.superclass != ApplicationRecord

if machine.allow_private_comments?(role)
can %i[read create], Comment, conds
Expand Down
4 changes: 1 addition & 3 deletions app/models/travel_sponsorship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ def self.notify_missing_reimbursement(after_end_threshold, before_deadline_thres
)
candidate_events.includes(:requests).each do |e|
e.requests.each do |r|
if r.lacks_reimbursement?
ReimbursableRequestMailer.notify_to([r.user], :missing_reimbursement, r)
end
ReimbursableRequestMailer.notify_to([r.user], :missing_reimbursement, r) if r.lacks_reimbursement?
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ class User < ApplicationRecord
extend ActiveHash::Associations::ActiveRecordExtensions

devise_modules = []
if Rails.configuration.site['authentication']['ichain']['enabled']
devise_modules += %i[ichain_authenticatable ichain_registerable]
end
devise_modules += %i[ichain_authenticatable ichain_registerable] if Rails.configuration.site['authentication']['ichain']['enabled']
if Rails.configuration.site['authentication']['database']['enabled']
devise_modules += %i[database_authenticatable registerable recoverable
rememberable trackable validatable]
Expand Down
4 changes: 1 addition & 3 deletions script/clockwork.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ module Clockwork

end_threshold = Rails.configuration.site['reimbursement_reminder']['days_after_event']
deadline_threshold = Rails.configuration.site['reimbursement_reminder']['days_before_deadline']
unless end_threshold.blank? || deadline_threshold.blank?
TravelSponsorship.notify_missing_reimbursement end_threshold.to_i.days, deadline_threshold.to_i.days
end
TravelSponsorship.notify_missing_reimbursement end_threshold.to_i.days, deadline_threshold.to_i.days unless end_threshold.blank? || deadline_threshold.blank?
end
end

0 comments on commit 7884f5d

Please sign in to comment.