Skip to content

Commit

Permalink
Merge pull request #2436 from DavidKang/method_call_parentheses
Browse files Browse the repository at this point in the history
[ci] Enable the Style/MethodCallParentheses Rubocop cop
  • Loading branch information
Ana06 committed Dec 7, 2016
2 parents ebc7593 + b839a82 commit 31cc602
Show file tree
Hide file tree
Showing 39 changed files with 82 additions and 83 deletions.
12 changes: 8 additions & 4 deletions src/api/.rubocop.yml
Expand Up @@ -57,7 +57,7 @@ Style/EachWithObject:
# Avoid empty else statements.
Style/EmptyElse:
EnforcedStyle: both

# Checks for extra/unnecessary whitespace
Style/ExtraSpacing:
Enabled: true
Expand All @@ -72,15 +72,15 @@ Style/HashSyntax:
# Use Kernel#loop for infinite loops
Style/InfiniteLoop:
Enabled: true

# Checks for uses of if with a negated condition (only ifs without else)
Style/NegatedIf:
Enabled: true

# Use ! instead not
Style/Not:
Enabled: true

# Checks for redundant `return` expressions
Style/RedundantReturn:
Enabled: false
Expand All @@ -93,14 +93,18 @@ Style/NumericLiteralPrefix:
Style/RedundantSelf:
Enabled: true

# checks for space after `!`
# Checks for space after `!`
Style/SpaceAfterNot:
Enabled: true

# Checks for the presence of parentheses around ternary conditions
Style/TernaryParentheses:
Enabled: true

# Checks for unwanted parentheses in parameterless method calls
Style/MethodCallParentheses:
Enabled: true

##################### Metrics ##################################

# Checks if the length a class exceeds some maximum value
Expand Down
5 changes: 0 additions & 5 deletions src/api/.rubocop_todo.yml
Expand Up @@ -560,11 +560,6 @@ Style/IndentationWidth:
Style/LineEndConcatenation:
Enabled: false

# Offense count: 80
# Cop supports --auto-correct.
Style/MethodCallParentheses:
Enabled: false

# Offense count: 29
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/application_controller.rb
Expand Up @@ -542,12 +542,12 @@ def validate_xml_response
return if @skip_validation
# rubocop:disable Metrics/LineLength
if request.format != 'json' && response.status.to_s[0..2] == '200' && response.headers['Content-Type'] !~ /.*\/json/i && response.headers['Content-Disposition'] != 'attachment'
opt = params()
opt = params
opt[:method] = request.method.to_s
opt[:type] = 'response'
ms = Benchmark.ms do
if response.body.respond_to? :call
sio = StringIO.new()
sio = StringIO.new
response.body.call(nil, sio) # send_file can return a block that takes |response, output|
str = sio.string
else
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/architectures_controller.rb
Expand Up @@ -7,7 +7,7 @@ class ArchitecturesController < ApplicationController
# GET /architecture
# GET /architecture.xml
def index
@architectures = Architecture.all()
@architectures = Architecture.all

respond_to do |format|
format.xml do
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/issue_trackers_controller.rb
Expand Up @@ -10,7 +10,7 @@ class IssueTrackersController < ApplicationController
# GET /issue_trackers.json
# GET /issue_trackers.xml
def index
@issue_trackers = IssueTracker.all()
@issue_trackers = IssueTracker.all

respond_to do |format|
format.xml { render xml: @issue_trackers.to_xml(IssueTracker::DEFAULT_RENDER_PARAMS) }
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/public_controller.rb
Expand Up @@ -121,7 +121,7 @@ def distributions
def show_request
required_parameters :number
req = BsRequest.find_by_number!(params[:number])
render xml: req.render_xml()
render xml: req.render_xml
end

