Commit 08c2a928 authored by Matias Alvarez's avatar Matias Alvarez Committed by Elliot Forbes
Browse files

fix: Rubocop offenses

parent 7e5dbbb7
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ module Labkit
        # Placeholder logger_class used when an offense originates from the Labkit
        # context. The same context fields appear in every logger that runs within
        # the context, so collapsing across loggers prevents one offense per
        # logger × deprecated_field combination and prevents new offenses being
        # logger x deprecated_field combination, and prevents new offenses being
        # raised whenever a developer adds a new logger class.
        ANY_LOGGER = "*"

@@ -52,9 +52,7 @@ module Labkit
            @context_callsite || DEFAULT_CONTEXT_CALLSITE
          end

          def context_callsite=(callsite)
            @context_callsite = callsite
          end
          attr_writer :context_callsite

          def reset_context_callsite!
            @context_callsite = nil
+8 −4
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ RSpec.describe Labkit::Logging::FieldValidator::LogInterceptor do

        expect(registry.offenses).not_to be_empty
        offense = registry.offenses.first
        expect(offense['callsite']).to eq(Labkit::Logging::FieldValidator::LogInterceptor.context_callsite)
        expect(offense['callsite']).to eq(described_class.context_callsite)
        expect(offense['deprecated_field']).to eq('meta.user_id')
      end

@@ -195,7 +195,7 @@ RSpec.describe Labkit::Logging::FieldValidator::LogInterceptor do
        expect(registry).to receive(:check_for_removed_offenses)
          .with('app/test.rb', hash_including('gl_user_id' => 123, 'message' => 'hello'), 'AnonymousLogger')
        expect(registry).to receive(:check_for_removed_offenses)
          .with(Labkit::Logging::FieldValidator::LogInterceptor.context_callsite,
          .with(described_class.context_callsite,
            hash_including('gl_user_id' => 123, 'message' => 'hello'),
            Labkit::Logging::FieldValidator::LogInterceptor::ANY_LOGGER)

@@ -258,7 +258,9 @@ RSpec.describe Labkit::Logging::FieldValidator::LogInterceptor do

  describe 'context callsite' do
    describe '.context_callsite' do
      after { described_class.reset_context_callsite! }
      after do
        described_class.reset_context_callsite!
      end

      it 'returns the default value' do
        expect(described_class.context_callsite).to eq(Labkit::Logging::FieldValidator::LogInterceptor::DEFAULT_CONTEXT_CALLSITE)
@@ -287,7 +289,9 @@ RSpec.describe Labkit::Logging::FieldValidator::LogInterceptor do
        allow(test_logger).to receive(:determine_callsite).and_return(mock_location)
      end

      after { described_class.reset_context_callsite! }
      after do
        described_class.reset_context_callsite!
      end

      it 'uses the custom callsite for context-originated offenses' do
        Labkit::Context.with_context('meta.user_id' => 456) do