Skip to content

Commit

Permalink
Organise requires to fix circular require warning
Browse files Browse the repository at this point in the history
  • Loading branch information
imjoehaines committed Jun 12, 2024
1 parent 1ad926c commit e601084
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 52 deletions.
17 changes: 5 additions & 12 deletions lib/bugsnag.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
require "rubygems"
require "thread"
require "set"
require "json"
require "uri"
require "socket"
require "logger"

require "bugsnag/version"
require "bugsnag/utility/feature_data_store"
Expand All @@ -21,21 +26,9 @@
# as it doesn't auto-configure when loaded
require "bugsnag/integrations/rack"

require "bugsnag/middleware/rack_request"
require "bugsnag/middleware/warden_user"
require "bugsnag/middleware/clearance_user"
require "bugsnag/middleware/callbacks"
require "bugsnag/middleware/rails3_request"
require "bugsnag/middleware/sidekiq"
require "bugsnag/middleware/mailman"
require "bugsnag/middleware/rake"
require "bugsnag/middleware/classify_error"
require "bugsnag/middleware/delayed_job"

require "bugsnag/breadcrumb_type"
require "bugsnag/breadcrumbs/validator"
require "bugsnag/breadcrumbs/breadcrumb"
require "bugsnag/breadcrumbs/breadcrumbs"

require "bugsnag/utility/duplicator"
require "bugsnag/utility/metadata_delegate"
Expand Down
2 changes: 0 additions & 2 deletions lib/bugsnag/breadcrumbs/on_breadcrumb_callback_list.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require "set"

module Bugsnag::Breadcrumbs
class OnBreadcrumbCallbackList
def initialize(configuration)
Expand Down
2 changes: 0 additions & 2 deletions lib/bugsnag/breadcrumbs/validator.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'bugsnag/breadcrumbs/breadcrumbs'

module Bugsnag::Breadcrumbs
##
# Validates a given breadcrumb before it is stored
Expand Down
2 changes: 0 additions & 2 deletions lib/bugsnag/cleaner.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'uri'

module Bugsnag
# @api private
class Cleaner
Expand Down
30 changes: 19 additions & 11 deletions lib/bugsnag/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
require "set"
require "socket"
require "logger"
require "bugsnag/middleware_stack"
require "bugsnag/breadcrumbs/on_breadcrumb_callback_list"

require "bugsnag/endpoint_configuration"
require "bugsnag/endpoint_validator"

require "bugsnag/middleware/breadcrumbs"
require "bugsnag/middleware/callbacks"
require "bugsnag/middleware/classify_error"
require "bugsnag/middleware/clearance_user"
require "bugsnag/middleware/delayed_job"
require "bugsnag/middleware/discard_error_class"
require "bugsnag/middleware/exception_meta_data"
require "bugsnag/middleware/ignore_error_class"
require "bugsnag/middleware/suggestion_data"
require "bugsnag/middleware/classify_error"
require "bugsnag/middleware/mailman"
require "bugsnag/middleware/rack_request"
require "bugsnag/middleware/rails3_request"
require "bugsnag/middleware/rake"
require "bugsnag/middleware/session_data"
require "bugsnag/middleware/breadcrumbs"
require "bugsnag/middleware/sidekiq"
require "bugsnag/middleware/suggestion_data"
require "bugsnag/middleware/warden_user"

require "bugsnag/middleware_stack"

require "bugsnag/utility/circular_buffer"
require "bugsnag/breadcrumbs/breadcrumbs"
require "bugsnag/breadcrumbs/on_breadcrumb_callback_list"
require "bugsnag/endpoint_configuration"
require "bugsnag/endpoint_validator"

module Bugsnag
class Configuration
Expand Down
1 change: 0 additions & 1 deletion lib/bugsnag/delivery/synchronous.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "net/https"
require "uri"

module Bugsnag
module Delivery
Expand Down
2 changes: 0 additions & 2 deletions lib/bugsnag/delivery/thread_queue.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require "thread"

module Bugsnag
module Delivery
class ThreadQueue < Synchronous
Expand Down
2 changes: 0 additions & 2 deletions lib/bugsnag/event.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require "bugsnag/report"

module Bugsnag
# For now Event is just an alias of Report. This points to the same object so
# any changes to Report will also affect Event
Expand Down
5 changes: 0 additions & 5 deletions lib/bugsnag/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
require 'uri'
require 'set'
require 'json'


module Bugsnag
module Helpers # rubocop:todo Metrics/ModuleLength
MAX_STRING_LENGTH = 3072
Expand Down
1 change: 0 additions & 1 deletion lib/bugsnag/integrations/mongo.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'mongo'
require 'bugsnag/breadcrumbs/breadcrumbs'

module Bugsnag
##
Expand Down
2 changes: 0 additions & 2 deletions lib/bugsnag/integrations/rails/active_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'set'

module Bugsnag::Rails
module ActiveJob
SEVERITY = 'error'
Expand Down
2 changes: 0 additions & 2 deletions lib/bugsnag/integrations/rails/rails_breadcrumbs.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require "bugsnag/breadcrumbs/breadcrumbs"

module Bugsnag::Rails
DEFAULT_RAILS_BREADCRUMBS = [
{
Expand Down
4 changes: 0 additions & 4 deletions lib/bugsnag/integrations/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Rails 3.x hooks

require "json"
require "rails"
require "bugsnag"
require "bugsnag/middleware/rails3_request"
require "bugsnag/middleware/rack_request"
require "bugsnag/integrations/rails/rails_breadcrumbs"

module Bugsnag
Expand Down
5 changes: 4 additions & 1 deletion lib/bugsnag/integrations/rake.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require 'bugsnag'
# this file can either be required manually by a user, in which case 'bugsnag'
# needs to be required, or it can be required automatically in the railtie,
# in which case 'bugsnag' has already been required
require 'bugsnag' unless defined?(Bugsnag)

Rake::TaskManager.record_task_metadata = true

Expand Down
2 changes: 0 additions & 2 deletions lib/bugsnag/middleware/rack_request.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require "json"

module Bugsnag::Middleware
##
# Extracts and attaches rack data to an error report
Expand Down
1 change: 0 additions & 1 deletion lib/bugsnag/report.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require "json"
require "pathname"
require "bugsnag/error"
require "bugsnag/stacktrace"
Expand Down

0 comments on commit e601084

Please sign in to comment.