Corrected with rubocop cop 'Lint/UnusedBlockArgument'.
This commit is contained in:
parent
1ac1cf4184
commit
c282fd2b37
22 changed files with 55 additions and 58 deletions
|
@ -200,11 +200,6 @@ Style/RedundantBegin:
|
|||
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#begin-implicit'
|
||||
Enabled: false
|
||||
|
||||
Lint/UnusedBlockArgument:
|
||||
Description: 'Checks for unused block arguments.'
|
||||
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars'
|
||||
Enabled: false
|
||||
|
||||
Style/SignalException:
|
||||
Description: 'Checks for proper usage of fail and raise.'
|
||||
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
|
||||
|
|
|
@ -231,7 +231,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
|||
if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
|
||||
domains.push mail_exchangers[0][0]
|
||||
end
|
||||
provider_map.each {|provider, settings|
|
||||
provider_map.each {|_provider, settings|
|
||||
domains.each {|domain_to_check|
|
||||
|
||||
next if domain_to_check !~ /#{settings[:domain]}/i
|
||||
|
@ -616,7 +616,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
|||
end
|
||||
result = email_probe_outbound( params[:outbound], params[:meta][:email], subject )
|
||||
|
||||
(1..5).each {|loop|
|
||||
(1..5).each {
|
||||
sleep 10
|
||||
|
||||
# fetch mailbox
|
||||
|
@ -769,7 +769,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
|||
white_map = {
|
||||
'Recipient address rejected' => true,
|
||||
}
|
||||
white_map.each {|key, message|
|
||||
white_map.each {|key, _message|
|
||||
|
||||
next if e.message !~ /#{Regexp.escape(key)}/i
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ class LongPollingController < ApplicationController
|
|||
begin
|
||||
|
||||
# update last ping
|
||||
4.times {|loop|
|
||||
4.times {
|
||||
sleep 0.25
|
||||
}
|
||||
#sleep 1
|
||||
|
@ -128,7 +128,7 @@ class LongPollingController < ApplicationController
|
|||
render json: queue
|
||||
return
|
||||
end
|
||||
8.times {|loop|
|
||||
8.times {
|
||||
sleep 0.25
|
||||
}
|
||||
#sleep 2
|
||||
|
|
|
@ -761,7 +761,7 @@ log object update activity stream, if configured - will be executed automaticall
|
|||
end
|
||||
|
||||
log = false
|
||||
self.changes.each {|key, value|
|
||||
self.changes.each {|key, _value|
|
||||
|
||||
# do not log created_at and updated_at attributes
|
||||
next if ignore_attributes[key.to_sym] == true
|
||||
|
|
|
@ -335,7 +335,7 @@ class Channel::EmailParser
|
|||
}
|
||||
|
||||
# filter( channel, mail )
|
||||
filters.each {|prio, backend|
|
||||
filters.each {|_prio, backend|
|
||||
begin
|
||||
backend.run( channel, mail )
|
||||
rescue Exception => e
|
||||
|
@ -484,7 +484,7 @@ class Channel::EmailParser
|
|||
}
|
||||
|
||||
# filter( channel, mail )
|
||||
filters.each {|prio, backend|
|
||||
filters.each {|_prio, backend|
|
||||
begin
|
||||
backend.run( channel, mail, ticket, article, user )
|
||||
rescue Exception => e
|
||||
|
@ -529,7 +529,7 @@ class Channel::EmailParser
|
|||
def set_attributes_by_x_headers( item_object, header_name, mail )
|
||||
|
||||
# loop all x-zammad-hedaer-* headers
|
||||
item_object.attributes.each {|key, value|
|
||||
item_object.attributes.each {|key, _value|
|
||||
|
||||
# ignore read only attributes
|
||||
next if key == 'updated_at'
|
||||
|
|
|
@ -7,7 +7,7 @@ module Channel::Filter::Trusted
|
|||
|
||||
# check if trust x-headers
|
||||
if !channel[:trusted]
|
||||
mail.each {|key, value|
|
||||
mail.each {|key, _value|
|
||||
if key =~ /^x-zammad/i
|
||||
mail.delete(key)
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
|
|||
|
||||
# get uniq objects
|
||||
list_objects = get_uniq_changes(list)
|
||||
list_objects.each {|ticket_id, item|
|
||||
list_objects.each {|_ticket_id, item|
|
||||
|
||||
# send background job
|
||||
Delayed::Job.enqueue( Observer::Ticket::Notification::BackgroundJob.new( item ) )
|
||||
|
|
|
@ -25,8 +25,9 @@ class Setting < ApplicationModel
|
|||
# config lookups
|
||||
config.each { |key, value|
|
||||
next if value.class.to_s != 'String'
|
||||
config[key].gsub!( /\#\{config\.(.+?)\}/ ) { |s|
|
||||
s = config[$1].to_s
|
||||
|
||||
config[key].gsub!( /\#\{config\.(.+?)\}/ ) {
|
||||
config[$1].to_s
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ returns
|
|||
def self.generate
|
||||
|
||||
# generate number
|
||||
(1..50_000).each { |i|
|
||||
(1..50_000).each {
|
||||
number = adapter.generate
|
||||
ticket = Ticket.where( number: number ).first
|
||||
return number if !ticket
|
||||
|
|
|
@ -31,7 +31,7 @@ module Ticket::Number::Increment
|
|||
min_digs = min_digs.to_i - 1
|
||||
end
|
||||
fillup = Setting.get('system_id') || '1'
|
||||
( 1..100 ).each do |i|
|
||||
( 1..100 ).each do |_i|
|
||||
if ( fillup.length.to_i + counter_increment.to_s.length.to_i ) < min_digs.to_i
|
||||
fillup = fillup + '0'
|
||||
end
|
||||
|
|
|
@ -72,7 +72,7 @@ class String
|
|||
# find <a href=....> and replace it with [x]
|
||||
link_list = ''
|
||||
counter = 0
|
||||
string.gsub!( /<a\s.*?href=("|')(.+?)("|').*?>/ix ) { |item|
|
||||
string.gsub!( /<a\s.*?href=("|')(.+?)("|').*?>/ix ) {
|
||||
link = $2
|
||||
counter = counter + 1
|
||||
link_list += "[#{counter}] #{link}\n"
|
||||
|
@ -121,12 +121,12 @@ class String
|
|||
string.gsub!( ' ', ' ' )
|
||||
|
||||
# encode html entities like "–"
|
||||
string.gsub!( /(&\#(\d+);?)/x ) { |item|
|
||||
string.gsub!( /(&\#(\d+);?)/x ) {
|
||||
$2.chr
|
||||
}
|
||||
|
||||
# encode html entities like "d;"
|
||||
string.gsub!( /(&\#[xX]([0-9a-fA-F]+);?)/x ) { |item|
|
||||
string.gsub!( /(&\#[xX]([0-9a-fA-F]+);?)/x ) {
|
||||
chr_orig = $1
|
||||
hex = $2.hex
|
||||
if hex
|
||||
|
|
|
@ -14,7 +14,7 @@ module FillDB
|
|||
# organizations
|
||||
organization_pool = []
|
||||
if organizations && !organizations.zero?
|
||||
(1..organizations).each {|count|
|
||||
(1..organizations).each {
|
||||
organization = Organization.create( name: 'FillOrganization::' + rand(999_999).to_s, active: true )
|
||||
organization_pool.push organization
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ module FillDB
|
|||
if agents && !agents.zero?
|
||||
roles = Role.where( name: [ 'Agent'] )
|
||||
groups_all = Group.all
|
||||
(1..agents).each {|count|
|
||||
(1..agents).each {
|
||||
suffix = rand(99_999).to_s
|
||||
user = User.create_or_update(
|
||||
login: "filldb-agent-#{suffix}",
|
||||
|
@ -51,7 +51,7 @@ module FillDB
|
|||
if customers && !customers.zero?
|
||||
roles = Role.where( name: [ 'Customer'] )
|
||||
groups_all = Group.all
|
||||
(1..customers).each {|count|
|
||||
(1..customers).each {
|
||||
suffix = rand(99_999).to_s
|
||||
organization = nil
|
||||
if !organization_pool.empty? && rand(2) == 1
|
||||
|
@ -77,7 +77,7 @@ module FillDB
|
|||
group_pool = []
|
||||
if groups && !groups.zero?
|
||||
puts "1..#{groups}"
|
||||
(1..groups).each {|count|
|
||||
(1..groups).each {
|
||||
group = Group.create( name: 'FillGroup::' + rand(999_999).to_s, active: true )
|
||||
group_pool.push group
|
||||
Role.where(name: 'Agent').first.users.where(active: true).each {|user|
|
||||
|
@ -95,7 +95,7 @@ module FillDB
|
|||
priority_pool = Ticket::Priority.all
|
||||
state_pool = Ticket::State.all
|
||||
if tickets && !tickets.zero?
|
||||
(1..tickets).each {|count|
|
||||
(1..tickets).each {
|
||||
customer = customer_pool[ rand(customer_pool.length - 1) ]
|
||||
agent = agent_pool[ rand(agent_pool.length - 1) ]
|
||||
ticket = Ticket.create(
|
||||
|
|
|
@ -81,10 +81,11 @@ module NotificationFactory
|
|||
}
|
||||
|
||||
# translate
|
||||
data[:string].gsub!( /i18n\((|.+?)\)/ ) { |placeholder|
|
||||
data[:string].gsub!( /i18n\((|.+?)\)/ ) {
|
||||
string = $1
|
||||
locale = data[:locale] || 'en'
|
||||
placeholder = Translation.translate( locale, string )
|
||||
|
||||
Translation.translate( locale, string )
|
||||
}
|
||||
|
||||
data[:string]
|
||||
|
|
|
@ -36,8 +36,8 @@ class Sessions::Client
|
|||
user_id_last_run = user.id
|
||||
|
||||
# release old objects
|
||||
backend_pool.each {|pool|
|
||||
pool = nil
|
||||
backend_pool.collect! {
|
||||
nil
|
||||
}
|
||||
|
||||
# create new pool
|
||||
|
|
|
@ -2,7 +2,7 @@ $LOAD_PATH << './lib'
|
|||
require 'rubygems'
|
||||
|
||||
namespace :searchindex do
|
||||
task :drop, [:opts] => :environment do |t, args|
|
||||
task :drop, [:opts] => :environment do |_t, _args|
|
||||
|
||||
# drop indexes
|
||||
puts 'drop indexes...'
|
||||
|
@ -12,7 +12,7 @@ namespace :searchindex do
|
|||
|
||||
end
|
||||
|
||||
task :create, [:opts] => :environment do |t, args|
|
||||
task :create, [:opts] => :environment do |_t, _args|
|
||||
|
||||
# create indexes
|
||||
puts 'create indexes...'
|
||||
|
@ -39,7 +39,7 @@ namespace :searchindex do
|
|||
|
||||
end
|
||||
|
||||
task :reload, [:opts] => :environment do |t, args|
|
||||
task :reload, [:opts] => :environment do |_t, _args|
|
||||
|
||||
puts 'reload data...'
|
||||
User.search_index_reload
|
||||
|
@ -48,7 +48,7 @@ namespace :searchindex do
|
|||
|
||||
end
|
||||
|
||||
task :rebuild, [:opts] => :environment do |t, args|
|
||||
task :rebuild, [:opts] => :environment do |_t, _args|
|
||||
|
||||
Rake::Task['searchindex:drop'].execute
|
||||
Rake::Task['searchindex:create'].execute
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'rubygems'
|
|||
|
||||
namespace :test do
|
||||
desc 'Start browser tests'
|
||||
task :browser, [:opts] => :environment do |t, args|
|
||||
task :browser, [:opts] => :environment do |_t, args|
|
||||
|
||||
start = Time.now()
|
||||
if !args.opts
|
||||
|
|
|
@ -69,10 +69,10 @@ put working hours matrix and timezone in function, returns UTC working hours mat
|
|||
Sat: [],
|
||||
Sun: [],
|
||||
}
|
||||
(1..hours_to_shift).each {|count|
|
||||
(1..hours_to_shift).each {
|
||||
working_hours.each {|day, value|
|
||||
|
||||
next if !working_hours[day]
|
||||
next if !value
|
||||
|
||||
to_move = working_hours[day].shift
|
||||
if day == :Mon
|
||||
|
|
|
@ -243,14 +243,14 @@ EventMachine.run {
|
|||
|
||||
# websocket
|
||||
log 'notice', "Status: websocket clients: #{ @clients.size }"
|
||||
@clients.each { |client_id, client|
|
||||
@clients.each { |client_id, _client|
|
||||
log 'notice', 'working...', client_id
|
||||
}
|
||||
|
||||
# ajax
|
||||
client_list = Sessions.list
|
||||
clients = 0
|
||||
client_list.each {|client_id, client|
|
||||
client_list.each {|_client_id, client|
|
||||
next if client[:meta][:type] == 'websocket'
|
||||
clients = clients + 1
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ class TestCase < Test::Unit::TestCase
|
|||
|
||||
def teardown
|
||||
return if !@browsers
|
||||
@browsers.each { |hash, local_browser|
|
||||
@browsers.each { |_hash, local_browser|
|
||||
screenshot( browser: local_browser, comment: 'teardown' )
|
||||
browser_instance_close(local_browser)
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ class TestCase < Test::Unit::TestCase
|
|||
instance.find_elements( { css: 'a[href="#current_user"]' } )[0].click
|
||||
sleep 0.1
|
||||
instance.find_elements( { css: 'a[href="#logout"]' } )[0].click
|
||||
(1..6).each {|loop|
|
||||
(1..6).each {
|
||||
sleep 1
|
||||
login = instance.find_elements( { css: '#login' } )[0]
|
||||
if login
|
||||
|
@ -760,7 +760,7 @@ class TestCase < Test::Unit::TestCase
|
|||
end
|
||||
loops = (timeout).to_i * 2
|
||||
text = ''
|
||||
(1..loops).each { |loop|
|
||||
(1..loops).each {
|
||||
element = instance.find_elements( { css: params[:css] } )[0]
|
||||
if element #&& element.displayed?
|
||||
begin
|
||||
|
@ -820,7 +820,7 @@ wait untill text in selector disabppears
|
|||
end
|
||||
loops = (timeout).to_i
|
||||
text = ''
|
||||
(1..loops).each { |loop|
|
||||
(1..loops).each {
|
||||
element = instance.find_elements( { css: params[:css] } )[0]
|
||||
if !element #|| element.displayed?
|
||||
assert( true, 'not found' )
|
||||
|
@ -942,7 +942,7 @@ wait untill text in selector disabppears
|
|||
end
|
||||
|
||||
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
||||
(1..12).each {|loop|
|
||||
(1..12).each {
|
||||
element = instance.find_elements( { css: 'body' } )[0]
|
||||
text = element.text
|
||||
if text =~ /#{Regexp.quote(data[:name])}/
|
||||
|
@ -1063,7 +1063,7 @@ wait untill text in selector disabppears
|
|||
#instance.execute_script( '$(".content.active .newTicket form").submit();' )
|
||||
instance.find_elements( { css: '.active .newTicket button.submit' } )[0].click
|
||||
sleep 1
|
||||
(1..10).each {|loop|
|
||||
(1..10).each {
|
||||
if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/
|
||||
assert( true, 'ticket created' )
|
||||
sleep 2.5
|
||||
|
@ -1220,7 +1220,7 @@ wait untill text in selector disabppears
|
|||
|
||||
if data[:state] || data[:group] || data[:body]
|
||||
found = nil
|
||||
(1..5).each {|loop|
|
||||
(1..5).each {
|
||||
if !found
|
||||
begin
|
||||
text = instance.find_elements( { css: '.content.active .js-reset' } )[0].text
|
||||
|
@ -1246,7 +1246,7 @@ wait untill text in selector disabppears
|
|||
|
||||
instance.find_elements( { css: '.content.active button.js-submit' } )[0].click
|
||||
|
||||
(1..10).each {|loop|
|
||||
(1..10).each {
|
||||
begin
|
||||
text = instance.find_elements( { css: '.content.active .js-reset' } )[0].text
|
||||
if !text || text.empty?
|
||||
|
@ -1408,7 +1408,7 @@ wait untill text in selector disabppears
|
|||
#puts url.inspect
|
||||
#puts element.inspect
|
||||
}
|
||||
overviews.each {|url, value|
|
||||
overviews.each {|url, _value|
|
||||
count = instance.find_elements( { css: ".content.active .sidebar a[href=\"#{url}\"] .badge" } )[0].text
|
||||
overviews[url] = count.to_i
|
||||
}
|
||||
|
@ -1576,7 +1576,7 @@ wait untill text in selector disabppears
|
|||
element.clear
|
||||
element.send_keys( data[:first_response_time] )
|
||||
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
||||
(1..8).each {|loop|
|
||||
(1..8).each {
|
||||
element = instance.find_elements( { css: 'body' } )[0]
|
||||
text = element.text
|
||||
if text =~ /#{Regexp.quote(data[:name])}/
|
||||
|
@ -1623,7 +1623,7 @@ wait untill text in selector disabppears
|
|||
element.clear
|
||||
element.send_keys( data[:content] )
|
||||
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
||||
(1..8).each {|loop|
|
||||
(1..8).each {
|
||||
element = instance.find_elements( { css: 'body' } )[0]
|
||||
text = element.text
|
||||
if text =~ /#{Regexp.quote(data[:name])}/
|
||||
|
@ -1667,7 +1667,7 @@ wait untill text in selector disabppears
|
|||
element.clear
|
||||
element.send_keys( data[:body] )
|
||||
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
||||
(1..12).each {|loop|
|
||||
(1..12).each {
|
||||
element = instance.find_elements( { css: 'body' } )[0]
|
||||
text = element.text
|
||||
if text =~ /#{Regexp.quote(data[:name])}/
|
||||
|
@ -1719,7 +1719,7 @@ wait untill text in selector disabppears
|
|||
dropdown.select_by( :text, data[:signature])
|
||||
end
|
||||
instance.find_elements( { css: '.modal button.js-submit' } )[0].click
|
||||
(1..12).each {|loop|
|
||||
(1..12).each {
|
||||
element = instance.find_elements( { css: 'body' } )[0]
|
||||
text = element.text
|
||||
if text =~ /#{Regexp.quote(data[:name])}/
|
||||
|
|
|
@ -165,7 +165,7 @@ class TwitterTest < ActiveSupport::TestCase
|
|||
|
||||
# fetch check system account
|
||||
article = nil
|
||||
(1..4).each {|loop|
|
||||
(1..4).each {
|
||||
next if article
|
||||
sleep 25
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class ActiveSupport::TestCase
|
|||
return if Delayed::Job.all.empty?
|
||||
|
||||
Delayed::Job.where('failed_at != NULL').each {|job|
|
||||
assert( false, "not processable job #{jobs.inspect}" )
|
||||
assert( false, "not processable job #{job.inspect}" )
|
||||
}
|
||||
Delayed::Job.all.destroy_all
|
||||
end
|
||||
|
|
|
@ -300,7 +300,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
|||
if message['event'] == 'resetCollection'
|
||||
#puts "rc: "
|
||||
if message['data']
|
||||
message['data'].each {|key, value|
|
||||
message['data'].each {|key, _value|
|
||||
#puts "rc: #{key}"
|
||||
collections_result[key] = true
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
|||
end
|
||||
}
|
||||
#puts "c: #{collections_result.inspect}"
|
||||
collections_orig.each {|key, value|
|
||||
collections_orig.each {|key, _value|
|
||||
assert_equal( collections_orig[key], collections_result[key], "collection message for #{key} #{type}-check (client_id #{client_id})" )
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue