Skip to content

Commit

Permalink
[api] Rubymine 6.0 was released and I had to click around it
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Nov 26, 2013
1 parent 60cbae4 commit 5bbe5c7
Show file tree
Hide file tree
Showing 56 changed files with 121 additions and 133 deletions.
4 changes: 2 additions & 2 deletions src/api/app/controllers/build_controller.rb
Expand Up @@ -2,7 +2,7 @@ class BuildController < ApplicationController

def index
# for read access and visibility permission check
if params[:package] and not ["_repository", "_jobhistory"].include?(params[:package])
if params[:package] and not %w(_repository _jobhistory).include?(params[:package])
Package.get_by_project_and_name( params[:project], params[:package], use_source: false )
else
Project.get_by_name params[:project]
Expand Down Expand Up @@ -44,7 +44,7 @@ def project_index
return
end

unless ["wipe", "restartbuild", "killbuild", "abortbuild", "rebuild"].include? params[:cmd]
unless %w(wipe restartbuild killbuild abortbuild rebuild).include? params[:cmd]
render_error :status => 400, :errorcode => "illegal_request",
:message => "unsupported POST command #{params[:cmd]} to #{request.url}"
return
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/controllers/request_controller.rb
Expand Up @@ -306,7 +306,7 @@ def check_request_change(req, params)
# do not allow direct switches from a final state to another one to avoid races and double actions.
# request needs to get reopened first.
if [:accepted, :superseded, :revoked].include? req.state
if ['accepted', 'declined', 'superseded', 'revoked'].include? params[:newstate]
if %w(accepted declined superseded revoked).include? params[:newstate]
raise PostRequestNoPermission.new "set state to #{params[:newstate]} from a final state is not allowed."
end
end
Expand All @@ -321,7 +321,7 @@ def check_request_change(req, params)
end

# adding and removing of requests is only allowed for groups
if ['addrequest', 'removerequest'].include? params[:cmd]
if %w(addrequest removerequest).include? params[:cmd]
if req.bs_request_actions.first.action_type != :group
raise GroupRequestSpecial.new "Command #{params[:cmd]} is only valid for group requests"
end
Expand Down Expand Up @@ -397,7 +397,7 @@ def check_request_change(req, params)
end
#
permission_granted = true
elsif req.state != :accepted and ['new', 'review', 'revoked', 'superseded'].include?(params[:newstate]) and req.creator == User.current.login
elsif req.state != :accepted and %w(new review revoked superseded).include?(params[:newstate]) and req.creator == User.current.login
# request creator can reopen, revoke or supersede a request which was declined
permission_granted = true
elsif req.state == :declined and (params[:newstate] == 'new' or params[:newstate] == 'review') and req.commenter == User.current.login
Expand Down
26 changes: 13 additions & 13 deletions src/api/app/controllers/source_controller.rb
Expand Up @@ -188,7 +188,8 @@ def project_command

# init and validation
#--------------------
valid_commands=['undelete', 'showlinked', 'remove_flag', 'set_flag', 'createpatchinfo', 'createkey', 'extendkey', 'copy', 'createmaintenanceincident', 'unlock', 'release', 'addchannels']
valid_commands=%w(undelete showlinked remove_flag set_flag createpatchinfo createkey extendkey copy
createmaintenanceincident unlock release addchannels)
if params[:cmd]
raise IllegalRequest.new 'invalid_command' unless valid_commands.include?(params[:cmd])
command = params[:cmd]
Expand Down Expand Up @@ -241,7 +242,7 @@ def show_package
validate_read_access_of_deleted_package(@target_project_name, @target_package_name)
end
else
if ['_project', '_pattern'].include? @target_package_name
if %w(_project _pattern).include? @target_package_name
Project.get_by_name @target_project_name
else
@tpkg = Package.get_by_project_and_name(@target_project_name, @target_package_name, use_source: true, follow_project_links: true)
Expand Down Expand Up @@ -356,10 +357,9 @@ def package_command
end

# valid post commands
valid_commands=['diff', 'branch', 'servicediff', 'linkdiff', 'showlinked', 'copy', 'remove_flag', 'set_flag',
'rebuild', 'undelete', 'wipe', 'runservice', 'commit', 'commitfilelist',
'createSpecFileTemplate', 'deleteuploadrev', 'linktobranch', 'updatepatchinfo',
'getprojectservices', 'unlock', 'release']
valid_commands=%w(diff branch servicediff linkdiff showlinked copy remove_flag set_flag rebuild undelete
wipe runservice commit commitfilelist createSpecFileTemplate deleteuploadrev linktobranch
updatepatchinfo getprojectservices unlock release)