# GET /public/binary_packages/:project/:package
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/source_controller.rb
Expand Up @@ -894,7 +894,7 @@ class RepoDependency < APIException
# POST /source/<project>?cmd=showlinked
def project_command_showlinked
builder = Builder::XmlMarkup.new( indent: 2 )
xml = builder.collection() do |c|
xml = builder.collection do |c|
@project.linked_by_projects.each do |l|
p={}
p[:name] = l.name
Expand Down Expand Up @@ -1253,7 +1253,7 @@ def package_command_showlinked
end

builder = Builder::XmlMarkup.new( indent: 2 )
xml = builder.collection() do |c|
xml = builder.collection do |c|
@package.find_linking_packages.each do |l|
p={}
p[:project] = l.project.name
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/tag_controller.rb
Expand Up @@ -339,7 +339,7 @@ def save_tags(object, tagCreator, tags)
# create an entry in the join table (taggings) if necessary
def create_relationship(object, tagCreator, tag)
Tagging.transaction do
@jointable = Tagging.new()
@jointable = Tagging.new
object.taggings << @jointable
tagCreator.taggings << @jointable
tag.taggings << @jointable
Expand Down
8 changes: 4 additions & 4 deletions src/api/app/controllers/wizard_controller.rb
Expand Up @@ -64,12 +64,12 @@ def package_wizard

def create_service_file
node = Builder::XmlMarkup.new(indent: 2)
node.services() do |s|
node.services do |s|
# download file
m = @wizard['sourcefile'].split('://')
protocol = m.first()
host = m[1].split('/').first()
path = m[1].split('/', 2).last()
protocol = m.first
host = m[1].split('/').first
path = m[1].split('/', 2).last
s.service(name: 'download_url') do |d|
d.param(protocol, name: 'protocol')
d.param(host, name: 'host')
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/bs_request_action.rb
Expand Up @@ -292,7 +292,7 @@ def notify_params(ret = {})

def contains_change?
begin
return !sourcediff().blank?
return !sourcediff.blank?
rescue BsRequestAction::DiffError
# if the diff can'be created we can't say
# but let's assume the reason for the problem lies in the change
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/distribution.rb
@@ -1,8 +1,8 @@
class Distribution < ApplicationRecord
validates_presence_of :vendor, :version, :name, :reponame, :repository, :project

has_and_belongs_to_many :icons, -> { distinct() }, class_name: 'DistributionIcon'
has_and_belongs_to_many :architectures, -> { distinct() }, class_name: 'Architecture'
has_and_belongs_to_many :icons, -> { distinct }, class_name: 'DistributionIcon'
has_and_belongs_to_many :architectures, -> { distinct }, class_name: 'Architecture'

def self.parse(xmlhash)
Distribution.transaction do
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/issue_tracker.rb
Expand Up @@ -124,7 +124,7 @@ def update_issues_cve
# new file exists
h = http.get("/data/downloads/allitems.xml.gz")
unzipedio = StringIO.new(h.body) # Net::HTTP is decompressing already
listener = CVEparser.new()
listener = CVEparser.new
listener.set_tracker(self)
parser = Nokogiri::XML::SAX::Parser.new(listener)
parser.parse_io(unzipedio)
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/package_issue.rb
Expand Up @@ -13,7 +13,7 @@ def self.sync_relations(package, issues)
PackageIssue.where("package_id = ? AND NOT issue_id IN (?)", package, allissues).lock(true).delete_all

