Skip to content

Commit

Permalink
[ci] Enable Style/RaiseArgs rubocop: raise Foo.new -> raise Foo
Browse files Browse the repository at this point in the history
  • Loading branch information
bgeuken committed Apr 19, 2017
1 parent 377a069 commit 78789a9
Show file tree
Hide file tree
Showing 44 changed files with 244 additions and 246 deletions.
5 changes: 5 additions & 0 deletions .rubocop.yml
Expand Up @@ -120,6 +120,11 @@ Style/RedundantSelf:
Style/SignalException:
Enabled: true

# Enforces passing the exception class and exception message instead
# of constructing a new exception instance when raising errors
Style/RaiseArgs:
Enabled: true

# Checks for uses of rescue in its modifier form
Style/RescueModifier:
Enabled: true
Expand Down
7 changes: 0 additions & 7 deletions .rubocop_todo.yml
Expand Up @@ -766,13 +766,6 @@ Style/Proc:
- 'src/api/app/models/owner.rb'
- 'src/api/app/models/user.rb'

# Offense count: 248
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: compact, exploded
Style/RaiseArgs:
Enabled: false

# Offense count: 11
# Cop supports --auto-correct.
Style/RedundantBegin:
Expand Down
12 changes: 6 additions & 6 deletions src/api/app/controllers/attribute_controller.rb
Expand Up @@ -37,7 +37,7 @@ def index
# /attribute/:namespace/_meta
def namespace_definition
if params[:namespace].nil?
raise MissingParameterError.new "parameter 'namespace' is missing"
raise MissingParameterError, "parameter 'namespace' is missing"
end
namespace = params[:namespace]

Expand Down Expand Up @@ -92,10 +92,10 @@ def namespace_definition
# /attribute/:namespace/:name/_meta
def attribute_definition
if params[:namespace].nil?
raise MissingParameterError.new "parameter 'namespace' is missing"
raise MissingParameterError, "parameter 'namespace' is missing"
end
if params[:name].nil?
raise MissingParameterError.new "parameter 'name' is missing"
raise MissingParameterError, "parameter 'name' is missing"
end
namespace = params[:namespace]
name = params[:name]
Expand Down Expand Up @@ -250,7 +250,7 @@ def cmd_attribute
attrib.container = @attribute_container

unless attrib.valid?
raise APIException.new({ message: attrib.errors.full_messages.join('\n'), status: 400 })
raise APIException, { message: attrib.errors.full_messages.join('\n'), status: 400 }
end

authorize attrib, :create?
Expand Down Expand Up @@ -282,7 +282,7 @@ def find_attribute_container
else
# project
if Project.is_remote_project?(params[:project])
raise RemoteProject.new
raise RemoteProject
end
@attribute_container = Project.get_by_name(params[:project])
end
Expand All @@ -294,7 +294,7 @@ def find_attribute_container
aname = params[:attribute]
name_parts = aname.split(/:/)
if name_parts.length != 2
raise InvalidAttribute.new "attribute '#{aname}' must be in the $NAMESPACE:$NAME style"
raise InvalidAttribute, "attribute '#{aname}' must be in the $NAMESPACE:$NAME style"
end
# existing ?
AttribType.find_by_name!(params[:attribute])
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/build_controller.rb
Expand Up @@ -39,7 +39,7 @@ def project_index

# check for cmd parameter
if params[:cmd].nil?
raise MissingParameterError.new "Missing parameter 'cmd'"
raise MissingParameterError, "Missing parameter 'cmd'"
end

unless %w(wipe restartbuild killbuild abortbuild rebuild unpublish).include? params[:cmd]
Expand Down Expand Up @@ -170,7 +170,7 @@ def result_lastsuccess

pkg = Package.get_by_project_and_name(params[:project], params[:package],
{use_source: false, follow_project_links: true})
raise RemoteProjectError.new 'The package lifes in a remote project, this is not supported atm' unless pkg
raise RemoteProjectError, 'The package lifes in a remote project, this is not supported atm' unless pkg

