From 814f7e997b31a723c6a7c8471fa699c98c47492c Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 16 Jul 2021 16:10:31 +0200 Subject: [PATCH] Maintenance: Activated rubocop Style/SelfAssignment. --- .rubocop/default.yml | 7 ------- app/controllers/long_polling_controller.rb | 2 +- app/jobs/ticket_online_notification_seen_job.rb | 2 +- app/models/channel.rb | 2 +- app/models/job.rb | 10 +++++----- app/models/transaction/notification.rb | 2 +- lib/calendar_subscriptions.rb | 4 ++-- lib/core_ext/string.rb | 2 +- lib/report/base.rb | 2 +- lib/stats/ticket_waiting_time.rb | 2 +- lib/twitter_sync.rb | 2 +- lib/websocket_server.rb | 2 +- 12 files changed, 16 insertions(+), 23 deletions(-) diff --git a/.rubocop/default.yml b/.rubocop/default.yml index 055c52a53..631c316ee 100644 --- a/.rubocop/default.yml +++ b/.rubocop/default.yml @@ -166,13 +166,6 @@ Style/PerlBackrefs: StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers' Enabled: false -Style/SelfAssignment: - Description: >- - Checks for places where self-assignment shorthand should have - been used. - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment' - Enabled: false - Rails/ApplicationRecord: Exclude: - 'app/models/application_model.rb' diff --git a/app/controllers/long_polling_controller.rb b/app/controllers/long_polling_controller.rb index b66bba2c8..74af327c1 100644 --- a/app/controllers/long_polling_controller.rb +++ b/app/controllers/long_polling_controller.rb @@ -73,7 +73,7 @@ class LongPollingController < ApplicationController count = 12 end loop do - count = count - 1 + count -= 1 queue = Sessions.queue(client_id) if queue && queue[0] logger.debug { "send #{queue.inspect} to #{client_id}" } diff --git a/app/jobs/ticket_online_notification_seen_job.rb b/app/jobs/ticket_online_notification_seen_job.rb index 66c94eb64..79c1278a5 100644 --- a/app/jobs/ticket_online_notification_seen_job.rb +++ b/app/jobs/ticket_online_notification_seen_job.rb @@ -9,7 +9,7 @@ class TicketOnlineNotificationSeenJob < ApplicationJob end def perform(ticket_id, user_id) - user_id = user_id || 1 + user_id ||= 1 # set all online notifications to seen Transaction.execute do diff --git a/app/models/channel.rb b/app/models/channel.rb index c937db081..9beb070a2 100644 --- a/app/models/channel.rb +++ b/app/models/channel.rb @@ -164,7 +164,7 @@ stream all accounts local_delay_before_reconnect = delay_before_reconnect if channel.status_in == 'error' - local_delay_before_reconnect = local_delay_before_reconnect * 2 + local_delay_before_reconnect *= 2 end if @@channel_stream[channel_id].blank? && @@channel_stream_started_till_at[channel_id].present? wait_in_seconds = @@channel_stream_started_till_at[channel_id] - (Time.zone.now - local_delay_before_reconnect.seconds) diff --git a/app/models/job.rb b/app/models/job.rb index f73261564..b342f3e68 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -151,7 +151,7 @@ job.run(true) if last_run_at diff = time - last_run_at if diff.positive? - time = time + 10.minutes + time += 10.minutes end end day_map = { @@ -180,8 +180,8 @@ job.run(true) # start on next day at 00:00:00 time = day_to_check - day_to_check.sec.seconds - time = time - day_to_check.min.minutes - time = time - day_to_check.hour.hours + time -= day_to_check.min.minutes + time -= day_to_check.hour.hours next end @@ -202,7 +202,7 @@ job.run(true) # move to [0-5]0:00 time stamps day_to_check = day_to_check - day_to_check.min.minutes + min.minutes - day_to_check = day_to_check - day_to_check.sec.seconds + day_to_check -= day_to_check.sec.seconds # loop minutes till next full hour if day_to_check.min.nonzero? @@ -210,7 +210,7 @@ job.run(true) if minute_counter.nonzero? break if day_to_check.min.zero? - day_to_check = day_to_check + 10.minutes + day_to_check += 10.minutes end next if !timeplan['hours'][day_to_check.hour] && !timeplan['hours'][day_to_check.hour.to_s] next if !timeplan['minutes'][match_minutes(day_to_check.min)] && !timeplan['minutes'][match_minutes(day_to_check.min).to_s] diff --git a/app/models/transaction/notification.rb b/app/models/transaction/notification.rb index b87e4c88e..53dd4ffef 100644 --- a/app/models/transaction/notification.rb +++ b/app/models/transaction/notification.rb @@ -84,7 +84,7 @@ class Transaction::Notification if possible_recipients_additions.present? # join unique entries - possible_recipients = possible_recipients | possible_recipients_additions.to_a + possible_recipients |= possible_recipients_additions.to_a end already_checked_recipient_ids = {} diff --git a/lib/calendar_subscriptions.rb b/lib/calendar_subscriptions.rb index 23a65a829..0d74c8794 100644 --- a/lib/calendar_subscriptions.rb +++ b/lib/calendar_subscriptions.rb @@ -23,8 +23,8 @@ class CalendarSubscriptions def all events_data = [] @preferences.each_key do |object_name| - result = generic_call(object_name) - events_data = events_data + result + result = generic_call(object_name) + events_data += result end to_ical(events_data) end diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb index cc83cd5d3..bb9cc2020 100644 --- a/lib/core_ext/string.rb +++ b/lib/core_ext/string.rb @@ -162,7 +162,7 @@ class String elsif string.scan(%r{}ix) do link = $2 - counter = counter + 1 + counter += 1 link_list += "[#{counter}] #{link}\n" "[#{counter}] " end diff --git a/lib/report/base.rb b/lib/report/base.rb index 02ec76434..96a0ee3b2 100644 --- a/lib/report/base.rb +++ b/lib/report/base.rb @@ -243,7 +243,7 @@ class Report::Base # puts 'CT:' + ticket.created_at.to_s diff = timestamp - ticket.created_at #puts 'DIFF:' + diff.to_s - time_total = time_total + diff + time_total += diff tickets += 1 end if time_total.zero? || tickets.zero? diff --git a/lib/stats/ticket_waiting_time.rb b/lib/stats/ticket_waiting_time.rb index 012715b11..530a59599 100644 --- a/lib/stats/ticket_waiting_time.rb +++ b/lib/stats/ticket_waiting_time.rb @@ -74,7 +74,7 @@ class Stats::TicketWaitingTime end if count_articles.positive? - average_time = average_time / count_articles + average_time /= count_articles end average_time diff --git a/lib/twitter_sync.rb b/lib/twitter_sync.rb index a169b28ec..b8e3b48b1 100644 --- a/lib/twitter_sync.rb +++ b/lib/twitter_sync.rb @@ -551,7 +551,7 @@ create a tweet or direct message from an article def tweet_limit_reached(tweet, factor = 1) max_count = 120 - max_count = max_count * factor + max_count *= factor type_id = Ticket::Article::Type.lookup(name: 'twitter status').id created_at = Time.zone.now - 15.minutes created_count = Ticket::Article.where('created_at > ? AND type_id = ?', created_at, type_id).count diff --git a/lib/websocket_server.rb b/lib/websocket_server.rb index 94c7ea110..b6501ceb1 100644 --- a/lib/websocket_server.rb +++ b/lib/websocket_server.rb @@ -199,7 +199,7 @@ class WebsocketServer client_list.each_value do |client| next if client[:meta][:type] == 'websocket' - clients = clients + 1 + clients += 1 end log 'info', "Status: ajax clients: #{clients}" client_list.each do |client_id, client|