Skip to content

Commit

Permalink
Updated rubocop(-* gems) to latest version (0.88.0).
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsteneckel committed Jul 14, 2020
1 parent 829fc6e commit 73f6a98
Show file tree
Hide file tree
Showing 37 changed files with 385 additions and 340 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ GEM
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rszr (0.5.2)
rubocop (0.87.0)
rubocop (0.88.0)
parallel (~> 1.10)
parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0)
Expand All @@ -468,8 +468,8 @@ GEM
activesupport (>= 4.2.0)
rack (>= 1.1)
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-saml (1.10.2)
nokogiri (>= 1.5.10)
Expand Down
9 changes: 5 additions & 4 deletions app/controllers/monitoring_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,14 @@ def amount_check
periode = params[:periode][0, params[:periode].length - 1]
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
elsif scale == 'm'
when 'm'
created_at = Time.zone.now - periode.to_i.minutes
elsif scale == 'h'
when 'h'
created_at = Time.zone.now - periode.to_i.hours
elsif scale == 'd'
when 'd'
created_at = Time.zone.now - periode.to_i.days
end

Expand Down
5 changes: 3 additions & 2 deletions app/controllers/object_manager_attributes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ def permitted_params
if permitted[:data_option][:options][:true]
permitted[:data_option][:options][true] = permitted[:data_option][:options].delete(:true)
end
if permitted[:data_option][:default] == 'true'
case permitted[:data_option][:default]
when 'true'
permitted[:data_option][:default] = true
elsif permitted[:data_option][:default] == 'false'
when 'false'
permitted[:data_option][:default] = false
end
# rubocop:enable Lint/BooleanSymbol
Expand Down
9 changes: 5 additions & 4 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,23 @@ def params_all

metric = local_config[:metric][params[:metric].to_sym]

if params[:timeRange] == 'realtime'
case params[:timeRange]
when 'realtime'
start_at = (Time.zone.now - 60.minutes)
stop_at = Time.zone.now
range = 'minute'
elsif params[:timeRange] == 'day'
when 'day'
date = Date.parse("#{params[:year]}-#{params[:month]}-#{params[:day]}").to_s
start_at = Time.zone.parse("#{date}T00:00:00Z")
stop_at = Time.zone.parse("#{date}T23:59:59Z")
range = 'hour'
elsif params[:timeRange] == 'week'
when 'week'
start_week_at = Date.commercial(params[:year].to_i, params[:week].to_i)
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")
stop_at = Time.zone.parse("#{stop_week_at.year}-#{stop_week_at.month}-#{stop_week_at.day}T23:59:59Z")
range = 'week'
elsif params[:timeRange] == 'month'
when 'month'
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")
range = 'day'
Expand Down
17 changes: 7 additions & 10 deletions app/helpers/knowledge_base_top_bar_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ def kb_top_bar_color(object)
end

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

def kb_top_bar_tag(object)
Expand Down
14 changes: 6 additions & 8 deletions app/helpers/knowledge_base_visibility_class_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ def visibility_class_name(object)
end

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

def visiblity_class_suffix_category(object)
Expand Down
14 changes: 6 additions & 8 deletions app/helpers/knowledge_base_visibility_note_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ def visibility_text(object)
end

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

def visiblity_text_category(object)
Expand Down
2 changes: 1 addition & 1 deletion app/models/channel/email_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def parse(msg)
headers,
body,
self.class.sender_attributes(headers),
raw: msg,
{ raw: msg },
]
message_attributes.reduce({}.with_indifferent_access, &:merge)
end
Expand Down
5 changes: 3 additions & 2 deletions app/models/channel/filter/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ def self.run(_channel, mail)
value = mail[ key.downcase.to_sym ]
match_rule = meta['value']
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)
all_matches_ok = false
Rails.logger.info " matching #{key.downcase}:'#{value}' on #{match_rule}, but shoud not"
end
elsif meta[:operator] == 'contains'
when 'contains'
if value.blank? || !Channel::Filter::Match::EmailRegex.match(value: value, match_rule: match_rule)
all_matches_ok = false
Rails.logger.info " not matching #{key.downcase}:'#{value}' on #{match_rule}, but should"
Expand Down
5 changes: 3 additions & 2 deletions app/models/channel/filter/monitoring_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ def self.run(_channel, mail)

# possible event types https://mmonit.com/monit/documentation/#Setting-an-event-filter
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'
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'
else
'CRITICAL'
Expand Down
5 changes: 3 additions & 2 deletions app/models/chat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def customer_state(session_id = nil)
chat_session = Chat::Session.find_by(session_id: session_id, state: %w[waiting running])

