fixed codeclimate errors

This commit is contained in:
dinsmol 2021-09-09 21:34:56 +03:00
parent e0c47cdb35
commit 788af6cc5f
15 changed files with 32 additions and 31 deletions

View file

@ -1,5 +1,5 @@
module Epp
class BaseController < ActionController::Base
class BaseController < ApplicationController
class AuthorizationError < StandardError; end
skip_before_action :verify_authenticity_token
check_authorization

View file

@ -35,15 +35,13 @@ class Registrar
@depp_user.errors.add(:base, :invalid_cert)
end
if @depp_user.errors.none?
if @api_user.active?
sign_in_and_redirect(:registrar_user, @api_user)
else
@depp_user.errors.add(:base, :not_active)
show_error and return
end
show_error and return unless @depp_user.errors.none?
if @api_user.active?
sign_in_and_redirect(:registrar_user, @api_user)
else
show_error and return
@depp_user.errors.add(:base, :not_active)
show_error
end
end

View file

@ -45,7 +45,7 @@ class CsyncJob < ApplicationJob
def process_scanner_results
scanner_results
@results.keys.each do |domain|
@results.each_key do |domain|
begin
next unless qualified_for_monitoring?(domain, @results[domain])
@ -132,7 +132,7 @@ class CsyncJob < ApplicationJob
end
def create_input_lines(out_file, state)
@input_store[state].keys.each do |nameserver|
@input_store[state].each_key do |nameserver|
domains = @input_store[state][nameserver].join(' ')
next unless domains.length.positive?

View file

@ -1,7 +1,7 @@
class SendEInvoiceJob < ApplicationJob
discard_on HTTPClient::TimeoutError
def perform(invoice_id, payable = true)
def perform(invoice_id, payable: true)
logger.info "Started to process e-invoice for invoice_id #{invoice_id}"
invoice = Invoice.find_by(id: invoice_id)
return unless need_to_process_invoice?(invoice: invoice, payable: payable)

View file

@ -26,7 +26,7 @@ class VerifyEmailsJob < ApplicationJob
end
def logger
@logger ||= Logger.new(Rails.root.join('log', 'email_verification.log'))
@logger ||= Logger.new(Rails.root.join('log/email_verification.log'))
end
def log_success(verification)

View file

@ -81,11 +81,11 @@ class Certificate < ApplicationRecord
csr_file.rewind
crt_file = Tempfile.new('client_crt')
_out, err, _st = Open3.capture3("openssl ca -config #{ENV['openssl_config_path']} \
-keyfile #{ENV['ca_key_path']} \
-cert #{ENV['ca_cert_path']} \
-extensions usr_cert -notext -md sha256 \
-in #{csr_file.path} -out #{crt_file.path} -key '#{ENV['ca_key_password']}' -batch")
_out, err, _st = Open3.capture3("openssl", "ca", "-config", ENV['openssl_config_path'],
"-keyfile", ENV['ca_key_path'],
"-cert", ENV['ca_cert_path'],
"-extensions", "usr_cert", "-notext", "-md sha256",
"-in", csr_file.path, "-out", crt_file.path, "-key", ENV['ca_key_password'], "-batch")
if err.match?(/Data Base Updated/)
crt_file.rewind

View file

@ -11,7 +11,7 @@ class Contact < ApplicationRecord
include Contact::Archivable
include EmailVerifable
belongs_to :original, class_name: name
belongs_to :original, class_name: 'Contact'
belongs_to :registrar, required: true
has_many :domain_contacts
has_many :domains, through: :domain_contacts

View file

@ -241,7 +241,7 @@ module Depp
ident = ident_xml[:_anonymus].try(:first)
when :update
# detect if any ident has changed, nb! ident and self.ident is not always same
unless ident == self.ident && ident == ident_type && ident_country_code == ident_country_code
unless ident == self.ident && ident == ident_type && ident_country_code == self.ident_country_code
ident = ident_xml[:_anonymus].try(:first)
end
end

View file

@ -343,10 +343,10 @@ class Domain < ApplicationRecord
# find by internationalized domain name
# internet domain name => ascii or puny, but db::domains.name is unicode
def self.find_by_idn(name)
domain = find_by_name name
domain = find_by(name: name)
if domain.blank? && name.include?('-')
unicode = SimpleIDN.to_unicode name # we have no index on domains.name_puny
domain = find_by_name unicode
domain = find_by(name: unicode)
end
domain
end

View file

@ -216,7 +216,8 @@ class Epp::Domain < Domain
return transfers.last if transfers.any?
when 'request'
return pending_transfer if pending_transfer
return query_transfer(frame, current_user)
query_transfer(frame, current_user)
when 'approve'
return approve_transfer(frame, current_user) if pending_transfer
when 'reject'

View file

@ -17,13 +17,15 @@ class Invoice < ApplicationRecord
scope :all_columns, -> { select("invoices.*") }
scope :sort_due_date_column, -> { all_columns.select("CASE WHEN invoices.cancelled_at is not null THEN
(invoices.cancelled_at + interval '100 year') ELSE
invoices.due_date END AS sort_due_date") }
invoices.due_date END AS sort_due_date")
}
scope :sort_by_sort_due_date_asc, -> { sort_due_date_column.order("sort_due_date ASC") }
scope :sort_by_sort_due_date_desc, -> { sort_due_date_column.order("sort_due_date DESC") }
scope :sort_receipt_date_column, -> { all_columns.includes(:account_activity).references(:account_activity).select(%Q{
scope :sort_receipt_date_column, -> { all_columns.includes(:account_activity).references(:account_activity).select(%(
CASE WHEN account_activities.created_at is not null THEN account_activities.created_at
WHEN invoices.cancelled_at is not null THEN invoices.cancelled_at + interval '100 year'
ELSE NULL END AS sort_receipt_date })}
ELSE NULL END AS sort_receipt_date ))
}
scope :sort_by_sort_receipt_date_asc, -> { sort_receipt_date_column.order("sort_receipt_date ASC") }
scope :sort_by_sort_receipt_date_desc, -> { sort_receipt_date_column.order("sort_receipt_date DESC") }

View file

@ -105,7 +105,7 @@ class Registrar < ApplicationRecord
.deliver_later(wait: 1.minute)
end
SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable)
SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable: payable)
invoice
end

View file

@ -37,7 +37,7 @@ class ReservedDomain < ApplicationRecord
end
def fill_empty_passwords
regenerate_password if self.password.blank?
regenerate_password if password.blank?
end
def regenerate_password

View file

@ -82,8 +82,8 @@ module Xsd
end
def schemas_by_name
prefixes.each_with_object({}) do |prefix, hash|
hash[prefix] = xsd_schemas.select { |filename| prefix_check(prefix, filename) }.uniq.sort
prefixes.index_with do |prefix|
xsd_schemas.select { |filename| prefix_check(prefix, filename) }.uniq.sort
end
end

View file

@ -15,7 +15,7 @@ class SendEInvoiceJobTest < ActiveJob::TestCase
assert_nothing_raised do
perform_enqueued_jobs do
SendEInvoiceJob.perform_now(@invoice.id, true)
SendEInvoiceJob.perform_now(@invoice.id, payable: true)
end
end
@invoice.reload