Skip to content

Commit

Permalink
Generate rubocop_todo and autocorrect the specs
Browse files Browse the repository at this point in the history
The main part of the project will be fixed in a separate PR.
  • Loading branch information
bliof-fc committed Feb 9, 2024
1 parent e196caf commit 127420d
Show file tree
Hide file tree
Showing 30 changed files with 432 additions and 170 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.7
NewCops: enable
Exclude:
- '*.gemspec'
- 'gemfiles/*'
Expand Down
206 changes: 206 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 10000000`
# on 2024-02-09 15:03:07 UTC using RuboCop version 1.60.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
Bundler/OrderedGems:
Exclude:
- 'Gemfile'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterGuardClause:
Exclude:
- 'lib/loga/formatters/gelf_formatter.rb'

# Offense count: 34
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Exclude:
- 'lib/loga/configuration.rb'
- 'lib/loga/formatters/gelf_formatter.rb'
- 'lib/loga/rack/logger.rb'
- 'lib/loga/railtie.rb'
- 'lib/loga/sidekiq6/job_logger.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment.
Layout/LeadingCommentSpace:
Exclude:
- 'lib/loga/railtie.rb'

# Offense count: 2
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
- 'Appraisals'
- 'spec/integration/sinatra_spec.rb'

# Offense count: 1
# Configuration parameters: AllowedParentClasses.
Lint/MissingSuper:
Exclude:
- 'lib/loga/formatters/gelf_formatter.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Lint/RedundantCopDisableDirective:
Exclude:
- 'lib/loga/railtie.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Lint/SendWithMixinArgument:
Exclude:
- 'lib/loga/railtie.rb'

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 8

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 9

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Migration/DepartmentName:
Exclude:
- 'lib/loga/railtie.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: PreferredName.
Naming/RescuedExceptionsVariableName:
Exclude:
- 'lib/loga/sidekiq5/job_logger.rb'

# Offense count: 3
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/support/gethostname_shared.rb'
- 'spec/support/timecop_shared.rb'
- 'spec/unit/loga/configuration_spec.rb'

# Offense count: 41
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 12

# Offense count: 6
# Configuration parameters: AllowedPatterns.
# AllowedPatterns: ^expect_, ^assert_
RSpec/NoExpectationExample:
Exclude:
- 'spec/integration/sidekiq60_spec.rb'
- 'spec/integration/sidekiq61_spec.rb'
- 'spec/integration/sidekiq65_spec.rb'
- 'spec/integration/sidekiq7_spec.rb'

# Offense count: 2
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
# Include: **/*_spec.rb
RSpec/SpecFilePathFormat:
Exclude:
- '**/spec/routing/**/*'
- 'spec/integration/rails/action_mailer_spec.rb'
- 'spec/integration/rails/railtie_spec.rb'

# Offense count: 1
RSpec/SubjectDeclaration:
Exclude:
- 'spec/unit/loga/event_spec.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedReceivers.
Style/CollectionCompact:
Exclude:
- 'lib/loga/configuration.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Keywords, RequireColon.
# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE
Style/CommentAnnotation:
Exclude:
- 'lib/loga/configuration.rb'

# Offense count: 25
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Exclude:
- 'Appraisals'
- 'Gemfile'
- 'Guardfile'
- 'Rakefile'
- 'lib/loga.rb'
- 'lib/loga/configuration.rb'
- 'lib/loga/event.rb'
- 'lib/loga/ext/core/tempfile.rb'
- 'lib/loga/ext/rails/rack/debug_exceptions.rb'
- 'lib/loga/ext/rails/rack/logger.rb'
- 'lib/loga/ext/rails/rack/logger3.rb'
- 'lib/loga/formatters/gelf_formatter.rb'
- 'lib/loga/formatters/simple_formatter.rb'
- 'lib/loga/log_subscribers/action_mailer.rb'
- 'lib/loga/parameter_filter.rb'
- 'lib/loga/rack/logger.rb'
- 'lib/loga/rack/request.rb'
- 'lib/loga/rack/request_id.rb'
- 'lib/loga/railtie.rb'
- 'lib/loga/service_version_strategies.rb'
- 'lib/loga/sidekiq5/job_logger.rb'
- 'lib/loga/sidekiq6/job_logger.rb'
- 'lib/loga/tagged_logging.rb'
- 'lib/loga/utilities.rb'
- 'lib/loga/version.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'lib/loga/configuration.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: literals, strict
Style/MutableConstant:
Exclude:
- 'lib/loga/rack/request.rb'

# Offense count: 2
Style/OpenStructUse:
Exclude:
- 'spec/unit/loga/formatters/gelf_formatter_spec.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantFileExtensionInRequire:
Exclude:
- 'lib/loga/railtie.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantFreeze:
Exclude:
- 'lib/loga/sidekiq7/job_logger.rb'
2 changes: 2 additions & 0 deletions spec/integration/rails/action_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Loga::LogSubscribers::ActionMailer, if: Rails.env.production? do
Expand Down
4 changes: 3 additions & 1 deletion spec/integration/rails/railtie_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'ostruct'

RSpec.describe Loga::Railtie do
Expand Down Expand Up @@ -38,7 +40,7 @@
end

it 'disables colorized logging' do
expect(app.config.colorize_logging).to eq(false)
expect(app.config.colorize_logging).to be(false)
end
end

Expand Down
6 changes: 4 additions & 2 deletions spec/integration/rails/request_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Structured logging with Rails', timecop: true,
if: Rails.env.production? do
RSpec.describe 'Structured logging with Rails', :timecop,
if: Rails.env.production? do
let(:app) { Rails.application }

let(:log_entries) do
Expand Down
28 changes: 15 additions & 13 deletions spec/integration/sidekiq5_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'
require 'timecop'
require 'fakeredis'
Expand All @@ -24,8 +26,8 @@ def perform(_name); end
attr_reader :latest_error, :mutex, :cond

def initialize
@mutex = ::Mutex.new
@cond = ::ConditionVariable.new
@mutex = Mutex.new
@cond = ConditionVariable.new
end

def processor_died(_inst, err)
Expand Down Expand Up @@ -84,7 +86,7 @@ def read_json_log(line:)
aggregate_failures do
expect(last_element['class']).to eq 'MySidekiqWorker'
expect(last_element['args']).to eq ['Bob']
expect(last_element['retry']).to eq true
expect(last_element['retry']).to be true
expect(last_element['queue']).to eq 'default'
end
end
Expand All @@ -107,16 +109,16 @@ def read_json_log(line:)

aggregate_failures do
expect(json_line).to include(
'_queue'=> 'default',
'_retry'=> true,
'_params'=> ['Bob'],
'_class'=> 'MySidekiqWorker',
'_type'=> 'sidekiq',
'_service.name'=> 'hello_world_app',
'_service.version'=> '1.0',
'_tags'=> '',
'level'=> 6,
'version'=> '1.1',
'_queue' => 'default',
'_retry' => true,
'_params' => ['Bob'],
'_class' => 'MySidekiqWorker',
'_type' => 'sidekiq',
'_service.name' => 'hello_world_app',
'_service.version' => '1.0',
'_tags' => '',
'level' => 6,
'version' => '1.1',
)

%w[_created_at _enqueued_at _jid _duration timestamp host].each do |key|
Expand Down
6 changes: 3 additions & 3 deletions spec/integration/sidekiq60_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def perform(_name)
attr_reader :cond

def initialize
@mutex = ::Mutex.new
@cond = ::ConditionVariable.new
@mutex = Mutex.new
@cond = ConditionVariable.new
end

def processor_died(_inst, err)
Expand Down Expand Up @@ -103,7 +103,7 @@ def dump_log
aggregate_failures do
expect(last_element['class']).to eq 'MySidekiqWorker'
expect(last_element['args']).to eq ['Bob']
expect(last_element['retry']).to eq true
expect(last_element['retry']).to be true
expect(last_element['queue']).to eq 'default'
end
end
Expand Down
10 changes: 6 additions & 4 deletions spec/integration/sidekiq61_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'
require 'timecop'
require 'fakeredis'
Expand Down Expand Up @@ -27,8 +29,8 @@ def perform(_name)
attr_reader :latest_error, :mutex, :cond

def initialize
@mutex = ::Mutex.new
@cond = ::ConditionVariable.new
@mutex = Mutex.new
@cond = ConditionVariable.new
end

def processor_died(_inst, err)
Expand All @@ -46,7 +48,7 @@ def options
concurrency: 3,
queues: ['default'],
job_logger: Loga::Sidekiq6::JobLogger,
}.tap { |opts| opts[:fetch] = ::Sidekiq::BasicFetch.new(opts) }
}.tap { |opts| opts[:fetch] = Sidekiq::BasicFetch.new(opts) }
end
end
end
Expand Down Expand Up @@ -87,7 +89,7 @@ def read_json_log(line:)
aggregate_failures do
expect(last_element['class']).to eq 'MySidekiqWorker'
expect(last_element['args']).to eq ['Bob']
expect(last_element['retry']).to eq true
expect(last_element['retry']).to be true
expect(last_element['queue']).to eq 'default'
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/sidekiq65_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def read_json_log(line:)
aggregate_failures do
expect(last_element['class']).to eq 'MySidekiqWorker'
expect(last_element['args']).to eq ['Bob']
expect(last_element['retry']).to eq true
expect(last_element['retry']).to be true
expect(last_element['queue']).to eq 'default'
end
end
Expand Down
Loading

0 comments on commit 127420d

Please sign in to comment.