# create missing in an efficient way
sql=ApplicationRecord.connection()
sql=ApplicationRecord.connection
(allissues - package.issues.to_ary).each do |i|
sql.execute("INSERT INTO `package_issues` (`package_id`, `issue_id`) VALUES (#{package.id},#{i.id})")
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/project.rb
Expand Up @@ -1548,14 +1548,14 @@ def build_succeeded?(repository = nil)
result.each('summary') do |summary|
summary.each('statuscount') do |statuscount|
repository_states[repository][statuscount.value('code')] ||= 0
repository_states[repository][statuscount.value('code')] += statuscount.value('count').to_i()
repository_states[repository][statuscount.value('code')] += statuscount.value('count').to_i
end
end
else
result.each('summary') do |summary|
summary.each('statuscount') do |statuscount|
states[statuscount.value('code')] ||= 0
states[statuscount.value('code')] += statuscount.value('count').to_i()
states[statuscount.value('code')] += statuscount.value('count').to_i
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions src/api/app/models/user_ldap_strategy.rb
Expand Up @@ -373,7 +373,7 @@ def self.dn2user_principal_name(dn)
# implicitly convert array to string
dn = [ dn ].flatten.join(',')
begin
dn_components = dn.split(',').map{ |n| n.strip().split('=') }
dn_components = dn.split(',').map{ |n| n.strip.split('=') }
dn_uid = dn_components.select { |x, _| x == 'uid' }.map { |_, y| y }
dn_path = dn_components.select { |x, _| x == 'dc' }.map { |_, y| y }
upn = "#{dn_uid.fetch(0)}@#{dn_path.join('.')}"
Expand Down Expand Up @@ -431,7 +431,7 @@ def self.find_with_ldap(login, password)
end
rescue
Rails.logger.debug("Search failed: error #{ @@ldap_search_con.err}: #{ @@ldap_search_con.err2string(@@ldap_search_con.err)}")
@@ldap_search_con.unbind()
@@ldap_search_con.unbind
@@ldap_search_con = nil
if ldap_first_try
ldap_first_try = false
Expand Down Expand Up @@ -460,9 +460,9 @@ def self.find_with_ldap(login, password)
else
# Redo the search as the user for situations where the anon search may not be able to see attributes
user_con.search(CONFIG['ldap_search_base'], LDAP::LDAP_SCOPE_SUBTREE, user_filter) do |entry|
user.replace(entry.to_hash())
user.replace(entry.to_hash)
end
user_con.unbind()
user_con.unbind
end
else # If no CONFIG['ldap_authenticate'] is given do not return the ldap_info !
Rails.logger.error("Unknown ldap_authenticate setting: '#{CONFIG['ldap_authenticate']}' " +
Expand Down Expand Up @@ -592,7 +592,7 @@ def self.initialize_ldap_con(user_name, password)
conn.bind(user_name, password)
rescue LDAP::ResultError
if !conn.nil? && conn.bound?
conn.unbind()
conn.unbind
end
Rails.logger.debug("Not bound as #{user_name}: #{conn.err2string(conn.err)}")
return nil
Expand Down
Expand Up @@ -13,6 +13,6 @@ def self.up
end

def self.down
AttribType.find_by_namespace_and_name("OBS", "OwnerRootProject").destroy()
AttribType.find_by_namespace_and_name("OBS", "OwnerRootProject").destroy
end
end
Expand Up @@ -7,7 +7,7 @@ def self.up

sql.each_line do |line|
begin
ActiveRecord::Base.connection().execute( line )
ActiveRecord::Base.connection.execute( line )
rescue
puts "WARNING: The database is inconsistent, some FOREIGN KEYs (aka CONSTRAINTS) can not be added!"
puts " please run script/check_database script to fix the data."
Expand All @@ -19,7 +19,7 @@ def self.up
def self.drop_constraint( table, count )
for nr in (1..count)
begin
ActiveRecord::Base.connection().execute( "alter table #{table} drop FOREIGN KEY #{table}_ibfk_#{nr};" )
ActiveRecord::Base.connection.execute( "alter table #{table} drop FOREIGN KEY #{table}_ibfk_#{nr};" )
rescue
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/db/migrate/20130621083665_add_attrib_issues.rb
Expand Up @@ -7,9 +7,9 @@ def self.up
end
add_index :attrib_issues, [:attrib_id, :issue_id], unique: true

ActiveRecord::Base.connection().execute(
ActiveRecord::Base.connection.execute(
"alter table attrib_issues add FOREIGN KEY (attrib_id) references attribs (id);")
ActiveRecord::Base.connection().execute(
ActiveRecord::Base.connection.execute(
"alter table attrib_issues add FOREIGN KEY (issue_id) references issues (id);")

add_column :attrib_types, :issue_list, :boolean, default: false
Expand Down
Expand Up @@ -23,7 +23,7 @@ def self.up
# update database from file
old = CONFIG['global_write_through']
CONFIG['global_write_through'] = false
::Configuration.first.update_from_options_yml()
::Configuration.first.update_from_options_yml
CONFIG['global_write_through'] = old
end

Expand Down
Expand Up @@ -10,6 +10,6 @@ def self.up
end

def self.down
AttribType.find_by_namespace_and_name("OBS", "BranchRepositoriesFromProject").destroy()
AttribType.find_by_namespace_and_name("OBS", "BranchRepositoriesFromProject").destroy
end
end
Expand Up @@ -14,7 +14,7 @@ def self.up
end

def self.down
AttribType.find_by_namespace_and_name("OBS", "AutoCleanup").delete()
AttribType.find_by_namespace_and_name("OBS", "AutoCleanup").delete
remove_column :configurations, :cleanup_after_days
end
end
Expand Up @@ -12,6 +12,6 @@ def self.up
end

def self.down
AttribType.find_by_namespace_and_name("OBS", "IncidentPriority").delete()
AttribType.find_by_namespace_and_name("OBS", "IncidentPriority").delete
end
end
2 changes: 1 addition & 1 deletion src/api/db/migrate/20141107135426_embargo_attribute.rb
Expand Up @@ -18,6 +18,6 @@ def self.up
end

def self.down
AttribType.find_by_namespace_and_name("OBS", "EmbargoDate").delete()
AttribType.find_by_namespace_and_name("OBS", "EmbargoDate").delete
end
end
Expand Up @@ -18,6 +18,6 @@ def self.up
end

def self.down
AttribType.find_by_namespace_and_name("OBS", "MakeOriginOlder").delete()
AttribType.find_by_namespace_and_name("OBS", "MakeOriginOlder").delete
end
end
Expand Up @@ -14,6 +14,6 @@ def self.up
end

def self.down
AttribType.find_by_namespace_and_name("OBS", "BranchSkipRepositories").destroy()
AttribType.find_by_namespace_and_name("OBS", "BranchSkipRepositories").destroy
end
end
Expand Up @@ -15,6 +15,6 @@ def self.up
end

def self.down
AttribType.find_by_namespace_and_name("OBS", "PlannedReleaseDate").delete()
AttribType.find_by_namespace_and_name("OBS", "PlannedReleaseDate").delete
end
end
Expand Up @@ -12,6 +12,6 @@ def self.up
end

def self.down
AttribType.find_by_namespace_and_name("OBS", "ImageTemplates").delete()
AttribType.find_by_namespace_and_name("OBS", "ImageTemplates").delete
end
end
2 changes: 1 addition & 1 deletion src/api/lib/activexml/transport.rb
Expand Up @@ -335,7 +335,7 @@ def http_do( method, url, opt = {} )
opt[:data] = opt[:data].read
end
if opt[:data].respond_to?(:length)
clength["Content-Length"] = opt[:data].length().to_s()
clength["Content-Length"] = opt[:data].length.to_s
end
clength["Content-Type"] = opt[:content_type] unless opt[:content_type].nil?

Expand Down
2 changes: 1 addition & 1 deletion src/api/lib/tasks/databases.rake
Expand Up @@ -71,7 +71,7 @@ namespace :db do
else
if constraints.count > 0
constraints.sort!
new_structure += constraints.join()
new_structure += constraints.join
if added_comma
new_structure = new_structure[0..-3] + "\n"
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/lib/workers/update_issues.rb
Expand Up @@ -9,7 +9,7 @@ def initialize
def perform
IssueTracker.find(:all).each do |t|
next unless t.enable_fetch
t.update_issues()
t.update_issues
end
end
end

0 comments on commit 31cc602

Please sign in to comment.