use #fail instead of #raise to signal exceptions, as suggested by RuboCop
This commit is contained in:
@ -95,7 +95,7 @@ module Lti
|
||||
private :return_to_consumer
|
||||
|
||||
def send_score(score)
|
||||
raise Error.new("Score #{score} must be between 0 and #{MAXIMUM_SCORE}!") unless (0..MAXIMUM_SCORE).include?(score)
|
||||
fail(Error, "Score #{score} must be between 0 and #{MAXIMUM_SCORE}!") unless (0..MAXIMUM_SCORE).include?(score)
|
||||
provider = build_tool_provider(consumer: Consumer.find_by(id: session[:consumer_id]), parameters: session[:lti_parameters])
|
||||
if provider.nil?
|
||||
{status: 'error'}
|
||||
|
@ -21,7 +21,7 @@ class ApplicationPolicy
|
||||
private :no_one
|
||||
|
||||
def require_user!
|
||||
raise Pundit::NotAuthorizedError unless @user
|
||||
fail Pundit::NotAuthorizedError unless @user
|
||||
end
|
||||
private :require_user!
|
||||
|
||||
@ -33,7 +33,7 @@ class ApplicationPolicy
|
||||
end
|
||||
|
||||
def require_user!
|
||||
raise Pundit::NotAuthorizedError unless @user
|
||||
fail Pundit::NotAuthorizedError unless @user
|
||||
end
|
||||
private :require_user!
|
||||
end
|
||||
|
@ -17,7 +17,7 @@ class Assessor
|
||||
if options[:execution_environment].testing_framework?
|
||||
@testing_framework_adapter = Kernel.const_get(options[:execution_environment].testing_framework).new
|
||||
else
|
||||
raise Error.new('No testing framework adapter set!')
|
||||
fail(Error, 'No testing framework adapter set!')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -10,7 +10,7 @@ module CodeOcean
|
||||
content = options[:erb] ? YAML.load(ERB.new(::File.new(path, 'r').read).result) : YAML.load_file(path)
|
||||
content[Rails.env].with_indifferent_access
|
||||
else
|
||||
raise Error.new("Configuration file not found: #{path}")
|
||||
fail(Error, "Configuration file not found: #{path}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -10,7 +10,7 @@ class DockerClient
|
||||
def self.check_availability!
|
||||
Timeout::timeout(config[:connection_timeout]) { Docker.version }
|
||||
rescue Excon::Errors::SocketError, Timeout::Error
|
||||
raise Error.new("The Docker host at #{Docker.url} is not reachable!")
|
||||
raise(Error, "The Docker host at #{Docker.url} is not reachable!")
|
||||
end
|
||||
|
||||
def command_substitutions(filename)
|
||||
@ -96,12 +96,12 @@ class DockerClient
|
||||
@execution_environment = options[:execution_environment]
|
||||
@user = options[:user]
|
||||
@image = self.class.find_image_by_tag(@execution_environment.docker_image)
|
||||
raise Error.new("Cannot find image #{@execution_environment.docker_image}!") unless @image
|
||||
fail(Error, "Cannot find image #{@execution_environment.docker_image}!") unless @image
|
||||
end
|
||||
|
||||
def self.initialize_environment
|
||||
unless config[:connection_timeout] && config[:workspace_root]
|
||||
raise Error.new('Docker configuration missing!')
|
||||
fail(Error, 'Docker configuration missing!')
|
||||
end
|
||||
Docker.url = config[:host] if config[:host]
|
||||
check_availability!
|
||||
|
@ -15,7 +15,7 @@ class TestingFrameworkAdapter
|
||||
end
|
||||
|
||||
def parse_output(output)
|
||||
raise NotImplementedError.new("#{self.class} should implement #parse_output!")
|
||||
fail(NotImplementedError, "#{self.class} should implement #parse_output!")
|
||||
end
|
||||
private :parse_output
|
||||
|
||||
|
Reference in New Issue
Block a user