Browse Source

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

Thorsten Eckel 4 years ago
parent
commit
73f6a98e29

+ 3 - 3
Gemfile.lock

@@ -451,7 +451,7 @@ GEM
       rspec-support (~> 3.8.0)
       rspec-support (~> 3.8.0)
     rspec-support (3.8.0)
     rspec-support (3.8.0)
     rszr (0.5.2)
     rszr (0.5.2)
-    rubocop (0.87.0)
+    rubocop (0.88.0)
       parallel (~> 1.10)
       parallel (~> 1.10)
       parser (>= 2.7.1.1)
       parser (>= 2.7.1.1)
       rainbow (>= 2.2.2, < 4.0)
       rainbow (>= 2.2.2, < 4.0)
@@ -468,8 +468,8 @@ GEM
       activesupport (>= 4.2.0)
       activesupport (>= 4.2.0)
       rack (>= 1.1)
       rack (>= 1.1)
       rubocop (>= 0.82.0)
       rubocop (>= 0.82.0)
-    rubocop-rspec (1.41.0)
-      rubocop (>= 0.68.1)
+    rubocop-rspec (1.42.0)
+      rubocop (>= 0.87.0)
     ruby-progressbar (1.10.1)
     ruby-progressbar (1.10.1)
     ruby-saml (1.10.2)
     ruby-saml (1.10.2)
       nokogiri (>= 1.5.10)
       nokogiri (>= 1.5.10)

+ 5 - 4
app/controllers/monitoring_controller.rb

@@ -306,13 +306,14 @@ curl http://localhost/api/v1/monitoring/amount_check?token=XXX&periode=1h
     periode = params[:periode][0, params[:periode].length - 1]
     periode = params[:periode][0, params[:periode].length - 1]
     raise Exceptions::UnprocessableEntity, 'periode need to be an integer!' if periode.to_i.zero?
     raise Exceptions::UnprocessableEntity, 'periode need to be an integer!' if periode.to_i.zero?
 
 
-    if scale == 's'
+    case scale
+    when 's'
       created_at = Time.zone.now - periode.to_i.seconds
       created_at = Time.zone.now - periode.to_i.seconds
-    elsif scale == 'm'
+    when 'm'
       created_at = Time.zone.now - periode.to_i.minutes
       created_at = Time.zone.now - periode.to_i.minutes
-    elsif scale == 'h'
+    when 'h'
       created_at = Time.zone.now - periode.to_i.hours
       created_at = Time.zone.now - periode.to_i.hours
-    elsif scale == 'd'
+    when 'd'
       created_at = Time.zone.now - periode.to_i.days
       created_at = Time.zone.now - periode.to_i.days
     end
     end
 
 

+ 3 - 2
app/controllers/object_manager_attributes_controller.rb

@@ -85,9 +85,10 @@ class ObjectManagerAttributesController < ApplicationController
           if permitted[:data_option][:options][:true]
           if permitted[:data_option][:options][:true]
             permitted[:data_option][:options][true] = permitted[:data_option][:options].delete(:true)
             permitted[:data_option][:options][true] = permitted[:data_option][:options].delete(:true)
           end
           end
-          if permitted[:data_option][:default] == 'true'
+          case permitted[:data_option][:default]
+          when 'true'
             permitted[:data_option][:default] = true
             permitted[:data_option][:default] = true
-          elsif permitted[:data_option][:default] == 'false'
+          when 'false'
             permitted[:data_option][:default] = false
             permitted[:data_option][:default] = false
           end
           end
           # rubocop:enable Lint/BooleanSymbol
           # rubocop:enable Lint/BooleanSymbol

+ 5 - 4
app/controllers/reports_controller.rb

@@ -138,22 +138,23 @@ class ReportsController < ApplicationController
 
 
     metric = local_config[:metric][params[:metric].to_sym]
     metric = local_config[:metric][params[:metric].to_sym]
 
 
