Browse Source

Maintenance: Updated rubocop(-* gems) to latest version (1.0.0).

Thorsten Eckel 4 years ago
parent
commit
0b9e6676f8

+ 8 - 7
Gemfile.lock

@@ -358,7 +358,7 @@ GEM
       omniauth-oauth2 (>= 1.4.0)
     openssl (2.1.2)
     parallel (1.19.2)
-    parser (2.7.1.5)
+    parser (2.7.2.0)
       ast (~> 2.4.1)
     pg (0.21.0)
     pluginator (1.5.0)
@@ -427,7 +427,7 @@ GEM
     rb-inotify (0.10.0)
       ffi (~> 1.0)
     rchardet (1.8.0)
-    regexp_parser (1.8.0)
+    regexp_parser (1.8.2)
     rest-client (2.0.2)
       http-cookie (>= 1.0.2, < 2.0)
       mime-types (>= 1.16, < 4.0)
@@ -452,16 +452,16 @@ GEM
       rspec-support (~> 3.9.0)
     rspec-support (3.9.3)
     rszr (0.5.2)
-    rubocop (0.92.0)
+    rubocop (0.93.1)
       parallel (~> 1.10)
       parser (>= 2.7.1.5)
       rainbow (>= 2.2.2, < 4.0)
-      regexp_parser (>= 1.7)
+      regexp_parser (>= 1.8)
       rexml
-      rubocop-ast (>= 0.5.0)
+      rubocop-ast (>= 0.6.0)
       ruby-progressbar (~> 1.7)
       unicode-display_width (>= 1.4.0, < 2.0)
-    rubocop-ast (0.5.0)
+    rubocop-ast (1.0.0)
       parser (>= 2.7.1.5)
     rubocop-performance (1.8.1)
       rubocop (>= 0.87.0)
@@ -470,8 +470,9 @@ GEM
       activesupport (>= 4.2.0)
       rack (>= 1.1)
       rubocop (>= 0.87.0)
-    rubocop-rspec (1.43.2)
+    rubocop-rspec (1.44.1)
       rubocop (~> 0.87)
+      rubocop-ast (>= 0.7.1)
     ruby-progressbar (1.10.1)
     ruby-saml (1.10.2)
       nokogiri (>= 1.5.10)

+ 1 - 1
app/controllers/monitoring_controller.rb

@@ -104,7 +104,7 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
     handler_attempts_map = {}
     failed_jobs.order(:created_at).limit(10).each do |job|
 
-      job_name = if job.class.name == 'Delayed::Backend::ActiveRecord::Job'.freeze && job.payload_object.respond_to?(:job_data)
+      job_name = if job.instance_of?(Delayed::Backend::ActiveRecord::Job) && job.payload_object.respond_to?(:job_data)
                    job.payload_object.job_data['job_class']
                  else
                    job.name

+ 1 - 1
app/controllers/tickets_controller.rb

@@ -80,7 +80,7 @@ class TicketsController < ApplicationController
   # POST /api/v1/tickets
   def create
     customer = {}
-    if params[:customer].class == ActionController::Parameters
+    if params[:customer].instance_of?(ActionController::Parameters)
       customer = params[:customer]
       params.delete(:customer)
     end

+ 1 - 1
app/models/avatar.rb

@@ -105,7 +105,7 @@ add avatar by url
 
     # fetch image based on http url
     if data[:url].present?
-      if data[:url].class == Tempfile
+      if data[:url].instance_of?(Tempfile)
         logger.info "Reading image from tempfile '#{data[:url].inspect}'"
         content = data[:url].read
         filename = data[:url].path

+ 2 - 2
app/models/channel/email_build.rb

@@ -88,7 +88,7 @@ generate email with S/MIME
 
       # place to add inline attachments related to html alternative
       attr[:attachments]&.each do |attachment|
-        next if attachment.class == Hash
+        next if attachment.instance_of?(Hash)
         next if attachment.preferences['Content-ID'].blank?
 
         attachment = Mail::Part.new do
@@ -107,7 +107,7 @@ generate email with S/MIME
 
     # add attachments
     attr[:attachments]&.each do |attachment|
-      if attachment.class == Hash
+      if attachment.instance_of?(Hash)
         attachment['content-id'] = nil
         mail.attachments[attachment[:filename]] = attachment
       else

+ 12 - 9
app/models/channel/email_parser.rb

@@ -678,11 +678,12 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
       filename = file.header[:content_disposition].try(:filename)
     rescue
       begin
