Skip to content

Commit

Permalink
Fix new cops warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rubhanazeem committed Sep 15, 2021
1 parent fc6c88d commit c24499e
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/api/app/controllers/webui/staging/workflows_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ def project_weight(project)
when :acceptable
10_000
when :review
20_000 - helpers.review_progress(project) * 10
20_000 - (helpers.review_progress(project) * 10)
when :testing
30_000 - helpers.testing_progress(project) * 10
30_000 - (helpers.testing_progress(project) * 10)
when :building
40_000 - helpers.build_progress(project) * 10
40_000 - (helpers.build_progress(project) * 10)
when :failed
50_000
when :unacceptable
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/helpers/webui/staging/workflow_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def review_progress(staging_project)
total = Review.where(bs_request: staging_project.staged_requests).size
missing = staging_project.missing_reviews.count { |missing_review| staged_requests_numbers.include?(missing_review[:request]) }

100 - missing * 100 / total
100 - (missing * 100 / total)
end

def testing_progress(staging_project)
Expand All @@ -29,7 +29,7 @@ def testing_progress(staging_project)
not_done = staging_project.checks.pending.size + staging_project.missing_checks.size
all_checks = staging_project.checks.size + staging_project.missing_checks.size

100 - not_done * 100 / all_checks
100 - (not_done * 100 / all_checks)
end

def progress(staging_project)
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/helpers/webui/webui_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ def elide(text, length = 20, mode = :middle)
when :left # shorten at the beginning
shortened_text = '...' + text[text.length - length + 3..text.length]
when :middle # shorten in the middle
pre = text[0..length / 2 - 2]
pre = text[0..(length / 2) - 2]
offset = 2 # depends if (shortened) length is even or odd
offset = 1 if length.odd?
post = text[text.length - length / 2 + offset..text.length]
post = text[text.length - (length / 2) + offset..text.length]
shortened_text = pre + '...' + post
when :right # shorten at the end
shortened_text = text[0..length - 4] + '...'
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/jobs/status_history_rescaler_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class StatusHistoryRescalerJob < ApplicationJob
# this is called from a delayed job triggered by clockwork
def perform
maxtime = StatusHistory.maximum(:time)
StatusHistory.where('time < ?', maxtime - 365 * 24 * 3600).delete_all if maxtime
StatusHistory.where('time < ?', maxtime - (365 * 24 * 3600)).delete_all if maxtime

keys = StatusHistory.distinct.pluck(:key)
keys.each do |key|
Expand Down Expand Up @@ -47,7 +47,7 @@ def cleanup(key, offset, maxtimeoffset)
items = find_start_items(allitems, curmintime + offset)

if items.length > 1
timeavg = curmintime + offset / 2
timeavg = curmintime + (offset / 2)
valuavg = (items.inject(0) { |sum, item| sum + item.value }).to_f / items.length
Rails.logger.debug { "scaling #{key} #{curmintime} #{items.length} #{Time.at(timeavg)} #{valuavg}" }
StatusHistory.delete(items.map(&:id))
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/branch_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def create_branch_packages(tprj)
else
tpkg = tprj.packages.new(name: pack_name)
end
tpkg.bcntsynctag << '.' + p[:link_target_project].name.tr(':', '_') if tpkg.bcntsynctag && @extend_names
tpkg.bcntsynctag << ('.' + p[:link_target_project].name.tr(':', '_')) if tpkg.bcntsynctag && @extend_names
tpkg.releasename = p[:release_name]
end
tpkg.store
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/bs_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1137,8 +1137,8 @@ def raisepriority(new_priority)
# This method checks makes sure this is the case.
def change_priorities?(new_priority)
new_priority == 'critical' ||
new_priority == 'important' && priority.in?(['moderate', 'low']) ||
new_priority == 'moderate' && priority == 'low'
(new_priority == 'important' && priority.in?(['moderate', 'low'])) ||
(new_priority == 'moderate' && priority == 'low')
end

def check_bs_request_actions!(opts = {})
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/event/build_fail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def state