if chat_session
if chat_session.state == 'running'
case chat_session.state
when 'running'
user = chat_session.agent_user
if user

Expand All @@ -80,7 +81,7 @@ def customer_state(session_id = nil)
}
end
end
elsif chat_session.state == 'waiting'
when 'waiting'
return {
state: 'reconnect',
position: chat_session.position,
Expand Down
18 changes: 10 additions & 8 deletions app/models/cti/driver/placetel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ def config
def mapping(params)

# do event mapping
if params['event'] == 'IncomingCall'
case params['event']
when 'IncomingCall'
params['direction'] = 'in'
params['event'] = 'newCall'
elsif params['event'] == 'HungUp'
when 'HungUp'
params['event'] = 'hangup'
elsif params['event'] == 'OutgoingCall'
when 'OutgoingCall'
params['direction'] = 'out'
params['event'] = 'newCall'
elsif params['event'] == 'CallAccepted'
when 'CallAccepted'
params['event'] = 'answer'
end

Expand All @@ -41,13 +42,14 @@ def mapping(params)
end

# do case mapping
if params['type'] == 'missed'
case params['type']
when 'missed'
params['cause'] = 'cancel'
elsif params['type'] == 'voicemail'
when 'voicemail'
params['cause'] = 'voicemail'
elsif params['type'] == 'blocked'
when 'blocked'
params['cause'] = 'blocked'
elsif params['type'] == 'accepted'
when 'accepted'
params['cause'] = 'normalClearing'
end

Expand Down
27 changes: 15 additions & 12 deletions app/models/object_manager/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -677,37 +677,39 @@ def self.migration_execute(send_event = true)
end

data_type = nil
if attribute.data_type.match?(/^input|select|tree_select|richtext|textarea|checkbox$/)
case attribute.data_type
when /^input|select|tree_select|richtext|textarea|checkbox$/
data_type = :string
elsif attribute.data_type.match?(/^integer|user_autocompletion$/)
when /^integer|user_autocompletion$/
data_type = :integer
elsif attribute.data_type.match?(/^boolean|active$/)
when /^boolean|active$/
data_type = :boolean
elsif attribute.data_type.match?(/^datetime$/)
when /^datetime$/
data_type = :datetime
elsif attribute.data_type.match?(/^date$/)
when /^date$/
data_type = :date
end

# change field
if model.column_names.include?(attribute.name)
if attribute.data_type.match?(/^input|select|tree_select|richtext|textarea|checkbox$/)
case attribute.data_type
when /^input|select|tree_select|richtext|textarea|checkbox$/
ActiveRecord::Migration.change_column(
model.table_name,
attribute.name,
data_type,
limit: attribute.data_option[:maxlength],
null: true
)
elsif attribute.data_type.match?(/^integer|user_autocompletion|datetime|date$/)
when /^integer|user_autocompletion|datetime|date$/
ActiveRecord::Migration.change_column(
model.table_name,
attribute.name,
data_type,
default: attribute.data_option[:default],
null: true
)
elsif attribute.data_type.match?(/^boolean|active$/)
when /^boolean|active$/
ActiveRecord::Migration.change_column(
model.table_name,
attribute.name,
Expand All @@ -730,31 +732,32 @@ def self.migration_execute(send_event = true)
end

# create field
if attribute.data_type.match?(/^input|select|tree_select|richtext|textarea|checkbox$/)
case attribute.data_type
when /^input|select|tree_select|richtext|textarea|checkbox$/
ActiveRecord::Migration.add_column(
model.table_name,
attribute.name,
data_type,
limit: attribute.data_option[:maxlength],
null: true
)
elsif attribute.data_type.match?(/^integer|user_autocompletion$/)
when /^integer|user_autocompletion$/
ActiveRecord::Migration.add_column(
model.table_name,
attribute.name,
data_type,
default: attribute.data_option[:default],
null: true
)
elsif attribute.data_type.match?(/^boolean|active$/)
when /^boolean|active$/
ActiveRecord::Migration.add_column(
model.table_name,
attribute.name,
data_type,
default: attribute.data_option[:default],
null: true
)
elsif attribute.data_type.match?(/^datetime|date$/)
when /^datetime|date$/
ActiveRecord::Migration.add_column(
model.table_name,
attribute.name,
Expand Down
5 changes: 3 additions & 2 deletions app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,10 @@ def self._get_bin(name, version)
end

def self._read_file(file, fullpath = false)
location = if fullpath == false
location = case fullpath
when false
@@root + '/' + file
elsif fullpath == true
when true
file
else
fullpath + '/' + file
Expand Down
Loading

0 comments on commit 73f6a98

Please sign in to comment.