diff --git a/.rubocop.yml b/.rubocop.yml
index 603d81ab4..96629d76c 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -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'
diff --git a/app/controllers/getting_started_controller.rb b/app/controllers/getting_started_controller.rb
index 07f991daf..7f77410cb 100644
--- a/app/controllers/getting_started_controller.rb
+++ b/app/controllers/getting_started_controller.rb
@@ -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
diff --git a/app/controllers/long_polling_controller.rb b/app/controllers/long_polling_controller.rb
index 302d49fdd..c09c2cd18 100644
--- a/app/controllers/long_polling_controller.rb
+++ b/app/controllers/long_polling_controller.rb
@@ -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
diff --git a/app/models/application_model.rb b/app/models/application_model.rb
index 673f42c35..de075ac36 100644
--- a/app/models/application_model.rb
+++ b/app/models/application_model.rb
@@ -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
diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb
index f95cab235..f03a6de8c 100644
--- a/app/models/channel/email_parser.rb
+++ b/app/models/channel/email_parser.rb
@@ -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'
diff --git a/app/models/channel/filter/trusted.rb b/app/models/channel/filter/trusted.rb
index e37cb12bb..3f6e84f14 100644
--- a/app/models/channel/filter/trusted.rb
+++ b/app/models/channel/filter/trusted.rb
@@ -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
diff --git a/app/models/observer/ticket/notification.rb b/app/models/observer/ticket/notification.rb
index 29092b912..c0ff9b67f 100644
--- a/app/models/observer/ticket/notification.rb
+++ b/app/models/observer/ticket/notification.rb
@@ -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 ) )
diff --git a/app/models/setting.rb b/app/models/setting.rb
index 7854ef336..e81a24111 100644
--- a/app/models/setting.rb
+++ b/app/models/setting.rb
@@ -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
}
}
diff --git a/app/models/ticket/number.rb b/app/models/ticket/number.rb
index 139fe691e..8c0b64b6a 100644
--- a/app/models/ticket/number.rb
+++ b/app/models/ticket/number.rb
@@ -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
diff --git a/app/models/ticket/number/increment.rb b/app/models/ticket/number/increment.rb
index a3237c7b4..2a3d241b7 100644
--- a/app/models/ticket/number/increment.rb
+++ b/app/models/ticket/number/increment.rb
@@ -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
diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb
index 713322736..ad04ae723 100644
--- a/lib/core_ext/string.rb
+++ b/lib/core_ext/string.rb
@@ -72,7 +72,7 @@ class String
# find and replace it with [x]
link_list = ''
counter = 0
- string.gsub!( //ix ) { |item|
+ string.gsub!( //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
diff --git a/lib/fill_db.rb b/lib/fill_db.rb
index e3af2bdca..2ac9401b7 100644
--- a/lib/fill_db.rb
+++ b/lib/fill_db.rb
@@ -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(
diff --git a/lib/notification_factory.rb b/lib/notification_factory.rb
index 5352b5849..f982b635e 100644
--- a/lib/notification_factory.rb
+++ b/lib/notification_factory.rb
@@ -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]
diff --git a/lib/sessions/client.rb b/lib/sessions/client.rb
index 0fe2657c6..dc6aef845 100644
--- a/lib/sessions/client.rb
+++ b/lib/sessions/client.rb
@@ -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
diff --git a/lib/tasks/search_index_es.rake b/lib/tasks/search_index_es.rake
index e05d1bf9e..0d39075ea 100644
--- a/lib/tasks/search_index_es.rake
+++ b/lib/tasks/search_index_es.rake
@@ -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
diff --git a/lib/tasks/test_browser.rake b/lib/tasks/test_browser.rake
index e0bc526de..50d56df85 100644
--- a/lib/tasks/test_browser.rake
+++ b/lib/tasks/test_browser.rake
@@ -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
diff --git a/lib/time_calculation.rb b/lib/time_calculation.rb
index 8e375b154..d306258db 100644
--- a/lib/time_calculation.rb
+++ b/lib/time_calculation.rb
@@ -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
diff --git a/script/websocket-server.rb b/script/websocket-server.rb
index 029213d1f..87454828d 100755
--- a/script/websocket-server.rb
+++ b/script/websocket-server.rb
@@ -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
}
diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb
index e0f961f9a..ecd9bd578 100644
--- a/test/browser_test_helper.rb
+++ b/test/browser_test_helper.rb
@@ -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])}/
diff --git a/test/integration/twitter_test.rb b/test/integration/twitter_test.rb
index 54013abf4..100b665d4 100644
--- a/test/integration/twitter_test.rb
+++ b/test/integration/twitter_test.rb
@@ -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
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 3aae9664a..d170f3842 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -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
diff --git a/test/unit/session_enhanced_test.rb b/test/unit/session_enhanced_test.rb
index 9674e1449..6fe37ac4c 100644
--- a/test/unit/session_enhanced_test.rb
+++ b/test/unit/session_enhanced_test.rb
@@ -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