def faillog
size = get_size_of_log(payload['project'], payload['package'], payload['repository'], payload['arch'])
offset = size - 18 * 1024
offset = size - (18 * 1024)
offset = 0 if offset.negative?
log = raw_log_chunk(payload['project'], payload['package'], payload['repository'], payload['arch'], offset, size)
log.encode!(invalid: :replace, undef: :replace, universal_newline: true)
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ def self.activity_algorithm
end

def activity
activity_index * 2.3276**((updated_at_was.to_f - Time.now.to_f) / 10_000_000)
activity_index * (2.3276**((updated_at_was.to_f - Time.now.to_f) / 10_000_000))
end

def open_requests_with_package_as_source_or_target
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ def check_access?(project)
# check if User.session! belongs to group.
User.session!.is_in_group?(grouprel.group) ||
# FIXME: please do not do special things here for ldap. please cover this in a generic group model.
CONFIG['ldap_mode'] == :on &&
(CONFIG['ldap_mode'] == :on &&
CONFIG['ldap_group_support'] == :on &&
UserLdapStrategy.user_in_group_ldap?(User.session!, grouprel.group_id)
UserLdapStrategy.user_in_group_ldap?(User.session!, grouprel.group_id))
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/status_history.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class StatusHistory < ApplicationRecord
def self.history_by_key_and_hours(key, hours = 24)
starttime = Time.now.to_i - hours.to_i * 3600
starttime = Time.now.to_i - (hours.to_i * 3600)

where("time >= ? AND \`key\` = ?", starttime, key)
.pluck(:time, :value)
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/package/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
Source Files
- if @linkinfo && @revision_parameter.nil?
%small
- if @expand && @expand.to_s == '1' || @forced_unexpand.present?
- if (@expand && @expand.to_s == '1') || @forced_unexpand.present?
= link_to('(show unmerged sources)', package_show_path(project: @project.name, package: @package.name,
rev: @revision_parameter, expand: '0'))
- else
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/user/_activity.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
%tr
%td.week-day= Date::ABBR_DAYNAMES[(week_day + 1) % 7]
- 53.times do |week_number|
- current_day = first_day + week_number * 7 + week_day
- current_day = first_day + (week_number * 7) + week_day

- if current_day > last_day
%td
Expand Down
2 changes: 1 addition & 1 deletion src/api/lib/xpath_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def evaluate_expr(expr, root, escape = false)
when :attribute
expr.shift # :qname token
expr.shift # namespace
a << '@' + expr.shift
a << ('@' + expr.shift)
when :literal
value = (escape ? escape_for_like(expr.shift) : expr.shift)
return '' if @last_key && @attribs[table][@last_key][:empty]
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/helpers/webui/package_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
end

it 'breaks up long strings' do
long_string = 'a' * 50 + 'b' * 50 + 'c' * 10
long_string = ('a' * 50) + ('b' * 50) + ('c' * 10)
sanitized_string = nbsp(long_string)
expect(long_string.scan(/.{1,50}/).join('<wbr>')).to eq(sanitized_string)
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/spec/models/kiwi/repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@
property_of do
project = []
range(1, 3).times do
project << string(/[a-zA-Z1-9]/) + sized(range(0, 20)) { string(/[-+\w.]/) }
project << (string(/[a-zA-Z1-9]/) + sized(range(0, 20)) { string(/[-+\w.]/) })
end
repository = []
range(1, 3).times do
repository << string(/[a-zA-Z1-9]/) + sized(range(0, 20)) { string(/[-+\w.]/) }
repository << (string(/[a-zA-Z1-9]/) + sized(range(0, 20)) { string(/[-+\w.]/) })
end
path = "obs://#{project.join(':')}/#{repository.join(':')}"
path
Expand Down
2 changes: 1 addition & 1 deletion src/api/test/unit/status_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class StatusHelperTest < ActiveSupport::TestCase
now = 10_000
testarray = []
10.times do |i|
testarray << [now - i * 10, i]
testarray << [now - (i * 10), i]
end
# [[10000, 0], [9990, 1], [9980, 2], [9970, 3], [9960, 4], [9950, 5], [9940, 6], [9930, 7], [9920, 8], [9910, 9]]
# while the testarray increases, the timestamps go down, so the result needs to decrease
Expand Down

0 comments on commit c24499e

Please sign in to comment.