-        if file.header[:content_disposition].to_s =~ /(filename|name)(\*{0,1})="(.+?)"/i
+        case file.header[:content_disposition].to_s
+        when /(filename|name)(\*{0,1})="(.+?)"/i
           filename = $3
-        elsif file.header[:content_disposition].to_s =~ /(filename|name)(\*{0,1})='(.+?)'/i
+        when /(filename|name)(\*{0,1})='(.+?)'/i
           filename = $3
-        elsif file.header[:content_disposition].to_s =~ /(filename|name)(\*{0,1})=(.+?);/i
+        when /(filename|name)(\*{0,1})=(.+?);/i
           filename = $3
         end
       rescue
@@ -691,11 +692,12 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
     end
 
     begin
-      if file.header[:content_disposition].to_s =~ /(filename|name)(\*{0,1})="(.+?)"/i
+      case file.header[:content_disposition].to_s
+      when /(filename|name)(\*{0,1})="(.+?)"/i
         filename = $3
-      elsif file.header[:content_disposition].to_s =~ /(filename|name)(\*{0,1})='(.+?)'/i
+      when /(filename|name)(\*{0,1})='(.+?)'/i
         filename = $3
-      elsif file.header[:content_disposition].to_s =~ /(filename|name)(\*{0,1})=(.+?);/i
+      when /(filename|name)(\*{0,1})=(.+?);/i
         filename = $3
       end
     rescue
@@ -704,11 +706,12 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
 
     # as fallback, use raw values
     if filename.blank?
-      if headers_store['Content-Disposition'].to_s =~ /(filename|name)(\*{0,1})="(.+?)"/i
+      case headers_store['Content-Disposition'].to_s
+      when /(filename|name)(\*{0,1})="(.+?)"/i
         filename = $3
-      elsif headers_store['Content-Disposition'].to_s =~ /(filename|name)(\*{0,1})='(.+?)'/i
+      when /(filename|name)(\*{0,1})='(.+?)'/i
         filename = $3
-      elsif headers_store['Content-Disposition'].to_s =~ /(filename|name)(\*{0,1})=(.+?);/i
+      when /(filename|name)(\*{0,1})=(.+?);/i
         filename = $3
       end
     end

+ 4 - 4
app/models/concerns/can_csv_import.rb

@@ -247,8 +247,8 @@ returns
         record_attributes_with_association_names = record.attributes_with_association_names
         records_attributes_with_association_names.push record_attributes_with_association_names
         record_attributes_with_association_names.each do |key, value|
-          next if value.class == ActiveSupport::HashWithIndifferentAccess
-          next if value.class == Hash
+          next if value.instance_of?(ActiveSupport::HashWithIndifferentAccess)
+          next if value.instance_of?(Hash)
           next if csv_attributes_ignored&.include?(key.to_sym)
           next if key.end_with?('_id')
           next if key.end_with?('_ids')
@@ -269,11 +269,11 @@ returns
         position = -1
         header.each do |key|
           position += 1
-          if record[key].class == ActiveSupport::TimeWithZone
+          if record[key].instance_of?(ActiveSupport::TimeWithZone)
             row.push record[key].iso8601
             next
           end
-          if record[key].class == Array
+          if record[key].instance_of?(Array)
             entry_count = -2
             record[key].each do |entry|
               entry_count += 1

+ 1 - 1
app/models/cti/log.rb

@@ -356,7 +356,7 @@ Cti::Log.process(
       user    = params['user']
       queue   = params['queue']
       call_id = params['callId'] || params['call_id']
-      if user.class == Array
+      if user.instance_of?(Array)
         user = user.join(', ')
       end
 

+ 1 - 1
app/models/observer/sla/ticket_rebuild_escalation.rb

@@ -25,7 +25,7 @@ class Observer::Sla::TicketRebuildEscalation < ActiveRecord::Observer
 
     # check if condition has changed
     changed = false
-    fields_to_check = if record.class == Sla
+    fields_to_check = if record.instance_of?(Sla)
                         %w[condition calendar_id first_response_time update_time solution_time]
                       else
                         %w[timezone business_hours default ical_url public_holidays]

+ 1 - 1
app/models/observer/ticket/article/communicate_twitter/background_job.rb

@@ -72,7 +72,7 @@ class Observer::Ticket::Article::CommunicateTwitter::BackgroundJob
       end
 
     # regular tweet
-    elsif tweet.class == Twitter::Tweet
+    elsif tweet.instance_of?(Twitter::Tweet)
       tweet_type = 'Tweet'
       article.from = "@#{tweet.user.screen_name}"
       if tweet.user_mentions

Some files were not shown because too many files changed in this diff