diff --git a/app/controllers/form_controller.rb b/app/controllers/form_controller.rb index 48a49e445..6c12229a4 100644 --- a/app/controllers/form_controller.rb +++ b/app/controllers/form_controller.rb @@ -146,7 +146,7 @@ class FormController < ApplicationController # we don't wann to tell what the cause for the authorization error is # so we capture the exception and raise an anonymized one - def authorize!(*) + def authorize!(...) super rescue Pundit::NotAuthorizedError raise Exceptions::Forbidden diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 30a1ca2f2..4d18d507c 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -95,8 +95,9 @@ class TicketsController < ApplicationController clean_params[:customer_id] = current_user.id end - # try to create customer if needed - if clean_params[:customer_id].present? && clean_params[:customer_id] =~ %r{^guess:(.+?)$} + # The parameter :customer_id is 'abused' in cases where it is not an integer, but a string like + # 'guess:customers.email@domain.com' which implies that the customer should be looked up. + if clean_params[:customer_id].is_a?(String) && clean_params[:customer_id] =~ %r{^guess:(.+?)$} email_address = $1 email_address_validation = EmailAddressValidation.new(email_address) if !email_address_validation.valid_format? diff --git a/app/jobs/application_job/has_custom_logging.rb b/app/jobs/application_job/has_custom_logging.rb index e5c54806c..fe0670425 100644 --- a/app/jobs/application_job/has_custom_logging.rb +++ b/app/jobs/application_job/has_custom_logging.rb @@ -13,7 +13,7 @@ class ApplicationJob class LogSubscriber < ActiveJob::Logging::LogSubscriber # ATTENTION: Uncomment this line to enable info logging again - def info(*); end + def info(...); end def enqueue(event) super if job_enqueued?(event) diff --git a/app/models/application_model/can_creates_and_updates.rb b/app/models/application_model/can_creates_and_updates.rb index a3fe2dedb..e6b0c7931 100644 --- a/app/models/application_model/can_creates_and_updates.rb +++ b/app/models/application_model/can_creates_and_updates.rb @@ -41,7 +41,7 @@ returns raise ArgumentError, 'Need name, login, email or locale for create_or_update()' if attr.nil? - record = case_sensitive_find_by(data.slice(attr)) + record = case_sensitive_find_by(**data.slice(attr)) record.nil? ? create(data) : record.tap { |r| r.update(data) } end diff --git a/app/models/channel/driver/null.rb b/app/models/channel/driver/null.rb index f603ce915..21954aa39 100644 --- a/app/models/channel/driver/null.rb +++ b/app/models/channel/driver/null.rb @@ -5,7 +5,7 @@ class Channel::Driver::Null false end - def fetch(*) + def fetch(...) { result: 'ok', fetched: 0, diff --git a/app/models/concerns/can_csv_import.rb b/app/models/concerns/can_csv_import.rb index e5a08fa73..91f5c735b 100644 --- a/app/models/concerns/can_csv_import.rb +++ b/app/models/concerns/can_csv_import.rb @@ -59,7 +59,7 @@ returns raise Exceptions::UnprocessableEntity, "Unable to read file '#{data[:file]}': #{e.inspect}" end - header, *rows = ::CSV.parse(data[:string], data[:parse_params]) + header, *rows = ::CSV.parse(data[:string], **data[:parse_params]) header&.each do |column| column.try(:strip!) @@ -117,7 +117,7 @@ returns record = (lookup_keys & attributes.keys).lazy.map do |lookup_key| params = attributes.slice(lookup_key) params.transform_values!(&:downcase) if lookup_key.in?(%i[email login]) - lookup(params) + lookup(**params) end.detect(&:present?) if record&.in?(records) @@ -296,7 +296,7 @@ returns end rows_to_add = [] end - ::CSV.generate(params) do |csv| + ::CSV.generate(**params) do |csv| csv << header rows.each do |row| csv << row diff --git a/app/models/object_manager/attribute/validation/backend.rb b/app/models/object_manager/attribute/validation/backend.rb index 90c73bfeb..46768be21 100644 --- a/app/models/object_manager/attribute/validation/backend.rb +++ b/app/models/object_manager/attribute/validation/backend.rb @@ -1,8 +1,8 @@ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ class ObjectManager::Attribute::Validation::Backend - def self.validate(*args) - new(*args).validate + def self.validate(...) + new(...).validate end attr_reader :record, :attribute, :value, :previous_value diff --git a/lib/core_ext/active_record/connection_adapters/postgresql/schema_statements.rb b/lib/core_ext/active_record/connection_adapters/postgresql/schema_statements.rb index 3bc66336d..53540192a 100644 --- a/lib/core_ext/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/lib/core_ext/active_record/connection_adapters/postgresql/schema_statements.rb @@ -9,7 +9,7 @@ module ActiveRecord # on postgres create lower indices to support case-insensitive where conditions def add_index(table_name, column_name, options = {}) #:nodoc: - index_name, index_type, index_columns, index_options, index_algorithm, index_using = add_index_options(table_name, column_name, options) + index_name, index_type, index_columns, index_options, index_algorithm, index_using = add_index_options(table_name, column_name, **options) column_names = index_columns.split ', ' if column_names.instance_of?(Array) diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb index 7e9929fa8..cc83cd5d3 100644 --- a/lib/core_ext/string.rb +++ b/lib/core_ext/string.rb @@ -470,8 +470,8 @@ class String # * `:output_to_binary` returns an ASCII-8BIT-encoded string. # * `:read_as_sanitized_binary` returns a UTF-8-encoded string with all # invalid byte sequences replaced with "?" characters. - def utf8_encode(**options) - dup.utf8_encode!(options) + def utf8_encode(...) + dup.utf8_encode!(...) end def utf8_encode!(**options) diff --git a/lib/search_index_backend.rb b/lib/search_index_backend.rb index ba75436f0..584dc494b 100644 --- a/lib/search_index_backend.rb +++ b/lib/search_index_backend.rb @@ -946,7 +946,7 @@ helper method for making HTTP calls and raising error if response was not succes =end def self.make_request_and_validate(url, **args) - response = make_request(url, args) + response = make_request(url, **args) return true if response.success? diff --git a/lib/sequencer.rb b/lib/sequencer.rb index c384e7854..4b7c62f27 100644 --- a/lib/sequencer.rb +++ b/lib/sequencer.rb @@ -20,8 +20,8 @@ class Sequencer # ) # # @return [Hash{Symbol => Object}] the final result state attributes and values - def self.process(sequence, *args) - new(sequence, *args).process + def self.process(sequence, **args) + new(sequence, **args).process end # Provides the log level definition for the requested Sequencer component. diff --git a/lib/sequencer/unit/import/freshdesk/request/conversation.rb b/lib/sequencer/unit/import/freshdesk/request/conversation.rb index 07e543a4b..b899f5911 100644 --- a/lib/sequencer/unit/import/freshdesk/request/conversation.rb +++ b/lib/sequencer/unit/import/freshdesk/request/conversation.rb @@ -8,7 +8,7 @@ class Sequencer class Conversation < Sequencer::Unit::Import::Freshdesk::Request::Generic attr_reader :ticket - def initialize(*) + def initialize(...) super @ticket = request_params.delete(:ticket) end diff --git a/lib/sequencer/unit/import/freshdesk/request/time_entry.rb b/lib/sequencer/unit/import/freshdesk/request/time_entry.rb index 9da00014e..6dbd22119 100644 --- a/lib/sequencer/unit/import/freshdesk/request/time_entry.rb +++ b/lib/sequencer/unit/import/freshdesk/request/time_entry.rb @@ -8,7 +8,7 @@ class Sequencer class TimeEntry < Sequencer::Unit::Import::Freshdesk::Request::Generic attr_reader :ticket - def initialize(*) + def initialize(...) super @ticket = request_params.delete(:ticket) end diff --git a/spec/lib/ldap_spec.rb b/spec/lib/ldap_spec.rb index 3abca51b5..ec4a7d9b1 100644 --- a/spec/lib/ldap_spec.rb +++ b/spec/lib/ldap_spec.rb @@ -263,7 +263,7 @@ RSpec.describe Ldap do allow(mocked_ldap).to receive(:search).with(include(expected)).and_yield(yield_entry).and_return(true) check_entry = nil - instance.search(filter, additional) { |entry| check_entry = entry } + instance.search(filter, **additional) { |entry| check_entry = entry } expect(check_entry).to eq(yield_entry) end @@ -283,7 +283,7 @@ RSpec.describe Ldap do allow(mocked_ldap).to receive(:search).with(include(expected)).and_yield(yield_entry).and_return(true) check_entry = nil - instance.search(filter, additional) { |entry| check_entry = entry } + instance.search(filter, **additional) { |entry| check_entry = entry } expect(check_entry).to eq(yield_entry) end diff --git a/spec/models/application_model/can_lookup_examples.rb b/spec/models/application_model/can_lookup_examples.rb index e25df9ce8..5c6b5b9c5 100644 --- a/spec/models/application_model/can_lookup_examples.rb +++ b/spec/models/application_model/can_lookup_examples.rb @@ -93,7 +93,7 @@ RSpec.shared_examples 'ApplicationModel::CanLookup' do expect { instance.update(attribute => new_attribute_val) } .to change { described_class.cache_get(old_attribute_val) }.to(nil) - expect { described_class.lookup({ attribute => instance.send(attribute) }) } + expect { described_class.lookup(attribute => instance.send(attribute)) } .to change { described_class.cache_get(new_attribute_val) }.to(instance) end end diff --git a/spec/models/channel_spec.rb b/spec/models/channel_spec.rb index 6fa1e25ed..281916795 100644 --- a/spec/models/channel_spec.rb +++ b/spec/models/channel_spec.rb @@ -23,11 +23,11 @@ RSpec.describe Channel, type: :model do let(:failing_adapter_class) do Class.new(Channel::Driver::Null) do - def fetchable?(*) + def fetchable?(...) true end - def fetch(*) + def fetch(...) raise 'some error' end end @@ -35,7 +35,7 @@ RSpec.describe Channel, type: :model do let(:dummy_adapter_class) do Class.new(Channel::Driver::Null) do - def fetchable?(*) + def fetchable?(...) true end end diff --git a/spec/support/capybara/authenticated.rb b/spec/support/capybara/authenticated.rb index cfbbc0e49..50046f9d5 100644 --- a/spec/support/capybara/authenticated.rb +++ b/spec/support/capybara/authenticated.rb @@ -18,6 +18,6 @@ RSpec.configure do |config| authenticated = example.metadata.fetch(:authenticated_as, true) credentials = authenticated_as_get_user(authenticated, return_type: :credentials) - login(credentials) if credentials + login(**credentials) if credentials end end diff --git a/spec/support/capybara/custom_extensions.rb b/spec/support/capybara/custom_extensions.rb index a3d8785ba..52f643a00 100644 --- a/spec/support/capybara/custom_extensions.rb +++ b/spec/support/capybara/custom_extensions.rb @@ -36,43 +36,43 @@ class Capybara::Node::Element end module ZammadCapybarActionDelegator - def select(*) + def select(...) super.tap do await_empty_ajax_queue end end - def click(*) + def click(...) super.tap do await_empty_ajax_queue end end - def click_on(*) + def click_on(...) super.tap do await_empty_ajax_queue end end - def click_link_or_button(*) + def click_link_or_button(...) super.tap do await_empty_ajax_queue end end - def click_button(*) + def click_button(...) super.tap do await_empty_ajax_queue end end - def select_option(*) + def select_option(...) super.tap do await_empty_ajax_queue end end - def send_keys(*) + def send_keys(...) super.tap do await_empty_ajax_queue end @@ -80,31 +80,31 @@ module ZammadCapybarActionDelegator end module ZammadCapybarSelectorDelegator - def find_field(*) + def find_field(...) ZammadCapybaraElementDelegator.new(element: super, context: self) end - def find_button(*) + def find_button(...) ZammadCapybaraElementDelegator.new(element: super, context: self) end - def find_by_id(*) + def find_by_id(...) ZammadCapybaraElementDelegator.new(element: super, context: self) end - def find_link(*) + def find_link(...) ZammadCapybaraElementDelegator.new(element: super, context: self) end - def find(*) + def find(...) ZammadCapybaraElementDelegator.new(element: super, context: self) end - def first(*) + def first(...) ZammadCapybaraElementDelegator.new(element: super, context: self) end - def all(*) + def all(...) super.map { |element| ZammadCapybaraElementDelegator.new(element: element, context: self) } end end @@ -131,7 +131,7 @@ module CapybaraCustomExtensions include ZammadCapybarActionDelegator include ZammadCapybarSelectorDelegator - def page(*) + def page(...) ZammadCapybaraSessionDelegator.new(element: super, context: self) end end diff --git a/spec/support/capybara/driven_by.rb b/spec/support/capybara/driven_by.rb index 2cf388698..e636018c5 100644 --- a/spec/support/capybara/driven_by.rb +++ b/spec/support/capybara/driven_by.rb @@ -11,7 +11,7 @@ RSpec.configure do |config| Setting.set('fqdn', "#{host}:#{port}") # start a silenced Puma as application server - Capybara.servers[:puma].call(app, port, host, { Silent: true, Host: '0.0.0.0', Threads: '0:16' }) + Capybara.servers[:puma].call(app, port, host, Silent: true, Host: '0.0.0.0', Threads: '0:16') end Capybara.server = :puma_wrapper diff --git a/spec/support/capybara/selenium_driver.rb b/spec/support/capybara/selenium_driver.rb index 82b71af4a..ea016806a 100644 --- a/spec/support/capybara/selenium_driver.rb +++ b/spec/support/capybara/selenium_driver.rb @@ -29,7 +29,7 @@ Capybara.register_driver(:zammad_chrome) do |app| options[:url] = ENV['REMOTE_URL'] end - Capybara::Selenium::Driver.new(app, options) + Capybara::Selenium::Driver.new(app, **options) end Capybara.register_driver(:zammad_firefox) do |app| @@ -54,5 +54,5 @@ Capybara.register_driver(:zammad_firefox) do |app| options[:url] = ENV['REMOTE_URL'] end - Capybara::Selenium::Driver.new(app, options) + Capybara::Selenium::Driver.new(app, **options) end diff --git a/spec/support/db_migration.rb b/spec/support/db_migration.rb index 7ebc20b15..530129e74 100644 --- a/spec/support/db_migration.rb +++ b/spec/support/db_migration.rb @@ -117,7 +117,7 @@ module DbMigrationHelper # remove_foreign_key(:online_notifications, :users) # # @return [nil] - def respond_to_missing?(*) + def respond_to_missing?(...) true end diff --git a/spec/support/deprecation_toolkit.rb b/spec/support/deprecation_toolkit.rb index 5af4a5e97..daf174959 100644 --- a/spec/support/deprecation_toolkit.rb +++ b/spec/support/deprecation_toolkit.rb @@ -3,4 +3,14 @@ require 'deprecation_toolkit/rspec' DeprecationToolkit::Configuration.test_runner = :rspec -# DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [ %r{deprecat}i ] + +# Treat Ruby deprecation warnings as errors. +DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [ %r{deprecat}i ] + +# Ignore deprecation warnings from dependencies. +DeprecationToolkit::Configuration.allowed_deprecations = [ + lambda do |_message, stack| + path = stack.first.absolute_path.to_s + path.include?('/ruby/') || path.include?('/gems/') + end +]