Browse Source

Updated rubocop(-* gems) to latest version (0.84.0).

Thorsten Eckel 4 years ago
parent
commit
8690916936

+ 5 - 2
Gemfile.lock

@@ -448,14 +448,17 @@ GEM
       rspec-support (~> 3.8.0)
     rspec-support (3.8.0)
     rszr (0.5.2)
-    rubocop (0.83.0)
+    rubocop (0.84.0)
       parallel (~> 1.10)
       parser (>= 2.7.0.1)
       rainbow (>= 2.2.2, < 4.0)
       rexml
+      rubocop-ast (>= 0.0.3)
       ruby-progressbar (~> 1.7)
       unicode-display_width (>= 1.4.0, < 2.0)
-    rubocop-performance (1.5.2)
+    rubocop-ast (0.0.3)
+      parser (>= 2.7.0.1)
+    rubocop-performance (1.6.0)
       rubocop (>= 0.71.0)
     rubocop-rails (2.5.2)
       activesupport

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

@@ -638,8 +638,8 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
 
     # cleanup content id, <> will be added automatically later
     if headers_store['Content-ID']
-      headers_store['Content-ID'].gsub!(/^</, '')
-      headers_store['Content-ID'].gsub!(/>$/, '')
+      headers_store['Content-ID'].delete_prefix!('<')
+      headers_store['Content-ID'].delete_suffix!('>')
     end
 
     # get filename from content-disposition

+ 3 - 3
app/models/channel/filter/identify_sender.rb

@@ -188,8 +188,8 @@ module Channel::Filter::IdentifySender
 
     string.strip
           .delete('"')
-          .gsub(/^'/, '')
-          .gsub(/'$/, '')
+          .delete_prefix("'")
+          .delete_suffix("'")
           .gsub(/.+?\s\(.+?\)$/, '')
   end
 
@@ -204,7 +204,7 @@ module Channel::Filter::IdentifySender
           .sub(/^<|>$/, '')        # see https://github.com/zammad/zammad/issues/2254
           .sub(/\A'(.*)'\z/, '\1') # see https://github.com/zammad/zammad/issues/2154
           .gsub(/\s/, '')          # see https://github.com/zammad/zammad/issues/2198
-          .gsub(/\.\z/, '')
+          .delete_suffix('.')
   end
 
 end

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

@@ -247,8 +247,8 @@ returns
           next if value.class == ActiveSupport::HashWithIndifferentAccess
           next if value.class == Hash
           next if csv_attributes_ignored&.include?(key.to_sym)
-          next if key.match?(/_id$/)
-          next if key.match?(/_ids$/)
+          next if key.end_with?('_id')
+          next if key.end_with?('_ids')
           next if key == 'created_by'
           next if key == 'updated_by'
           next if key == 'created_at'

+ 1 - 1
app/models/knowledge_base.rb

@@ -54,7 +54,7 @@ class KnowledgeBase < ApplicationModel
 
     data[:KnowledgeBase].each do |_, elem|
       elem.delete_if do |k, _|
-        k.match?(/_ids$/)
+        k.end_with?('_ids')
       end
     end
 

+ 1 - 1
app/models/package.rb

@@ -170,7 +170,7 @@ link files + execute migration up
       file = file.sub(%r{^/}, '')
 
       # ignore files
-      if file.match?(/^README/)
+      if file.start_with?('README')
         logger.info "NOTICE: Ignore #{file}"
         next
       end

+ 1 - 1
app/models/package/migration.rb

@@ -37,7 +37,7 @@ class Package::Migration < ApplicationModel
     end
 
     migrations_existing.each do |migration|
-      next if !migration.match?(/\.rb$/)
+      next if !migration.end_with?('.rb')
 
       version = nil
       name    = nil

+ 3 - 3
app/models/ticket.rb

@@ -582,7 +582,7 @@ condition example
       # validate value / allow blank but only if pre_condition exists and is not specific
       if !selector.key?('value') ||
          (selector['value'].class == Array && selector['value'].respond_to?(:blank?) && selector['value'].blank?) ||
-         (selector['operator'] =~ /^contains/ && selector['value'].respond_to?(:blank?) && selector['value'].blank?)
+         (selector['operator'].start_with?('contains') && selector['value'].respond_to?(:blank?) && selector['value'].blank?)
         return nil if selector['pre_condition'].nil?
         return nil if selector['pre_condition'].respond_to?(:blank?) && selector['pre_condition'].blank?
         return nil if selector['pre_condition'] == 'specific'
@@ -938,9 +938,9 @@ perform changes on ticket
 
       # lookup pre_condition
       if value['pre_condition']
-        if value['pre_condition'].match?(/^not_set/)
+        if value['pre_condition'].start_with?('not_set')
           value['value'] = 1
-        elsif value['pre_condition'].match?(/^current_user\./)
+        elsif value['pre_condition'].start_with?('current_user.')
           raise 'Unable to use current_user, got no current_user_id for ticket.perform_changes' if !current_user_id
 
           value['value'] = current_user_id

+ 1 - 1
app/models/user.rb

@@ -422,7 +422,7 @@ returns
   def permissions?(key)
     Array(key).each do |local_key|
       list = []
-      if local_key.match?(/\.\*$/)
+      if local_key.end_with?('.*')
         local_key = local_key.sub('.*', '.%')
         permissions = ::Permission.with_parents(local_key)
         list = ::Permission.select('preferences').joins(:roles).where('roles.id IN (?) AND roles.active = ? AND (permissions.name IN (?) OR permissions.name LIKE ?) AND permissions.active = ?', role_ids, true, permissions, local_key, true).pluck(:preferences)

+ 1 - 1
lib/core_ext/active_record/connection_adapters/postgresql/schema_statements.rb

@@ -13,7 +13,7 @@ module ActiveRecord
           if column_names.class == Array
             index_columns_new = []
             column_names.each do |i|
-              if i =~ /^"(name|login|locale|alias)"$/ || i =~ /name"$/
+              if i =~ /^"(name|login|locale|alias)"$/ || i.end_with?('name"')
                 index_columns_new.push "LOWER(#{i})"
               else
                 index_columns_new.push i

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