diff --git a/.rubocop.yml b/.rubocop.yml index 5ae90526..c778bc07 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -118,3 +118,6 @@ Metrics/BlockLength: Performance/RegexpMatch: Enabled: false + +Style/IndentHeredoc: + Enabled: false diff --git a/benchmarks/payload_truncator_string_encoding.rb b/benchmarks/payload_truncator_string_encoding.rb index 0e45403f..0d20554e 100644 --- a/benchmarks/payload_truncator_string_encoding.rb +++ b/benchmarks/payload_truncator_string_encoding.rb @@ -1,4 +1,5 @@ # coding: utf-8 + require_relative 'benchmark_helpers' require 'securerandom' diff --git a/lib/airbrake-ruby/filters.rb b/lib/airbrake-ruby/filters.rb index 0423e8f3..1ef3feb5 100644 --- a/lib/airbrake-ruby/filters.rb +++ b/lib/airbrake-ruby/filters.rb @@ -5,6 +5,6 @@ module Filters ## # @return [Array] parts of a Notice's payload that can be modified # by various filters - FILTERABLE_KEYS = [:environment, :session, :params].freeze + FILTERABLE_KEYS = %i[environment session params].freeze end end diff --git a/lib/airbrake-ruby/notice.rb b/lib/airbrake-ruby/notice.rb index 820af360..dfed0668 100644 --- a/lib/airbrake-ruby/notice.rb +++ b/lib/airbrake-ruby/notice.rb @@ -44,12 +44,12 @@ class Notice # @return [Array] the list of keys that can be be overwritten with # {Airbrake::Notice#[]=} - WRITABLE_KEYS = [ - :notifier, - :context, - :environment, - :session, - :params + WRITABLE_KEYS = %i[ + notifier + context + environment + session + params ].freeze ## diff --git a/spec/airbrake_spec.rb b/spec/airbrake_spec.rb index 656c31c7..308111a0 100644 --- a/spec/airbrake_spec.rb +++ b/spec/airbrake_spec.rb @@ -94,7 +94,7 @@ notifiers = described_class.instance_variable_get(:@notifiers) expect(notifiers).to be_a(Hash) - expect(notifiers.keys).to eq([:default, :bingo]) + expect(notifiers.keys).to eq(%i[default bingo]) expect(notifiers.values).to all(satisfy { |v| v.is_a?(Airbrake::Notifier) }) end diff --git a/spec/config/validator_spec.rb b/spec/config/validator_spec.rb index 673f38da..261af4ca 100644 --- a/spec/config/validator_spec.rb +++ b/spec/config/validator_spec.rb @@ -12,9 +12,9 @@ end it "sets correct error message" do - expect { subject.valid_project_id? }. - to change { subject.error_message }. - to(/:project_id is required/) + expect { subject.valid_project_id? }.to( + change { subject.error_message }.to(/:project_id is required/) + ) end end @@ -28,8 +28,9 @@ it "sets correct error message" do expect { subject.valid_project_id? }. - to change { subject.error_message }. - to(/:project_id is required/) + to( + change { subject.error_message }.to(/:project_id is required/) + ) end end @@ -41,9 +42,9 @@ end it "sets correct error message" do - expect { subject.valid_project_id? }. - to change { subject.error_message }. - to(/:project_id is required/) + expect { subject.valid_project_id? }.to( + change { subject.error_message }.to(/:project_id is required/) + ) end end @@ -55,7 +56,7 @@ end it "doesn't set the error message" do - expect { subject.valid_project_id? }.not_to change { subject.error_message } + expect { subject.valid_project_id? }.not_to(change { subject.error_message }) end end end @@ -68,7 +69,7 @@ end it "doesn't set the error message" do - expect { subject.valid_project_id? }.not_to change { subject.error_message } + expect { subject.valid_project_id? }.not_to(change { subject.error_message }) end end end @@ -97,7 +98,7 @@ end it "doesn't set the error message" do - expect { subject.valid_project_key? }.not_to change { subject.error_message } + expect { subject.valid_project_key? }.not_to(change { subject.error_message }) end end end @@ -110,9 +111,9 @@ end it "sets correct error message" do - expect { subject.valid_project_key? }. - to change { subject.error_message }. - to(/:project_key is required/) + expect { subject.valid_project_key? }.to( + change { subject.error_message }.to(/:project_key is required/) + ) end end end @@ -126,7 +127,7 @@ end it "doesn't set the error message" do - expect { subject.valid_environment? }.not_to change { subject.error_message } + expect { subject.valid_environment? }.not_to(change { subject.error_message }) end end @@ -139,9 +140,10 @@ end it "sets the error message" do - expect { subject.valid_environment? }. - to change { subject.error_message }. - to(/the 'environment' option must be configured with a Symbol/) + expect { subject.valid_environment? }.to( + change { subject.error_message }. + to(/the 'environment' option must be configured with a Symbol/) + ) end end @@ -153,7 +155,7 @@ end it "doesn't set the error message" do - expect { subject.valid_environment? }.not_to change { subject.error_message } + expect { subject.valid_environment? }.not_to(change { subject.error_message }) end end @@ -165,7 +167,7 @@ end it "doesn't set the error message" do - expect { subject.valid_environment? }.not_to change { subject.error_message } + expect { subject.valid_environment? }.not_to(change { subject.error_message }) end end @@ -181,7 +183,7 @@ end it "doesn't set the error message" do - expect { subject.valid_environment? }.not_to change { subject.error_message } + expect { subject.valid_environment? }.not_to(change { subject.error_message }) end end end diff --git a/spec/config_spec.rb b/spec/config_spec.rb index eaba459c..318f3945 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -221,7 +221,7 @@ context "and when 'ignore_environments' contains Strings" do it "returns true" do config.environment = :bango - config.ignore_environments = %w(bango) + config.ignore_environments = %w[bango] expect(config.ignored_environment?).to be_truthy end diff --git a/spec/filter_chain_spec.rb b/spec/filter_chain_spec.rb index 55de58bc..85433390 100644 --- a/spec/filter_chain_spec.rb +++ b/spec/filter_chain_spec.rb @@ -181,7 +181,7 @@ expect(notice[:errors].first[:file]).to be_nil expect { @chain.refine(notice) }. - not_to change { notice[:errors].first[:file] } + not_to(change { notice[:errors].first[:file] }) end end @@ -200,7 +200,7 @@ expect(notice[:errors].first[:file]).to be_nil expect { filter_chain.refine(notice) }. - not_to change { notice[:errors].first[:file] } + not_to(change { notice[:errors].first[:file] }) end end end diff --git a/spec/notifier_spec.rb b/spec/notifier_spec.rb index a6c92745..2632c5bf 100644 --- a/spec/notifier_spec.rb +++ b/spec/notifier_spec.rb @@ -1,4 +1,5 @@ # coding: utf-8 + require 'spec_helper' RSpec.describe Airbrake::Notifier do @@ -405,7 +406,7 @@ def to_json(*) notifier.close end - it "respawns workers on fork()", skip: %w(jruby rbx).include?(RUBY_ENGINE) do + it "respawns workers on fork()", skip: %w[jruby rbx].include?(RUBY_ENGINE) do out = StringIO.new notifier = described_class.new(airbrake_params.merge(logger: Logger.new(out))) @@ -445,7 +446,7 @@ def to_json(*) end it "accepts multiple filters" do - [:bingo, :bongo, :bash].each do |key| + %i[bingo bongo bash].each do |key| @airbrake.add_filter do |notice| notice[:params][key] = '[Filtered]'.freeze if notice[:params][key] end diff --git a/spec/notifier_spec/options_spec.rb b/spec/notifier_spec/options_spec.rb index 033abc76..420dd9d0 100644 --- a/spec/notifier_spec/options_spec.rb +++ b/spec/notifier_spec/options_spec.rb @@ -201,7 +201,7 @@ def expect_a_request_with_body(body) context "when the current env and notify envs are the same" do params = { environment: :development, - ignore_environments: [:production, :development] + ignore_environments: %i[production development] } include_examples 'ignored notice', params @@ -217,7 +217,7 @@ def expect_a_request_with_body(body) end context "when the current env is not set and notify envs are present" do - params = { ignore_environments: [:production, :development] } + params = { ignore_environments: %i[production development] } include_examples 'sent notice', params end diff --git a/spec/notifier_spec/whitelist_keys_spec.rb b/spec/notifier_spec/whitelist_keys_spec.rb index 3ca1d194..998b3fa9 100644 --- a/spec/notifier_spec/whitelist_keys_spec.rb +++ b/spec/notifier_spec/whitelist_keys_spec.rb @@ -91,14 +91,14 @@ def expect_a_request_with_body(body) include_examples( 'whitelisting', - %w(bongo bish), + %w[bongo bish], bingo: 'bango', bongo: { bish: 'bash' } ) end context "and it is a recursive hash" do it "errors when nested hashes are not filtered" do - whitelist = airbrake_params.merge(whitelist_keys: %w(bingo bango)) + whitelist = airbrake_params.merge(whitelist_keys: %w[bingo bango]) notifier = Airbrake::Notifier.new(whitelist) bongo = { bingo: {} } @@ -196,7 +196,7 @@ def expect_a_request_with_body(body) describe "context/url" do let(:notifier) do - Airbrake::Notifier.new(airbrake_params.merge(whitelist_keys: %w(bish))) + Airbrake::Notifier.new(airbrake_params.merge(whitelist_keys: %w[bish])) end context "given a standard URL" do diff --git a/spec/payload_truncator_spec.rb b/spec/payload_truncator_spec.rb index d9d9efdf..f1dacefd 100644 --- a/spec/payload_truncator_spec.rb +++ b/spec/payload_truncator_spec.rb @@ -1,4 +1,5 @@ # coding: utf-8 + require 'spec_helper' RSpec.describe Airbrake::PayloadTruncator do @@ -216,13 +217,13 @@ context "of short strings" do let(:params) do - { bingo: %w(foo bar baz), bango: 'bongo', bish: 'bash' } + { bingo: %w[foo bar baz], bango: 'bongo', bish: 'bash' } end it "truncates long strings in the array, but not short ones" do @truncator.truncate_object(params) expect(params). - to eq(bingo: %w(foo bar baz), bango: 'bongo', bish: 'bash') + to eq(bingo: %w[foo bar baz], bango: 'bongo', bish: 'bash') end end