fixed codeclimate errors

This commit is contained in:
dinsmol 2021-09-09 13:06:51 +03:00
parent f4e0084895
commit e7e3278267
44 changed files with 118 additions and 150 deletions

View file

@ -25,13 +25,12 @@ module Admin
@account_activities = @q.result.page(params[:page]).per(params[:results_per_page])
@count = @q.result.count
if params[:page] && params[:page].to_i > 1
@sum = @q.result.limit(@account_activities.offset_value).sum(:sum) +
@b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})")
.sum(:sum)
else
@sum = @b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})").sum(:sum)
end
@sum = if params[:page] && params[:page].to_i > 1
@q.result.limit(@account_activities.offset_value).sum(:sum) +
@b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})").sum(:sum)
else
@b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})").sum(:sum)
end
respond_to do |format|
format.html

View file

@ -3,6 +3,7 @@ module Admin
load_and_authorize_resource class: ApiLog::EppLog
before_action :set_default_dates, only: [:index]
# rubocop:disable Metrics/MethodLength
def index
@q = ApiLog::EppLog.ransack(params[:q])
@q.sorts = 'id desc' if @q.sorts.empty?
@ -20,6 +21,7 @@ module Admin
render_by_format('admin/epp_logs/index', 'epp_logs')
end
# rubocop:enable Metrics/MethodLength
def show
@epp_log = ApiLog::EppLog.find(params[:id])

View file

@ -3,6 +3,7 @@ module Admin
load_and_authorize_resource class: ApiLog::ReppLog
before_action :set_default_dates, only: [:index]
# rubocop:disable Metrics/MethodLength
def index
@q = ApiLog::ReppLog.search(params[:q])
@q.sorts = 'id desc' if @q.sorts.empty?
@ -22,6 +23,7 @@ module Admin
render_by_format('admin/repp_logs/index', 'repp_logs')
end
# rubocop:enable Metrics/MethodLength
def show
@repp_log = ApiLog::ReppLog.find(params[:id])

View file

@ -15,9 +15,7 @@ module Api
current_registrant: serialized_registrant(@domain.registrant),
}
unless delete_action?
res[:new_registrant] = serialized_registrant(@domain.pending_registrant)
end
res[:new_registrant] = serialized_registrant(@domain.pending_registrant) unless delete_action?
render json: res, status: :ok
end

View file

@ -23,4 +23,4 @@ module Deliverable
def find_invoice
@invoice = Invoice.find(params[:invoice_id])
end
end
end

View file

@ -312,7 +312,12 @@ module Epp
request: trimmed_request,
request_command: request_command,
request_successful: epp_errors.empty?,
request_object: resource ? "#{params[:epp_object_type]}: #{resource.class} - #{resource.id} - #{resource.name}" : params[:epp_object_type],
request_object: if resource
"#{params[:epp_object_type]}: #{resource.class} - "\
"#{resource.id} - #{resource.name}"
else
params[:epp_object_type]
end,
response: @response,
api_user_name: @api_user.try(:username) || current_user.try(:username) || 'api-public',
api_user_registrar: @api_user.try(:registrar).try(:to_s) ||

View file

@ -14,16 +14,13 @@ module Epp
webclient_request = ENV['webclient_ips'].split(',').map(&:strip).include?(request.ip)
if webclient_request && !Rails.env.test? && !Rails.env.development?
client_md5 = Certificate.parse_md_from_string(request.env['HTTP_SSL_CLIENT_CERT'])
if ENV['cert_path'].blank?
raise 'webclient cert (cert_path) missing, registrar (r)epp disabled'
end
raise 'webclient cert (cert_path) missing, registrar (r)epp disabled' if ENV['cert_path'].blank?
server_md5 = Certificate.parse_md_from_string(File.read(ENV['cert_path']))
if client_md5 != server_md5
msg = 'Authentication error; server closing connection (certificate is not valid)'
epp_errors.add(:epp_errors,
msg: msg,
code: '2501')
msg: msg, code: '2501')
success = false
end
@ -33,10 +30,10 @@ module Epp
!@api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], request.env['HTTP_SSL_CLIENT_S_DN_CN'])
msg = 'Authentication error; server closing connection (certificate is not valid)'
epp_errors.add(:epp_errors,
msg: msg,code: '2501')
msg: msg, code: '2501')
success = false
end
end
if success && !@api_user
msg = 'Authentication error; server closing connection (API user not found)'
@ -109,9 +106,8 @@ module Epp
def ip_white?
webclient_request = ENV['webclient_ips'].split(',').map(&:strip).include?(request.ip)
return true if webclient_request
if @api_user && !@api_user.registrar.api_ip_white?(request.ip)
return false
end
return false if @api_user && !@api_user.registrar.api_ip_white?(request.ip)
true
end

View file

@ -21,9 +21,7 @@ class Registrar
current_domain_scope
end
if params[:contacts_ident_eq]
domains = domains.where(contacts: { ident: params[:contacts_ident_eq] })
end
domains = domains.where(contacts: { ident: params[:contacts_ident_eq] }) if params[:contacts_ident_eq]
normalize_search_parameters do
@q = domains.search(search_params.except(:contacts_ident_eq))

View file

@ -35,9 +35,7 @@ class Registrar
notices = ["#{t('.replaced')}. #{t('.affected_domains')}: " \
"#{res[:data][:affected_domains].join(', ')}"]
if res[:data][:skipped_domains]
notices << "#{t('.skipped_domains')}: #{res[:data][:skipped_domains].join(', ')}"
end
notices << "#{t('.skipped_domains')}: #{res[:data][:skipped_domains].join(', ')}" if res[:data][:skipped_domains]
notices.join(', ')
end

View file

@ -22,7 +22,7 @@ class Registrar
def load_xml
cl_trid = "#{depp_current_user.tag}-#{Time.zone.now.to_i}"
xml_dir_path = "#{Rails.root}/app/views/registrar/xml_consoles/epp_requests"
xml_dir_path = Rails.root.join('app', 'views', 'registrar', 'xml_consoles', 'epp_requests').to_s
xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml")
xml = prepare_payload(xml, cl_trid)
@ -54,7 +54,7 @@ class Registrar
end
def insert_prefix_and_version(xml, pref, version)
xml.gsub!("\"#{pref.to_s}\"",
xml.gsub!("\"#{pref}\"",
"\"#{Xsd::Schema.filename(for_prefix: pref.to_s, for_version: version)}\"")
xml
end