rubocop update, now it's green

This commit is contained in:
Priit Tamboom 2014-10-10 16:11:28 +03:00
parent 2d6ed7fa45
commit 8d189023c7
29 changed files with 190 additions and 54 deletions

View file

@ -53,6 +53,7 @@ class Admin::UsersController < AdminController
end
def user_params
params.require(:user).permit(:username, :password, :identity_code, :email, :registrar_id, :admin, :registrar_typeahead, :country_id)
params.require(:user).permit(:username, :password, :identity_code, :email, :registrar_id,
:admin, :registrar_typeahead, :country_id)
end
end

View file

@ -12,10 +12,12 @@ class Client::ContactsController < ClientController
end
def show
# rubocop: disable Style/GuardClause
if @contact.registrar != current_registrar
flash[:alert] = I18n.t('shared.authentication_error')
redirect_to client_contacts_path
end
# rubocop: enable Style/GuardClause
end
def create

View file

@ -12,6 +12,8 @@ class Client::DomainTransfersController < ClientController
@domain_transfer = DomainTransfer.new
end
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity
def create
@domain_transfer = @domain.pending_transfer
@ -36,6 +38,8 @@ class Client::DomainTransfersController < ClientController
redirect_to [:client, @domain_transfer]
end
end
# rubocop: enable Metrics/PerceivedComplexity
# rubocop: enable Metrics/CyclomaticComplexity
def approve
if can? :approve_as_client, @domain_transfer
@ -63,6 +67,8 @@ class Client::DomainTransfersController < ClientController
}
end
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity
def set_domain
@domain_transfer = DomainTransfer.new
@domain = Domain.find_by(name: params[:domain_name])
@ -81,4 +87,6 @@ class Client::DomainTransfersController < ClientController
render 'new'
end
end
# rubocop: enbale Metrics/PerceivedComplexity
# rubocop: enable Metrics/CyclomaticComplexity
end

View file

@ -14,7 +14,9 @@ module Epp::Common
end
def proxy
@svTRID = "ccReg-#{'%010d' % rand(10**10)}"
# rubocop: disable Style/VariableName
@svTRID = "ccReg-#{format('%010d', rand(10**10))}"
# rubocop: enable Style/VariableName
send(params[:command])
end
@ -46,7 +48,10 @@ module Epp::Common
end
# for debugging
@errors << { code: '1', msg: 'handle_errors was executed when there were actually no errors' } if @errors.blank?
@errors << {
code: '1',
msg: 'handle_errors was executed when there were actually no errors'
} if @errors.blank?
@errors.uniq!
@ -60,7 +65,10 @@ module Epp::Common
def xml_attrs_present?(ph, attributes)
attributes.each do |x|
epp_errors << { code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: x.last) } unless has_attribute(ph, x)
epp_errors << {
code: '2003',
msg: I18n.t('errors.messages.required_parameter_missing', key: x.last)
} unless has_attribute(ph, x)
end
epp_errors.empty?
end
@ -68,24 +76,27 @@ module Epp::Common
def xml_attrs_array_present?(array_ph, attributes)
[array_ph].flatten.each do |ph|
attributes.each do |x|
unless has_attribute(ph, x)
epp_errors << { code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: x.last) }
end
next if has_attribute(ph, x)
epp_errors << {
code: '2003',
msg: I18n.t('errors.messages.required_parameter_missing', key: x.last)
}
end
end
epp_errors.empty?
end
# rubocop: disable Style/PredicateName
def has_attribute(ph, path)
path.reduce(ph) do |location, key|
location.respond_to?(:keys) ? location[key] : nil
end
end
# rubocop: enable Style/PredicateName
def validate_request
validation_method = "validate_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}_#{params[:command]}_request"
if respond_to?(validation_method, true)
handle_errors and return unless send(validation_method)
end
return unless respond_to?(validation_method, true)
handle_errors and return unless send(validation_method)
end
end