Skip to content

Commit

Permalink
[webui] Fix Style/FormatString Rubocop cop
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoj committed Jul 3, 2017
1 parent 59e2829 commit 79c22c8
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 24 deletions.
14 changes: 0 additions & 14 deletions .rubocop_todo.yml
Expand Up @@ -802,20 +802,6 @@ Style/For:
- 'src/api/test/unit/debug_flag_test.rb'
- 'src/api/test/unit/publish_flag_test.rb'

# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: format, sprintf, percent
Style/FormatString:
Exclude:
- 'src/api/app/controllers/webui/project_controller.rb'
- 'src/api/app/helpers/webui/project_helper.rb'
- 'src/api/app/jobs/project_status_calculator.rb'
- 'src/api/app/models/issue.rb'
- 'src/api/app/models/package.rb'
- 'src/api/app/models/product.rb'
- 'src/api/config/initializers/logging.rb'

# Offense count: 8
# Configuration parameters: SupportedStyles.
# SupportedStyles: annotated, template
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/project_controller.rb
Expand Up @@ -982,7 +982,7 @@ def check_devel_package_status(currentpack, p)
dproject = dp.project
currentpack['develproject'] = dproject
currentpack['develpackage'] = dp.name
key = '%s/%s' % [dproject, dp.name]
key = "#{dproject}/#{dp.name}"
if @submits.has_key? key
currentpack['requests_to'].concat(@submits[key])
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/helpers/webui/project_helper.rb
Expand Up @@ -63,11 +63,11 @@ def project_bread_crumb(*args)
def format_seconds(secs)
secs = Integer(secs)
if secs < 3600
'0:%02d' % (secs / 60)
format('0:%02d', (secs / 60))
else
hours = secs / 3600
secs -= hours * 3600
'%d:%02d' % [hours, secs / 60]
format('%d:%02d', hours, secs / 60)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/jobs/project_status_calculator.rb
Expand Up @@ -125,7 +125,7 @@ def check_md5(packages)

# parse the jobhistory and put the result in a format we can cache
def parse_jobhistory(dname, repo, arch)
uri = '/build/%s/%s/%s/_jobhistory?code=lastfailures' % [CGI.escape(dname), CGI.escape(repo), arch]
uri = "/build/#{CGI.escape(dname)}/#{CGI.escape(repo)}/#{arch}/_jobhistory?code=lastfailures"

ret = []
d = Backend::Connection.get(uri).body
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/issue.rb
Expand Up @@ -129,7 +129,7 @@ def render_axml
end

def to_axml(_opts = {})
Rails.cache.fetch('issue_%d' % id) do
Rails.cache.fetch("issue_#{id}") do
render_axml
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/package.rb
Expand Up @@ -835,7 +835,7 @@ def to_axml_id
end

def to_axml(_opts = {})
Rails.cache.fetch('xml_package_%d' % id) do
Rails.cache.fetch("xml_package_#{id}") do
# CanRenderModel
render_xml
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/product.rb
Expand Up @@ -25,7 +25,7 @@ def self.all_products( project, expand = nil )
end

def to_axml(_opts = {})
Rails.cache.fetch('xml_product_%d' % id) do
Rails.cache.fetch("xml_product_#{id}") do
# CanRenderModel
render_xml
end
Expand Down
6 changes: 3 additions & 3 deletions src/api/config/initializers/logging.rb
Expand Up @@ -17,8 +17,8 @@ def append_info_to_payload(payload)
module ClassMethods
def log_process_action(payload)
messages, backend_runtime, xml_runtime = super, payload[:backend_runtime], payload[:xml_runtime]
messages << ("Backend: %.1fms" % backend_runtime.to_f) if backend_runtime
messages << ("XML: %.1fms" % xml_runtime.to_f) if xml_runtime
messages << format("Backend: %.1fms", backend_runtime.to_f) if backend_runtime
messages << format("XML: %.1fms", xml_runtime.to_f) if xml_runtime
messages
end
end
Expand All @@ -28,7 +28,7 @@ def log_process_action(payload)
module TimestampFormatter
def call(severity, timestamp, progname, msg)
Thread.current[:timestamp_formatter_timestamp] ||= Time.now
tdiff = sprintf("%02.2f", Time.now - Thread.current[:timestamp_formatter_timestamp])
tdiff = format("%02.2f", Time.now - Thread.current[:timestamp_formatter_timestamp])
super(severity, timestamp, progname, "[#{Process.pid}:#{tdiff}] #{msg}")
end
end
Expand Down

0 comments on commit 79c22c8

Please sign in to comment.