-    if params[:timeRange] == 'realtime'
+    case params[:timeRange]
+    when 'realtime'
       start_at = (Time.zone.now - 60.minutes)
       start_at = (Time.zone.now - 60.minutes)
       stop_at = Time.zone.now
       stop_at = Time.zone.now
       range = 'minute'
       range = 'minute'
-    elsif params[:timeRange] == 'day'
+    when 'day'
       date = Date.parse("#{params[:year]}-#{params[:month]}-#{params[:day]}").to_s
       date = Date.parse("#{params[:year]}-#{params[:month]}-#{params[:day]}").to_s
       start_at = Time.zone.parse("#{date}T00:00:00Z")
       start_at = Time.zone.parse("#{date}T00:00:00Z")
       stop_at = Time.zone.parse("#{date}T23:59:59Z")
       stop_at = Time.zone.parse("#{date}T23:59:59Z")
       range = 'hour'
       range = 'hour'
-    elsif params[:timeRange] == 'week'
+    when 'week'
       start_week_at = Date.commercial(params[:year].to_i, params[:week].to_i)
       start_week_at = Date.commercial(params[:year].to_i, params[:week].to_i)
       stop_week_at = start_week_at.end_of_week
       stop_week_at = start_week_at.end_of_week
       start_at = Time.zone.parse("#{start_week_at.year}-#{start_week_at.month}-#{start_week_at.day}T00:00:00Z")
       start_at = Time.zone.parse("#{start_week_at.year}-#{start_week_at.month}-#{start_week_at.day}T00:00:00Z")
       stop_at = Time.zone.parse("#{stop_week_at.year}-#{stop_week_at.month}-#{stop_week_at.day}T23:59:59Z")
       stop_at = Time.zone.parse("#{stop_week_at.year}-#{stop_week_at.month}-#{stop_week_at.day}T23:59:59Z")
       range = 'week'
       range = 'week'
-    elsif params[:timeRange] == 'month'
+    when 'month'
       start_at = Time.zone.parse("#{params[:year]}-#{params[:month]}-01T00:00:00Z")
       start_at = Time.zone.parse("#{params[:year]}-#{params[:month]}-01T00:00:00Z")
       stop_at = Time.zone.parse("#{params[:year]}-#{params[:month]}-#{start_at.end_of_month.day}T23:59:59Z")
       stop_at = Time.zone.parse("#{params[:year]}-#{params[:month]}-#{start_at.end_of_month.day}T23:59:59Z")
       range = 'day'
       range = 'day'

+ 7 - 10
app/helpers/knowledge_base_top_bar_helper.rb

@@ -12,16 +12,13 @@ module KnowledgeBaseTopBarHelper
   end
   end
 
 
   def kb_answer_top_bar_color(answer)
   def kb_answer_top_bar_color(answer)
-    case answer.can_be_published_aasm.current_state
-    when :draft
-      'yellow'
-    when :internal
-      'blue'
-    when :published
-      'green'
-    when :archived
-      'grey'
-    end
+    state_color_map = {
+      draft:     'yellow',
+      internal:  'blue',
+      published: 'green',
+      archived:  'grey',
+    }
+    state_color_map[answer.can_be_published_aasm.current_state]
   end
   end
 
 
   def kb_top_bar_tag(object)
   def kb_top_bar_tag(object)

+ 6 - 8
app/helpers/knowledge_base_visibility_class_helper.rb

@@ -13,14 +13,12 @@ module KnowledgeBaseVisibilityClassHelper
   end
   end
 
 
   def visiblity_class_suffix_can_be_published(object)
   def visiblity_class_suffix_can_be_published(object)
-    case object.can_be_published_aasm.current_state
-    when :internal
-      'internal'
-    when :archived
-      'archived'
-    when :draft
-      'not-published'
-    end
+    state_suffix_map = {
+      internal: 'internal',
+      archived: 'archived',
+      draft:    'not-published',
+    }
+    state_suffix_map[object.can_be_published_aasm.current_state]
   end
   end
 
 
   def visiblity_class_suffix_category(object)
   def visiblity_class_suffix_category(object)