tprj = Project.get_by_name params[:pathproject]
bs = PackageBuildStatus.new(pkg).result(target_project: tprj, srcmd5: params[:srcmd5])
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/group_controller.rb
Expand Up @@ -77,7 +77,7 @@ def command
elsif params[:cmd] == "set_email"
group.set_email params[:email]
else
raise UnknownCommandError.new "cmd must be set to add_user or remove_user"
raise UnknownCommandError, "cmd must be set to add_user or remove_user"
end

render_ok
Expand Down
12 changes: 6 additions & 6 deletions src/api/app/controllers/person_controller.rb
Expand Up @@ -28,7 +28,7 @@ def command
internal_register
return
end
raise UnknownCommandError.new "Allowed commands are 'change_password'"
raise UnknownCommandError, "Allowed commands are 'change_password'"
end

def get_userinfo
Expand Down Expand Up @@ -80,7 +80,7 @@ def post_userinfo
render_ok
return
end
raise UnknownCommandError.new "Allowed commands are 'change_password', 'lock' or 'delete', got #{params[:cmd]}"
raise UnknownCommandError, "Allowed commands are 'change_password', 'lock' or 'delete', got #{params[:cmd]}"
end

def put_userinfo
Expand Down Expand Up @@ -131,7 +131,7 @@ class NoPermissionToGroupList < APIException
end

def grouplist
raise NoPermissionToGroupList.new unless User.current
raise NoPermissionToGroupList unless User.current

user = User.find_by_login! params[:login]
@list = User.lookup_strategy.groups(user)
Expand Down Expand Up @@ -162,7 +162,7 @@ def internal_register

if authenticator.proxy_mode?
if request.env['HTTP_X_USERNAME'].blank?
raise ErrRegisterSave.new "Missing iChain header"
raise ErrRegisterSave, "Missing iChain header"
end
login = request.env['HTTP_X_USERNAME']
email = request.env['HTTP_X_EMAIL'] unless request.env['HTTP_X_EMAIL'].blank?
Expand Down Expand Up @@ -274,7 +274,7 @@ def command_token
user = User.get_by_login(params[:login])

unless params[:cmd] == "create"
raise UnknownCommandError.new "Allowed commands are 'create'"
raise UnknownCommandError, "Allowed commands are 'create'"
end
pkg = nil
if params[:project] || params[:package]
Expand All @@ -292,7 +292,7 @@ def delete_token
user = User.get_by_login(params[:login])

token = Token.where( user_id: user.id, id: params[:id] ).first
raise TokenNotFound.new "Specified token \"#{params[:id]}\" got not found" unless token
raise TokenNotFound, "Specified token \"#{params[:id]}\" got not found" unless token
token.destroy
render_ok
end
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/controllers/request_controller.rb
Expand Up @@ -26,7 +26,7 @@ class RequireFilter < APIException

def render_request_collection
# if all params areblank, something is wrong
raise RequireFilter.new if [:project, :user, :states, :types, :reviewstates, :ids].all? { |f| params[f].blank? }
raise RequireFilter if [:project, :user, :states, :types, :reviewstates, :ids].all? { |f| params[f].blank? }

# convert comma seperated values into arrays
params[:roles] = params[:roles].split(',') if params[:roles]
Expand Down Expand Up @@ -60,7 +60,7 @@ def show
# POST /request?cmd=create
def global_command
unless params[:cmd] == "create"
raise UnknownCommandError.new "Unknown command '#{params[:cmd]}' for path #{request.path}"
raise UnknownCommandError, "Unknown command '#{params[:cmd]}' for path #{request.path}"
end

# refuse request creation for anonymous users
Expand Down Expand Up @@ -96,7 +96,7 @@ def request_command
# FIXME3.0: to be dropped
@req.permission_check_change_groups!
else
raise UnknownCommandError.new "Unknown command '#{params[:cmd]}' for path #{request.path}"
raise UnknownCommandError, "Unknown command '#{params[:cmd]}' for path #{request.path}"
end

# permission granted for the request at this point
Expand Down

0 comments on commit 78789a9

Please sign in to comment.