@command = params[:cmd]
raise IllegalRequest.new 'invalid_command' unless valid_commands.include?(@command)
Expand All @@ -374,8 +374,8 @@ def package_command
# Check for existens/access of origin package when specified
@spkg = nil
Project.get_by_name origin_project_name if origin_project_name
if origin_package_name && !['_project', '_pattern'].include?(origin_package_name) && !(params[:missingok] && @command == 'branch')
@spkg = Package.get_by_project_and_name(origin_project_name, origin_package_name) if origin_package_name && !['_project', '_pattern'].include?(origin_package_name)
if origin_package_name && !%w(_project _pattern).include?(origin_package_name) && !(params[:missingok] && @command == 'branch')
@spkg = Package.get_by_project_and_name(origin_project_name, origin_package_name) if origin_package_name && !%w(_project _pattern).include?(origin_package_name)
end
if @spkg
# use real source in case we followed project link
Expand All @@ -395,19 +395,19 @@ def package_command
end


Source_untouched_commands = ['branch', 'diff', 'linkdiff', 'servicediff', 'showlinked', 'rebuild', 'wipe', 'remove_flag', 'set_flag', 'getprojectservices']
Source_untouched_commands = %w(branch diff linkdiff servicediff showlinked rebuild wipe remove_flag set_flag getprojectservices)
# list of cammands which create the target package
Package_creating_commands = ['branch', 'copy', 'undelete']
Package_creating_commands = %w(branch copy undelete)
# list of commands which are allowed even when the project has the package only via a project link
Read_commands = ['branch', 'diff', 'linkdiff', 'servicediff', 'showlinked', 'getprojectservices']
Read_commands = %w(branch diff linkdiff servicediff showlinked getprojectservices)

def validate_target_for_package_command_exists!
@project = nil
@package = nil

follow_project_links = Source_untouched_commands.include?(@command)

unless ['_project', '_pattern'].include? @target_package_name
unless %w(_project _pattern).include? @target_package_name
use_source = true
use_source = false if @command == 'showlinked'
@package = Package.get_by_project_and_name(@target_project_name, @target_package_name,
Expand Down Expand Up @@ -855,7 +855,7 @@ def update_file
pass_to_backend @path

# update package timestamp and reindex sources
unless params[:rev] == 'repository' or [ '_project', '_pattern'].include? @package_name
unless params[:rev] == 'repository' or %w(_project _pattern).include? @package_name
@pack.sources_changed
@pack.update_if_dirty if special_file # scan
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/tag_controller.rb
Expand Up @@ -172,7 +172,7 @@ def most_recent_tags()


def tagcloud
allowed_distribution_methods = ['raw', 'linear' , 'logarithmic']
allowed_distribution_methods = %w(raw linear logarithmic)
@limit = params[:limit] or @limit = 100
@limit = @limit.to_i

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/test_controller.rb
Expand Up @@ -19,7 +19,7 @@ def killme

# we need a way so the API uprises fully
def startme
if @@started == true
if @@started
render_ok
return
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/driver_update_controller.rb
Expand Up @@ -140,7 +140,7 @@ def binaries
required_parameters :repository
@repository = params[:repository]
@buildresult = Buildresult.find(:project => @project, :package => @package,
:repository => @repository, :view => ['binarylist', 'status'])
:repository => @repository, :view => %w(binarylist status))
@binaries = @buildresult.each('//binary').map{|binary| binary['filename']}
render :partial => 'binary_packages'
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/patchinfo_controller.rb
Expand Up @@ -139,7 +139,7 @@ def save
flash[:error] = "#{flash[:error]}" + ' || Description is too short (should have more than 50 signs and longer than summary)'
end

if valid_params == true
if valid_params
packager = params[:packager]
binaries = params[:selected_binaries]
relogin = params[:relogin]
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/user_controller.rb
Expand Up @@ -103,7 +103,7 @@ def lock

def admin
u = User.find_by_login(params[:user])
u.update_globalroles(['Admin'])
u.update_globalroles(%w(Admin))
u.save
end

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/webui_controller.rb
Expand Up @@ -4,7 +4,7 @@
require 'frontend_compat'

class Webui::WebuiController < ActionController::Base
Rails.cache.set_domain if Rails.cache.respond_to?('set_domain');
Rails.cache.set_domain if Rails.cache.respond_to?('set_domain')

before_filter :setup_view_path
before_filter :instantiate_controller_and_action_names
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/helpers/webui/package_helper.rb
Expand Up @@ -18,7 +18,7 @@ def human_readable_fsize( bytes )
end