+ 6 - 8
app/helpers/knowledge_base_visibility_note_helper.rb

@@ -19,14 +19,12 @@ module KnowledgeBaseVisibilityNoteHelper
   end
   end
 
 
   def visiblity_text_can_be_published(object)
   def visiblity_text_can_be_published(object)
-    case object.can_be_published_aasm.current_state
-    when :internal
-      'internal'
-    when :archived
-      'archived'
-    when :draft
-      'not published'
-    end
+    state_text_map = {
+      internal: 'internal',
+      archived: 'archived',
+      draft:    'not published',
+    }
+    state_text_map[object.can_be_published_aasm.current_state]
   end
   end
 
 
   def visiblity_text_category(object)
   def visiblity_text_category(object)

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

@@ -87,7 +87,7 @@ class Channel::EmailParser
       headers,
       headers,
       body,
       body,
       self.class.sender_attributes(headers),
       self.class.sender_attributes(headers),
-      raw: msg,
+      { raw: msg },
     ]
     ]
     message_attributes.reduce({}.with_indifferent_access, &:merge)
     message_attributes.reduce({}.with_indifferent_access, &:merge)
   end
   end

+ 3 - 2
app/models/channel/filter/database.rb

@@ -18,12 +18,13 @@ module Channel::Filter::Database
         value = mail[ key.downcase.to_sym ]
         value = mail[ key.downcase.to_sym ]
         match_rule = meta['value']
         match_rule = meta['value']
         min_one_rule_exists = true
         min_one_rule_exists = true
-        if meta[:operator] == 'contains not'
+        case meta[:operator]
+        when 'contains not'
           if value.present? && Channel::Filter::Match::EmailRegex.match(value: value, match_rule: match_rule)
           if value.present? && Channel::Filter::Match::EmailRegex.match(value: value, match_rule: match_rule)
             all_matches_ok = false
             all_matches_ok = false
             Rails.logger.info "  matching #{key.downcase}:'#{value}' on #{match_rule}, but shoud not"
             Rails.logger.info "  matching #{key.downcase}:'#{value}' on #{match_rule}, but shoud not"
           end
           end
-        elsif meta[:operator] == 'contains'
+        when 'contains'
           if value.blank? || !Channel::Filter::Match::EmailRegex.match(value: value, match_rule: match_rule)
           if value.blank? || !Channel::Filter::Match::EmailRegex.match(value: value, match_rule: match_rule)
             all_matches_ok = false
             all_matches_ok = false
             Rails.logger.info "  not matching #{key.downcase}:'#{value}' on #{match_rule}, but should"
             Rails.logger.info "  not matching #{key.downcase}:'#{value}' on #{match_rule}, but should"

+ 3 - 2
app/models/channel/filter/monitoring_base.rb

@@ -71,9 +71,10 @@ class Channel::Filter::MonitoringBase
 
 
     # possible event types https://mmonit.com/monit/documentation/#Setting-an-event-filter
     # possible event types https://mmonit.com/monit/documentation/#Setting-an-event-filter
     if result['state'].blank?
     if result['state'].blank?
-      result['state'] = if mail[:body].match?(/\s(done|recovery|succeeded|bytes\sok|packets\sok)\s/)
+      result['state'] = case mail[:body]
+                        when /\s(done|recovery|succeeded|bytes\sok|packets\sok)\s/
                           'OK'
                           'OK'
-                        elsif mail[:body].match?(/(instance\schanged\snot|Link\sup|Exists|Saturation\sok|Speed\sok)/)
+                        when /(instance\schanged\snot|Link\sup|Exists|Saturation\sok|Speed\sok)/
                           'OK'
                           'OK'
                         else
                         else
                           'CRITICAL'
                           'CRITICAL'

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