def guess_code_class( filename )
return 'xml' if ['_aggregate', '_link', '_patchinfo', '_service'].include?(filename) || filename.match(/.*\.service/)
return 'xml' if %w(_aggregate _link _patchinfo _service).include?(filename) || filename.match(/.*\.service/)
return 'shell' if filename.match(/^rc[\w-]+$/) # rc-scripts are shell
return 'python' if filename.match(/^.*rpmlintrc$/)
return 'makefile' if filename == 'debian.rules'
Expand All @@ -38,7 +38,7 @@ def guess_code_class( filename )
when '.sh' then return 'shell'
end
ext = ext[1..-1]
return ext if ['changes', 'spec', 'diff', 'php', 'html', 'xml', 'css', 'perl'].include? ext
return ext if %w(changes spec diff php html xml css perl).include? ext
return ''
end

Expand Down
6 changes: 3 additions & 3 deletions src/api/app/helpers/webui/webui_helper.rb
Expand Up @@ -111,12 +111,12 @@ def arch_repo_table_cell(repo, arch, packname)
end

out = "<td class='#{theclass} buildstatus'>"
if ['unresolvable', 'blocked'].include? code
if %w(unresolvable blocked).include? code
out += link_to code, '#', title: link_title, id: status_id
content_for :ready_function do
"$('a##{status_id}').click(function() { alert('#{link_title.gsub(/'/, '\\\\\'')}'); return false; });\n".html_safe
end
elsif ['-', 'excluded'].include? code
elsif %w(- excluded).include? code
out += code
else
out += link_to code.gsub(/\s/, '&nbsp;'), { action: :live_build_log,
Expand Down Expand Up @@ -338,7 +338,7 @@ def description_wrapper(description)
end

def is_advanced_tab?
['prjconf', 'attributes', 'meta', 'status'].include? @current_action.to_s
%w(prjconf attributes meta status).include? @current_action.to_s
end

def mobile_device?
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/mixins/webui/load_buildresults.rb
Expand Up @@ -25,7 +25,7 @@ def fill_status_cache

result.elements('status') do |status|
stathash[status['package']] = status
if ['unresolvable', 'failed', 'broken'].include? status['code']
if %w(unresolvable failed broken).include? status['code']
@failures += 1
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/bs_request_collection.rb
Expand Up @@ -119,7 +119,7 @@ def extend_query_for_group(group)
if @roles.count == 0 or @roles.include? 'reviewer'
@rel = @rel.includes(:reviews).references(:reviews)
# requests where the user is reviewer or own requests that are in review by someone else
or_in_and = ["reviews.by_group=#{quote(group.title)}"]
or_in_and = %W(reviews.by_group=#{quote(group.title)})

extend_query_for_involved_reviews(group, or_in_and)
end
Expand All @@ -140,7 +140,7 @@ def extend_query_for_user(user)
@rel = @rel.includes(:reviews).references(:reviews)

# requests where the user is reviewer or own requests that are in review by someone else
or_in_and = ["reviews.by_user=#{quote(user.login)}"]
or_in_and = %W(reviews.by_user=#{quote(user.login)})

# include all groups of user
usergroups = user.groups.map { |g| "'#{g.title}'" }
Expand Down
6 changes: 2 additions & 4 deletions src/api/app/models/buildresult.rb
@@ -1,9 +1,7 @@
class Buildresult < ActiveXML::Node

Avail_status_values =
['succeeded', 'failed', 'unresolvable', 'broken',
'blocked', 'dispatching', 'scheduled', 'building', 'finished', 'signing',
'disabled', 'excluded', 'locked', 'deleting', 'unknown']
Avail_status_values = %w(succeeded failed unresolvable broken blocked dispatching scheduled
building finished signing disabled excluded locked deleting unknown)
@@status_hash = nil

def self.avail_status_values
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/db_project_type.rb
@@ -1,4 +1,4 @@
class DbProjectType < ActiveRecord::Base
validates_presence_of :name
validates_inclusion_of :name, in: ['standard', 'maintenance', 'maintenance_incident', 'maintenance_release']
validates_inclusion_of :name, in: %w(standard maintenance maintenance_incident maintenance_release)
end
4 changes: 2 additions & 2 deletions src/api/app/models/issue.rb
Expand Up @@ -59,8 +59,8 @@ def self.states
end

def self.bugzilla_state( string )
return 'OPEN' if [ 'NEW', 'NEEDINFO', 'REOPENED', 'ASSIGNED' ].include? string
return 'CLOSED' if [ 'RESOLVED', 'CLOSED', 'VERIFIED' ].include? string
return 'OPEN' if %w(NEW NEEDINFO REOPENED ASSIGNED).include? string
return 'CLOSED' if %w(RESOLVED CLOSED VERIFIED).include? string
return 'UNKNOWN'
end

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/issue_tracker.rb
Expand Up @@ -10,7 +10,7 @@ class NotFoundError < APIException

validates_presence_of :name, :regex, :url, :kind
validates_uniqueness_of :name, :regex
validates_inclusion_of :kind, :in => ['other', 'bugzilla', 'cve', 'fate', 'trac', 'launchpad', 'sourceforge']
validates_inclusion_of :kind, :in => %w(other bugzilla cve fate trac launchpad sourceforge)

# FIXME: issues_updated should not be hidden, but it should also not break our api
DEFAULT_RENDER_PARAMS = {:except => [:id, :password, :user, :issues_updated], :dasherize => true, :skip_types => true, :skip_instruct => true}
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/maintenance_incident.rb
Expand Up @@ -7,7 +7,7 @@ class MaintenanceIncident < ActiveRecord::Base

def project_name
unless self.incident_id
sql = ActiveRecord::Base.connection();
sql = ActiveRecord::Base.connection()
r = sql.execute( "SELECT counter FROM incident_counter WHERE maintenance_db_project_id = " + self.maintenance_db_project_id.to_s + " FOR UPDATE" ).first

if r.nil?
Expand Down Expand Up @@ -53,7 +53,7 @@ def getUpdateinfoId( id_template )
counterType << " AND ISNULL(day)"
day = "NULL"
end
sql = ActiveRecord::Base.connection();
sql = ActiveRecord::Base.connection()
r = sql.execute( "SELECT counter FROM updateinfo_counter WHERE maintenance_db_project_id = " + self.maintenance_db_project.id.to_s + counterType + " FOR UPDATE" ).first
if r.nil?
# no counter exists, initialize it and select again
Expand Down
12 changes: 6 additions & 6 deletions src/api/app/models/owner.rb
Expand Up @@ -56,17 +56,17 @@ def self.search(params, obj)
projects.each do |project|

attrib = project.attribs.where(attrib_type_id: at.id).first
filter = ["maintainer","bugowner"]
filter = %w(maintainer bugowner)
devel = true
if params[:filter]
filter=params[:filter].split(",")
else
if attrib and v=attrib.values.where(value: "BugownerOnly").exists?
filter=["bugowner"]
filter=%w(bugowner)
end
end
if params[:devel]
devel=false if [ "0", "false" ].include? params[:devel]
devel=false if %w(0 false).include? params[:devel]
else
if attrib and v=attrib.values.where(value: "DisableDevel").exists?
devel=false
Expand All @@ -89,7 +89,7 @@ def self.search(params, obj)

protected

def self.find_assignees(rootproject, binary_name, limit=1, devel=true, filter=["maintainer","bugowner"], webui_mode=false)
def self.find_assignees(rootproject, binary_name, limit=1, devel=true, filter=%w(maintainer bugowner), webui_mode=false)
projects=rootproject.expand_all_projects
instances_without_definition=[]
maintainers=[]
Expand Down Expand Up @@ -149,7 +149,7 @@ def self.find_assignees(rootproject, binary_name, limit=1, devel=true, filter=["
return maintainers
end

def self.find_containers_without_definition(rootproject, devel=true, filter=["maintainer","bugowner"] )
def self.find_containers_without_definition(rootproject, devel=true, filter=%w(maintainer bugowner))
projects=rootproject.expand_all_projects
roles=[]
filter.each do |f|
Expand Down Expand Up @@ -189,7 +189,7 @@ def self.find_containers_without_definition(rootproject, devel=true, filter=["ma
return maintainers
end

def self.find_containers(rootproject, owner, devel=true, filter=["maintainer","bugowner"] )
def self.find_containers(rootproject, owner, devel=true, filter=%w(maintainer bugowner))
projects=rootproject.expand_all_projects

roles=[]
Expand Down
1 change: 1 addition & 0 deletions src/api/app/models/package.rb
Expand Up @@ -180,6 +180,7 @@ def exists_on_backend?(package, project)
answer = Suse::Backend.get(Package.source_path(project, package))
return true if answer
rescue ActiveXML::Transport::Error
# ignored
end
return false
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/package_build_status.rb
Expand Up @@ -103,10 +103,10 @@ def gather_current_buildcode(srep, arch)
rescue ActiveXML::Transport::Error
currentcode = nil
end
if ['unresolvable', 'failed', 'broken'].include?(currentcode)
if %w(unresolvable failed broken).include?(currentcode)
@buildcode='failed'
end
if ['building', 'scheduled', 'finished', 'signing', 'blocked'].include?(currentcode)
if %w(building scheduled finished signing blocked).include?(currentcode)
@buildcode='building'
end
if currentcode == 'excluded'
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/tagcloud.rb
Expand Up @@ -158,7 +158,7 @@ def linear_distribution_method(steps)
range = 1 if @max == @min
tagcloud = Hash.new
@tags.each do |tag|
ratio = (tag.count - @min.to_f) / range;
ratio = (tag.count - @min.to_f) / range
fsize = (0 + steps) * ratio
tagcloud[tag.name] = fsize.round
end
Expand Down

0 comments on commit 5bbe5c7

Please sign in to comment.