diff --git a/.rubocop.yml b/.rubocop.yml index 3ffe2b0d8..aa916e963 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,2 +1,57 @@ inherit_from: .rubocop_todo.yml +AllCops: + Exclude: + - 'bin/**/*' + - 'example/**/*' + - 'spec/fixtures/**/*' + - 'features/fixtures/**/*' + +# We can't use ".freeze" on our constants in case users are monkey patching +# them — this would be a BC break +Style/MutableConstant: + Enabled: false + +Layout/EmptyLinesAroundAttributeAccessor: + Enabled: true + +Layout/SpaceAroundMethodCallOperator: + Enabled: true + +Lint/RaiseException: + Enabled: true + +Lint/StructNewOverride: + Enabled: true + +Lint/DeprecatedOpenSSLConstant: + Enabled: true + +Lint/MixedRegexpCaptureTypes: + Enabled: true + +Style/RedundantFetchBlock: + Enabled: true + +Style/ExponentialNotation: + Enabled: false + +Style/HashEachMethods: + Enabled: true + +Style/RedundantRegexpCharacterClass: + Enabled: true + +Style/RedundantRegexpEscape: + Enabled: true + +# These require newer version of Ruby than our minimum supported version, so +# have to be disabled +Style/HashTransformKeys: # Requires Ruby 2.5 + Enabled: false + +Style/HashTransformValues: # Requires Ruby 2.4 + Enabled: false + +Style/SlicingWithRange: # Requires Ruby 2.6 + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4715394ab..fcb383927 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,40 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-02-06 11:17:57 +0000 using RuboCop version 0.52.1. +# on 2020-05-15 11:35:58 +0100 using RuboCop version 0.83.0. # 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: 3 +# Configuration parameters: Include. +# Include: **/*.gemfile, **/Gemfile, **/gems.rb +Bundler/DuplicatedGem: + Exclude: + - 'Gemfile' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: TreatCommentsAsGroupSeparators, Include. +# Include: **/*.gemfile, **/Gemfile, **/gems.rb +Bundler/OrderedGems: + Exclude: + - 'Gemfile' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'bugsnag.gemspec' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/BlockEndNewline: + Exclude: + - 'spec/integrations/mongo_spec.rb' + - 'spec/report_spec.rb' + # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. @@ -14,16 +43,45 @@ Layout/CaseIndentation: Exclude: - 'lib/bugsnag/cleaner.rb' -# Offense count: 3 +# Offense count: 15 +# Cop supports --auto-correct. +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'lib/bugsnag.rb' + - 'lib/bugsnag/cleaner.rb' + - 'lib/bugsnag/delivery/thread_queue.rb' + - 'lib/bugsnag/helpers.rb' + - 'lib/bugsnag/session_tracker.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +Layout/EmptyLineAfterMagicComment: + Exclude: + - 'spec/breadcrumbs/validator_spec.rb' + - 'spec/bugsnag_spec.rb' + - 'spec/configuration_spec.rb' + - 'spec/integrations/mongo_spec.rb' + - 'spec/integrations/que_spec.rb' + - 'spec/integrations/resque_spec.rb' + - 'spec/integrations/shoryuken_spec.rb' + - 'spec/middleware/exception_meta_data_spec.rb' + - 'spec/report_spec.rb' + - 'spec/session_tracker_spec.rb' + +# Offense count: 5 # Cop supports --auto-correct. Layout/EmptyLines: Exclude: + - 'features/steps/ruby_notifier_steps.rb' - 'lib/bugsnag/helpers.rb' - 'lib/bugsnag/integrations/mailman.rb' - 'lib/bugsnag/stacktrace.rb' + - 'spec/integrations/mailman_spec.rb' # Offense count: 4 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: around, only_before Layout/EmptyLinesAroundAccessModifier: Exclude: - 'lib/bugsnag/delivery.rb' @@ -31,25 +89,38 @@ Layout/EmptyLinesAroundAccessModifier: - 'lib/bugsnag/middleware_stack.rb' - 'lib/bugsnag/session_tracker.rb' -# Offense count: 1 +# Offense count: 2 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundAttributeAccessor: + Exclude: + - 'lib/bugsnag/configuration.rb' + - 'spec/report_spec.rb' + +# Offense count: 24 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, no_empty_lines Layout/EmptyLinesAroundBlockBody: Exclude: - 'lib/bugsnag/middleware/classify_error.rb' - -# Offense count: 11 + - 'spec/bugsnag_spec.rb' + - 'spec/helper_spec.rb' + - 'spec/integration_spec.rb' + - 'spec/integrations/logger_spec.rb' + - 'spec/integrations/rack_spec.rb' + - 'spec/integrations/rails3_request_spec.rb' + - 'spec/middleware_spec.rb' + - 'spec/report_spec.rb' + +# Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only Layout/EmptyLinesAroundClassBody: Exclude: - - 'lib/bugsnag/integrations/delayed_job.rb' - 'lib/bugsnag/integrations/mailman.rb' - 'lib/bugsnag/integrations/rack.rb' - 'lib/bugsnag/integrations/railtie.rb' - - 'lib/bugsnag/integrations/rake.rb' - 'lib/bugsnag/integrations/resque.rb' - 'lib/bugsnag/integrations/shoryuken.rb' - 'lib/bugsnag/integrations/sidekiq.rb' @@ -57,12 +128,6 @@ Layout/EmptyLinesAroundClassBody: - 'lib/bugsnag/session_tracker.rb' - 'lib/bugsnag/stacktrace.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundExceptionHandlingKeywords: - Exclude: - - 'lib/bugsnag/integrations/rake.rb' - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. @@ -71,26 +136,54 @@ Layout/EmptyLinesAroundModuleBody: Exclude: - 'lib/bugsnag/integrations/rails/controller_methods.rb' +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. +# SupportedStylesAlignWith: keyword, variable, start_of_line +Layout/EndAlignment: + Exclude: + - 'lib/bugsnag/cleaner.rb' + # Offense count: 1 # Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Exclude: + - 'Rakefile' + +# Offense count: 7 +# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/IndentArray: +Layout/FirstArrayElementIndentation: Exclude: - 'lib/bugsnag/middleware/classify_error.rb' + - 'spec/report_spec.rb' + - 'spec/stacktrace_spec.rb' -# Offense count: 12 +# Offense count: 164 # Cop supports --auto-correct. # Configuration parameters: IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/IndentHash: +Layout/FirstHashElementIndentation: EnforcedStyle: consistent +# Offense count: 2 +# Cop supports --auto-correct. +# 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/bugsnag/delivery/synchronous.rb' + - 'spec/integrations/rake_spec.rb' + # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. -# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent -Layout/IndentHeredoc: +# SupportedStyles: squiggly, active_support, powerpack, unindent +Layout/HeredocIndentation: Exclude: - 'lib/generators/bugsnag/bugsnag_generator.rb' @@ -101,11 +194,23 @@ Layout/IndentationWidth: Exclude: - 'lib/bugsnag/cleaner.rb' -# Offense count: 2 +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. +Layout/LeadingCommentSpace: + Exclude: + - 'spec/integration_spec.rb' + - 'spec/integrations/mailman_spec.rb' + - 'spec/integrations/que_spec.rb' + - 'spec/integrations/resque_spec.rb' + +# Offense count: 4 # Cop supports --auto-correct. Layout/MultilineBlockLayout: Exclude: - 'lib/bugsnag/middleware/classify_error.rb' + - 'spec/integrations/mongo_spec.rb' + - 'spec/report_spec.rb' # Offense count: 3 # Cop supports --auto-correct. @@ -124,7 +229,13 @@ Layout/SpaceAfterComma: - 'lib/bugsnag/middleware_stack.rb' - 'lib/bugsnag/report.rb' -# Offense count: 5 +# Offense count: 1 +# Cop supports --auto-correct. +Layout/SpaceAfterNot: + Exclude: + - 'features/steps/ruby_notifier_steps.rb' + +# Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: space, no_space @@ -136,7 +247,20 @@ Layout/SpaceAroundEqualsInParameterDefault: - 'lib/bugsnag/integrations/rake.rb' - 'lib/bugsnag/report.rb' -# Offense count: 2 +# Offense count: 16 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. +# SupportedStylesForExponentOperator: space, no_space +Layout/SpaceAroundOperators: + Exclude: + - 'Gemfile' + - 'Rakefile' + - 'spec/bugsnag_spec.rb' + - 'spec/integrations/rake_spec.rb' + - 'spec/integrations/sidekiq_spec.rb' + - 'spec/report_spec.rb' + +# Offense count: 89 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space @@ -145,120 +269,178 @@ Layout/SpaceBeforeBlockBraces: Exclude: - 'lib/bugsnag/middleware/suggestion_data.rb' - 'lib/bugsnag/middleware_stack.rb' - -# Offense count: 23 + - 'spec/bugsnag_spec.rb' + - 'spec/configuration_spec.rb' + - 'spec/helper_spec.rb' + - 'spec/integration_spec.rb' + - 'spec/integrations/mailman_spec.rb' + - 'spec/integrations/rack_spec.rb' + - 'spec/integrations/rake_spec.rb' + - 'spec/integrations/sidekiq_spec.rb' + - 'spec/middleware_spec.rb' + - 'spec/report_spec.rb' + - 'spec/session_tracker_spec.rb' + - 'spec/stacktrace_spec.rb' + +# Offense count: 48 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceInsideBlockBraces: - Exclude: - - 'lib/bugsnag.rb' - - 'lib/bugsnag/cleaner.rb' - - 'lib/bugsnag/helpers.rb' - - 'lib/bugsnag/integrations/shoryuken.rb' - - 'lib/bugsnag/middleware/callbacks.rb' - - 'lib/bugsnag/middleware/rack_request.rb' - - 'lib/bugsnag/middleware/warden_user.rb' - - 'lib/bugsnag/middleware_stack.rb' - - 'lib/bugsnag/report.rb' - - 'lib/bugsnag/stacktrace.rb' + Enabled: false -# Offense count: 22 +# Offense count: 162 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space, compact # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceInsideHashLiteralBraces: - Exclude: - - 'lib/bugsnag.rb' - - 'lib/bugsnag/cleaner.rb' - - 'lib/bugsnag/integrations/resque.rb' - - 'lib/bugsnag/middleware/exception_meta_data.rb' - - 'lib/bugsnag/middleware/mailman.rb' - - 'lib/bugsnag/middleware/suggestion_data.rb' - - 'lib/bugsnag/middleware/warden_user.rb' - - 'lib/bugsnag/report.rb' - - 'lib/bugsnag/session_tracker.rb' + Enabled: false -# Offense count: 2 +# Offense count: 3 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space Layout/SpaceInsideParens: Exclude: - 'lib/bugsnag/stacktrace.rb' + - 'spec/integrations/shoryuken_spec.rb' -# Offense count: 4 +# Offense count: 8 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: final_newline, final_blank_line -Layout/TrailingBlankLines: +Layout/TrailingEmptyLines: Exclude: - - 'lib/bugsnag/integrations/que.rb' - 'lib/bugsnag/session_tracker.rb' - 'lib/bugsnag/tasks.rb' - 'lib/bugsnag/version.rb' + - 'spec/breadcrumbs/breadcrumb_spec.rb' + - 'spec/breadcrumbs/validator_spec.rb' + - 'spec/middleware_stack_spec.rb' + - 'spec/spec_helper.rb' + - 'spec/utility/circular_buffer_spec.rb' -# Offense count: 2 +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'spec/integrations/clearance_user_spec.rb' + - 'spec/integrations/que_spec.rb' + - 'spec/integrations/rake_spec.rb' + - 'spec/integrations/shoryuken_spec.rb' + - 'spec/integrations/warden_user_spec.rb' + +# Offense count: 90 Lint/AmbiguousBlockAssociation: Exclude: - 'lib/bugsnag/delivery/thread_queue.rb' - 'lib/bugsnag/middleware/suggestion_data.rb' + - 'spec/integrations/rack_spec.rb' + - 'spec/integrations/rails3_request_spec.rb' + - 'spec/integrations/sidekiq_spec.rb' + - 'spec/middleware_spec.rb' + - 'spec/report_spec.rb' + - 'spec/session_tracker_spec.rb' + - 'spec/stacktrace_spec.rb' -# Offense count: 4 +# Offense count: 3 # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: Exclude: - 'lib/bugsnag/delivery/thread_queue.rb' - 'lib/bugsnag/helpers.rb' - - 'lib/bugsnag/integrations/delayed_job.rb' # Offense count: 2 -Lint/DuplicateMethods: +# Cop supports --auto-correct. +Lint/BooleanSymbol: Exclude: - - 'lib/bugsnag/configuration.rb' + - 'spec/breadcrumbs/validator_spec.rb' -# Offense count: 2 +# Offense count: 15 +Lint/IneffectiveAccessModifier: + Exclude: + - 'lib/bugsnag/helpers.rb' + +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect. -# SupportedStylesAlignWith: keyword, variable, start_of_line -Lint/EndAlignment: +# Configuration parameters: EnforcedStyle. +# SupportedStyles: runtime_error, standard_error +Lint/InheritException: Exclude: - - 'lib/bugsnag/cleaner.rb' + - 'spec/report_spec.rb' -# Offense count: 2 -Lint/HandleExceptions: +# Offense count: 1 +# Cop supports --auto-correct. +Lint/ParenthesesAsGroupedExpression: + Exclude: + - 'spec/report_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Lint/RedundantRequireStatement: Exclude: - 'lib/bugsnag.rb' - - 'lib/bugsnag/tasks/bugsnag.rake' + - 'lib/bugsnag/delivery/thread_queue.rb' + - 'lib/bugsnag/session_tracker.rb' -# Offense count: 10 -Lint/IneffectiveAccessModifier: +# Offense count: 1 +# Cop supports --auto-correct. +Lint/RedundantStringCoercion: Exclude: - - 'lib/bugsnag/helpers.rb' + - 'features/support/env.rb' -# Offense count: 5 +# Offense count: 12 Lint/RescueException: Exclude: + - 'lib/bugsnag/integrations/delayed_job.rb' - 'lib/bugsnag/integrations/mailman.rb' - 'lib/bugsnag/integrations/rack.rb' - 'lib/bugsnag/integrations/rake.rb' - 'lib/bugsnag/integrations/shoryuken.rb' - 'lib/bugsnag/integrations/sidekiq.rb' - - 'lib/bugsnag/integrations/delayed_job.rb' + - 'spec/middleware_spec.rb' + - 'spec/report_spec.rb' + - 'spec/stacktrace_spec.rb' -# Offense count: 6 +# Offense count: 1 +# Cop supports --auto-correct. +Lint/SendWithMixinArgument: + Exclude: + - 'lib/bugsnag/integrations/rake.rb' + +# Offense count: 2 +# Configuration parameters: AllowComments. +Lint/SuppressedException: + Exclude: + - 'lib/bugsnag.rb' + - 'lib/bugsnag/tasks/bugsnag.rake' + +# Offense count: 103 # Cop supports --auto-correct. # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: Exclude: + - 'features/support/env.rb' - 'lib/bugsnag/configuration.rb' - 'lib/bugsnag/helpers.rb' - 'lib/bugsnag/middleware_stack.rb' - 'lib/bugsnag/report.rb' + - 'spec/bugsnag_spec.rb' + - 'spec/helper_spec.rb' + - 'spec/integrations/rack_spec.rb' + - 'spec/integrations/rails3_request_spec.rb' + - 'spec/integrations/sidekiq_spec.rb' + - 'spec/middleware_spec.rb' + - 'spec/report_spec.rb' + - 'spec/session_tracker_spec.rb' + - 'spec/stacktrace_spec.rb' # Offense count: 3 # Cop supports --auto-correct. -# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. Lint/UnusedMethodArgument: Exclude: - 'lib/bugsnag.rb' @@ -266,53 +448,59 @@ Lint/UnusedMethodArgument: - 'lib/bugsnag/integrations/sidekiq.rb' # Offense count: 1 +# Cop supports --auto-correct. # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. Lint/UselessAccessModifier: Exclude: - 'lib/bugsnag/helpers.rb' -# Offense count: 25 +# Offense count: 4 +Lint/UselessAssignment: + Exclude: + - 'features/steps/ruby_notifier_steps.rb' + - 'spec/breadcrumbs/breadcrumb_spec.rb' + - 'spec/session_tracker_spec.rb' + +# Offense count: 33 +# Configuration parameters: IgnoredMethods. Metrics/AbcSize: - Max: 86 + Max: 68 -# Offense count: 1 +# Offense count: 74 # Configuration parameters: CountComments, ExcludedMethods. +# ExcludedMethods: refine Metrics/BlockLength: - Max: 30 + Max: 1026 -# Offense count: 2 +# Offense count: 1 # Configuration parameters: CountBlocks. Metrics/BlockNesting: Max: 4 -# Offense count: 3 +# Offense count: 4 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 149 - Exclude: - - 'lib/bugsnag/report.rb' - - 'lib/bugsnag/configuration.rb' + Max: 174 -# Offense count: 12 +# Offense count: 15 +# Configuration parameters: IgnoredMethods. Metrics/CyclomaticComplexity: - Max: 19 + Max: 18 -# Offense count: 34 -# Configuration parameters: CountComments. +# Offense count: 42 +# Configuration parameters: CountComments, ExcludedMethods. Metrics/MethodLength: - Max: 55 + Max: 54 -# Offense count: 1 +# Offense count: 3 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 125 - Exclude: - - 'lib/bugsnag/helpers.rb' - - 'lib/bugsnag.rb' + Max: 152 -# Offense count: 11 +# Offense count: 15 +# Configuration parameters: IgnoredMethods. Metrics/PerceivedComplexity: - Max: 21 + Max: 20 # Offense count: 2 Naming/AccessorMethodName: @@ -320,24 +508,57 @@ Naming/AccessorMethodName: - 'lib/bugsnag/session_tracker.rb' # Offense count: 1 -# Configuration parameters: Blacklist. -# Blacklist: END, (?-mix:EO[A-Z]{1}) +Naming/ConstantName: + Exclude: + - 'spec/integrations/que_spec.rb' + +# Offense count: 1 +# Configuration parameters: ForbiddenDelimiters. +# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) Naming/HeredocDelimiterNaming: Exclude: - 'lib/generators/bugsnag/bugsnag_generator.rb' # Offense count: 1 -# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros. +# Configuration parameters: EnforcedStyleForLeadingUnderscores. +# SupportedStylesForLeadingUnderscores: disallowed, required, optional +Naming/MemoizedInstanceVariableName: + Exclude: + - 'lib/bugsnag.rb' + +# Offense count: 1 +# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. # NamePrefix: is_, has_, have_ -# NamePrefixBlacklist: is_, has_, have_ -# NameWhitelist: is_a? +# ForbiddenPrefixes: is_, has_, have_ +# AllowedMethods: is_a? # MethodDefinitionMacros: define_method, define_singleton_method Naming/PredicateName: Exclude: - 'spec/**/*' - 'lib/bugsnag/helpers.rb' -# Offense count: 5 +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'lib/bugsnag/integrations/delayed_job.rb' + - 'lib/bugsnag/integrations/mailman.rb' + - 'lib/bugsnag/integrations/rack.rb' + - 'lib/bugsnag/integrations/rails/active_record_rescue.rb' + - 'lib/bugsnag/integrations/rake.rb' + - 'lib/bugsnag/integrations/shoryuken.rb' + - 'lib/bugsnag/integrations/sidekiq.rb' + - 'lib/bugsnag/middleware/rack_request.rb' + +# Offense count: 3 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: snake_case, normalcase, non_integer +Naming/VariableNumber: + Exclude: + - 'spec/breadcrumbs/validator_spec.rb' + +# Offense count: 20 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: prefer_alias, prefer_alias_method @@ -346,8 +567,14 @@ Style/Alias: - 'lib/bugsnag/configuration.rb' - 'lib/bugsnag/integrations/rake.rb' - 'lib/bugsnag/session_tracker.rb' + - 'spec/bugsnag_spec.rb' + - 'spec/integrations/mailman_spec.rb' + - 'spec/integrations/mongo_spec.rb' + - 'spec/integrations/que_spec.rb' + - 'spec/integrations/resque_spec.rb' + - 'spec/integrations/shoryuken_spec.rb' -# Offense count: 2 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: always, conditionals @@ -355,35 +582,30 @@ Style/AndOr: Exclude: - 'lib/bugsnag.rb' - 'lib/bugsnag/helpers.rb' + - 'spec/spec_helper.rb' -# Offense count: 2 +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: percent_q, bare_percent +Style/BarePercentLiterals: + Exclude: + - 'features/steps/ruby_notifier_steps.rb' + +# Offense count: 5 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods. -# SupportedStyles: line_count_based, semantic, braces_for_chaining +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object # FunctionalMethods: let, let!, subject, watch # IgnoredMethods: lambda, proc, it Style/BlockDelimiters: Exclude: - 'lib/bugsnag/middleware/classify_error.rb' + - 'spec/integrations/mongo_spec.rb' + - 'spec/report_spec.rb' -# Offense count: 12 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: braces, no_braces, context_dependent -Style/BracesAroundHashParameters: - Exclude: - - 'lib/bugsnag/integrations/resque.rb' - - 'lib/bugsnag/integrations/shoryuken.rb' - - 'lib/bugsnag/integrations/sidekiq.rb' - - 'lib/bugsnag/middleware/mailman.rb' - - 'lib/bugsnag/middleware/rack_request.rb' - - 'lib/bugsnag/middleware/rails3_request.rb' - - 'lib/bugsnag/middleware/rake.rb' - - 'lib/bugsnag/middleware/suggestion_data.rb' - - 'lib/bugsnag/middleware/warden_user.rb' - -# Offense count: 16 +# Offense count: 27 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle. # SupportedStyles: nested, compact @@ -398,19 +620,27 @@ Style/ClassCheck: Exclude: - 'lib/bugsnag/cleaner.rb' -# Offense count: 6 +# Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. # SupportedStyles: assign_to_condition, assign_inside_condition Style/ConditionalAssignment: Exclude: + - 'features/steps/ruby_notifier_steps.rb' - 'lib/bugsnag.rb' - 'lib/bugsnag/cleaner.rb' - 'lib/bugsnag/delivery/synchronous.rb' - 'lib/bugsnag/middleware_stack.rb' - 'lib/bugsnag/report.rb' + - 'spec/report_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/Dir: + Exclude: + - 'spec/report_spec.rb' -# Offense count: 38 +# Offense count: 22 Style/Documentation: Enabled: false @@ -422,15 +652,55 @@ Style/EmptyElse: Exclude: - 'lib/bugsnag/stacktrace.rb' +# Offense count: 15 +# Cop supports --auto-correct. +Style/Encoding: + Exclude: + - 'Rakefile' + - 'spec/breadcrumbs/breadcrumb_spec.rb' + - 'spec/breadcrumbs/validator_spec.rb' + - 'spec/bugsnag_spec.rb' + - 'spec/cleaner_spec.rb' + - 'spec/configuration_spec.rb' + - 'spec/helper_spec.rb' + - 'spec/integrations/mongo_spec.rb' + - 'spec/integrations/que_spec.rb' + - 'spec/integrations/resque_spec.rb' + - 'spec/integrations/shoryuken_spec.rb' + - 'spec/middleware/exception_meta_data_spec.rb' + - 'spec/report_spec.rb' + - 'spec/session_tracker_spec.rb' + - 'spec/utility/circular_buffer_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ExpandPathArguments: + Exclude: + - 'lib/generators/bugsnag/bugsnag_generator.rb' + +# Offense count: 80 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + # Offense count: 3 +# Configuration parameters: AllowedVariables. +Style/GlobalVars: + Exclude: + - 'features/steps/ruby_notifier_steps.rb' + - 'features/support/env.rb' + +# Offense count: 5 # Configuration parameters: MinBodyLength. Style/GuardClause: Exclude: - 'lib/bugsnag.rb' - - 'lib/bugsnag/integrations/delayed_job.rb' - 'lib/bugsnag/integrations/resque.rb' + - 'spec/spec_helper.rb' -# Offense count: 98 +# Offense count: 547 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys @@ -438,11 +708,12 @@ Style/HashSyntax: Enabled: false # Offense count: 1 +# Configuration parameters: AllowIfModifier. Style/IfInsideElse: Exclude: - 'lib/bugsnag/session_tracker.rb' -# Offense count: 15 +# Offense count: 14 # Cop supports --auto-correct. Style/IfUnlessModifier: Exclude: @@ -452,21 +723,38 @@ Style/IfUnlessModifier: - 'lib/bugsnag/integrations/rack.rb' - 'lib/bugsnag/integrations/resque.rb' - 'lib/bugsnag/middleware/callbacks.rb' - - 'lib/bugsnag/middleware/exception_meta_data.rb' - 'lib/bugsnag/middleware/rack_request.rb' - 'lib/bugsnag/session_tracker.rb' - 'lib/bugsnag/stacktrace.rb' + - 'spec/cleaner_spec.rb' -# Offense count: 6 +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: line_count_dependent, lambda, literal +Style/Lambda: + Exclude: + - 'spec/integrations/rack_spec.rb' + - 'spec/middleware/exception_meta_data_spec.rb' + +# Offense count: 8 # Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. Style/MethodCallWithoutArgsParentheses: Exclude: - 'lib/bugsnag/delivery/synchronous.rb' - 'lib/bugsnag/report.rb' - 'lib/bugsnag/session_tracker.rb' + - 'spec/integrations/rake_spec.rb' + - 'spec/integrations/shoryuken_spec.rb' + +# Offense count: 1 +Style/MethodMissingSuper: + Exclude: + - 'lib/bugsnag/middleware_stack.rb' # Offense count: 1 -Style/MethodMissing: +Style/MissingRespondToMissing: Exclude: - 'lib/bugsnag/middleware_stack.rb' @@ -481,19 +769,23 @@ Style/MultilineIfModifier: Exclude: - 'lib/bugsnag/integrations/rails/controller_methods.rb' -# Offense count: 29 -# Cop supports --auto-correct. -Style/MutableConstant: - Enabled: false - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: both, prefix, postfix Style/NegatedIf: Exclude: - - 'lib/bugsnag.rb' - 'lib/bugsnag/session_tracker.rb' + - 'spec/middleware_spec.rb' + - 'spec/stacktrace_spec.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: AllowedMethods. +# AllowedMethods: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with +Style/NestedParenthesizedCalls: + Exclude: + - 'spec/session_tracker_spec.rb' # Offense count: 2 # Cop supports --auto-correct. @@ -511,20 +803,23 @@ Style/NonNilCheck: Exclude: - 'lib/bugsnag/report.rb' -# Offense count: 1 +# Offense count: 13 # Cop supports --auto-correct. # Configuration parameters: Strict. Style/NumericLiterals: MinDigits: 7 -# Offense count: 1 +# Offense count: 6 # Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle. +# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - 'spec/**/*' + - 'Rakefile' + - 'lib/bugsnag.rb' - 'lib/bugsnag/session_tracker.rb' + - 'lib/bugsnag/utility/circular_buffer.rb' # Offense count: 2 # Cop supports --auto-correct. @@ -532,19 +827,36 @@ Style/ParallelAssignment: Exclude: - 'lib/bugsnag/stacktrace.rb' +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'features/steps/ruby_notifier_steps.rb' + # Offense count: 6 # Cop supports --auto-correct. Style/PerlBackrefs: Exclude: - 'lib/bugsnag/stacktrace.rb' -# Offense count: 1 +# Offense count: 8 +# Cop supports --auto-correct. +Style/Proc: + Exclude: + - 'spec/bugsnag_spec.rb' + - 'spec/report_spec.rb' + +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: compact, exploded Style/RaiseArgs: Exclude: - 'lib/bugsnag/tasks/bugsnag.rake' + - 'spec/bugsnag_spec.rb' + - 'spec/integrations/rack_spec.rb' + - 'spec/integrations/rails3_request_spec.rb' # Offense count: 4 # Cop supports --auto-correct. @@ -553,7 +865,7 @@ Style/RedundantBegin: - 'lib/bugsnag/delivery/synchronous.rb' - 'lib/bugsnag/integrations/mailman.rb' - 'lib/bugsnag/integrations/shoryuken.rb' - - 'lib/bugsnag/integrations/sidekiq.rb' + - 'spec/bugsnag_spec.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -561,32 +873,41 @@ Style/RedundantException: Exclude: - 'lib/bugsnag/tasks/bugsnag.rake' -# Offense count: 11 +# Offense count: 2 +# Cop supports --auto-correct. +Style/RedundantInterpolation: + Exclude: + - 'spec/helper_spec.rb' + +# Offense count: 13 # Cop supports --auto-correct. Style/RedundantSelf: Exclude: - 'lib/bugsnag/configuration.rb' - - 'lib/bugsnag/integrations/railtie.rb' -# Offense count: 2 +# Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed Style/RegexpLiteral: Exclude: + - 'features/steps/ruby_notifier_steps.rb' - 'lib/bugsnag/stacktrace.rb' + - 'spec/report_spec.rb' + - 'spec/stacktrace_spec.rb' -# Offense count: 6 +# Offense count: 11 # Cop supports --auto-correct. Style/RescueModifier: Exclude: - - 'lib/bugsnag/cleaner.rb' - 'lib/bugsnag/middleware/rack_request.rb' - 'lib/bugsnag/middleware/rails3_request.rb' - 'lib/bugsnag/middleware/warden_user.rb' - 'lib/bugsnag/stacktrace.rb' + - 'spec/integrations/rack_spec.rb' + - 'spec/stacktrace_spec.rb' -# Offense count: 5 +# Offense count: 15 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, explicit @@ -596,36 +917,65 @@ Style/RescueStandardError: - 'lib/bugsnag/integrations/railtie.rb' - 'lib/bugsnag/stacktrace.rb' - 'lib/bugsnag/tasks/bugsnag.rake' + - 'spec/bugsnag_spec.rb' + - 'spec/report_spec.rb' -# Offense count: 1 +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'lib/bugsnag/middleware/callbacks.rb' + - 'spec/spec_helper.rb' + +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: AllowAsExpressionSeparator. Style/Semicolon: Exclude: - 'lib/bugsnag/configuration.rb' + - 'spec/cleaner_spec.rb' + - 'spec/configuration_spec.rb' -# Offense count: 3 +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: only_raise, only_fail, semantic +Style/SignalException: + Exclude: + - 'spec/bugsnag_spec.rb' + +# Offense count: 15 # Cop supports --auto-correct. # Configuration parameters: . # SupportedStyles: use_perl_names, use_english_names Style/SpecialGlobalVars: EnforcedStyle: use_perl_names -# Offense count: 176 +# Offense count: 1817 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes Style/StringLiterals: Enabled: false -# Offense count: 5 +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiteralsInInterpolation: + Exclude: + - 'features/support/env.rb' + +# Offense count: 14 # Cop supports --auto-correct. # Configuration parameters: MinSize. # SupportedStyles: percent, brackets Style/SymbolArray: EnforcedStyle: brackets -# Offense count: 3 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. # IgnoredMethods: respond_to, define_method @@ -634,6 +984,7 @@ Style/SymbolProc: - 'lib/bugsnag/middleware/classify_error.rb' - 'lib/bugsnag/middleware/rack_request.rb' - 'lib/bugsnag/middleware/suggestion_data.rb' + - 'spec/report_spec.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -643,37 +994,56 @@ Style/TernaryParentheses: Exclude: - 'lib/bugsnag/report.rb' -# Offense count: 5 +# Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArguments: Exclude: - - 'lib/bugsnag/integrations/delayed_job.rb' + - 'spec/report_spec.rb' # Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist. -# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Exclude: + - 'spec/stacktrace_spec.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'spec/integrations/que_spec.rb' + - 'spec/integrations/rails3_request_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods. +# AllowedMethods: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym Style/TrivialAccessors: Exclude: - 'lib/bugsnag/configuration.rb' -# Offense count: 1 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: MinSize, WordRegex. # SupportedStyles: percent, brackets Style/WordArray: EnforcedStyle: brackets -# Offense count: 3 +# Offense count: 4 # Cop supports --auto-correct. Style/ZeroLengthPredicate: Exclude: + - 'Rakefile' - 'lib/bugsnag/session_tracker.rb' -# Offense count: 92 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# Offense count: 371 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https -Metrics/LineLength: - Max: 162 +Layout/LineLength: + Max: 175 diff --git a/CHANGELOG.md b/CHANGELOG.md index 256cb4f57..be53a6bef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,31 @@ Changelog ========= +## 6.14.0 (20 July 2020) + +### Enhancements + +* Add configurable `discard_classes` option to allow filtering errors using either a `String` or `Regexp` matched against the error's class name + | [#597](https://github.com/bugsnag/bugsnag-ruby/pull/597) + +* The Breadcrumb name limit of 30 characters has been removed + | [#600](https://github.com/bugsnag/bugsnag-ruby/pull/600) + +* Improve performance of payload cleaning + | [#601](https://github.com/bugsnag/bugsnag-ruby/pull/601) + +* Improve performance when processing stacktraces + | [#602](https://github.com/bugsnag/bugsnag-ruby/pull/602) + | [#603](https://github.com/bugsnag/bugsnag-ruby/pull/603) + +* If a custom object responds to `id` method, show the id and class in error reports + | [#531](https://github.com/bugsnag/bugsnag-ruby/pull/531) + | [manojmj92](https://github.com/manojmj92) + +### Deprecated + +* The `ignore_classes` configuration option has been deprecated in favour of `discard_classes`. `ignore_classes` will be removed in the next major release + ## 6.13.1 (11 May 2020) ### Fixes diff --git a/Gemfile b/Gemfile index 74a298c81..93e21543b 100644 --- a/Gemfile +++ b/Gemfile @@ -32,13 +32,15 @@ group :coverage, optional: true do end group :rubocop, optional: true do - gem 'rubocop', '~> 0.52.1' + gem 'rubocop', '~> 0.83' end group :sidekiq, optional: true do gem 'sidekiq', '~> 5.2.7' # redis 4.1.2 dropped support for Ruby 2.2 gem 'redis', ruby_version < Gem::Version.new('2.3.0') ? '4.1.1' : '>= 4.1.2' + # rack 2.2.0 dropped support for Ruby 2.2 + gem 'rack', ruby_version < Gem::Version.new('2.3.0') ? '< 2.2.0' : '~> 2.2' end group :doc, optional: true do diff --git a/TESTING.md b/TESTING.md index f5fe99e87..513d83588 100644 --- a/TESTING.md +++ b/TESTING.md @@ -42,7 +42,7 @@ aws configure --profile=opensource Subsequently you'll need to run the following commmand to authenticate with the registry: ``` -$(aws ecr get-login --profile=opensource --no-include-email) +aws ecr get-login-password --profile=opensource | docker login --username AWS --password-stdin 855461928731.dkr.ecr.us-west-1.amazonaws.com ``` __Your session will periodically expire__, so you'll need to run this command to re-authenticate when that happens. @@ -64,7 +64,7 @@ Configure the tests to be run in the following way: When running the end-to-end tests, you'll want to restrict the feature files run to the specific test features for the platform. This is done using the Cucumber CLI syntax at the end of the `docker-compose run ruby-maze-runner` command, i.e: ``` -RUBY_TEST_VERSION=2.6 RAILS_VERSION=6 docker-compose run ruby-maze-runner features/rails_features --tags "@rails6" +RUBY_TEST_VERSION=2.6 RAILS_VERSION=6 docker-compose run --use-aliases ruby-maze-runner features/rails_features --tags "@rails6" ``` - Plain ruby tests should target `features/plain_features` @@ -75,7 +75,7 @@ RUBY_TEST_VERSION=2.6 RAILS_VERSION=6 docker-compose run ruby-maze-runner featur In order to target specific features the exact `.feature` file can be specified, i.e: ``` -RUBY_TEST_VERSION=2.6 RAILS_VERSION=6 docker-compose run ruby-maze-runner features/rails_features/app_version.feature --tags "@rails6" +RUBY_TEST_VERSION=2.6 RAILS_VERSION=6 docker-compose run --use-aliases ruby-maze-runner features/rails_features/app_version.feature --tags "@rails6" ``` In order to avoid running flakey or unfinished tests, the tag `"not @wip"` can be added to the tags option. This is recommended for all CI runs. If a tag is already specified, this should be added using the `and` keyword, e.g. `--tags "@rails6 and not @wip"` diff --git a/VERSION b/VERSION index d7d9d3fbd..68390495f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.13.1 +6.14.0 diff --git a/dockerfiles/Dockerfile.ruby-maze-runner b/dockerfiles/Dockerfile.ruby-maze-runner index 3b72c15b8..de09d813c 100644 --- a/dockerfiles/Dockerfile.ruby-maze-runner +++ b/dockerfiles/Dockerfile.ruby-maze-runner @@ -20,7 +20,7 @@ COPY spec ./spec RUN gem build bugsnag.gemspec # The maze-runner node tests -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:v2-cli as ruby-maze-runner +FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:latest-cli as ruby-maze-runner WORKDIR /app/ COPY features ./features COPY --from=ruby-package-builder /app/bugsnag-*.gem bugsnag.gem diff --git a/example/rails-60/.browserslistrc b/example/rails-60/.browserslistrc new file mode 100644 index 000000000..e94f8140c --- /dev/null +++ b/example/rails-60/.browserslistrc @@ -0,0 +1 @@ +defaults diff --git a/example/rails-60/.gitignore b/example/rails-60/.gitignore new file mode 100644 index 000000000..f3c55eb4f --- /dev/null +++ b/example/rails-60/.gitignore @@ -0,0 +1,45 @@ +/.ruby-version +/Gemfile.lock +/yarn.lock + +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal +/db/*.sqlite3-* + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/ +!/tmp/pids/.keep + +# Ignore uploaded files in development. +/storage/* +!/storage/.keep + +/public/assets +.byebug_history + +# Ignore master key for decrypting credentials and more. +/config/master.key + +/public/packs +/public/packs-test +/node_modules +/yarn-error.log +yarn-debug.log* +.yarn-integrity diff --git a/example/rails-60/Gemfile b/example/rails-60/Gemfile new file mode 100644 index 000000000..2a8f4d30e --- /dev/null +++ b/example/rails-60/Gemfile @@ -0,0 +1,56 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +# Install Bugsnag +gem "bugsnag", path: "../../" + +# Example task queues +gem "que" +gem "resque" +gem "sidekiq" + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 6.0.3', '>= 6.0.3.1' +# Use sqlite3 and pg as the database for Active Record +gem 'pg' +gem 'sqlite3' + +# Use Puma as the app server +gem 'puma', '~> 4.1' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.7' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use Active Model has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Active Storage variant +# gem 'image_processing', '~> 1.2' + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.4.2', require: false + +group :development, :test do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '~> 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of web drivers to run system tests with browsers + gem 'webdrivers' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/example/rails-60/README.md b/example/rails-60/README.md new file mode 100644 index 000000000..2eaa10f01 --- /dev/null +++ b/example/rails-60/README.md @@ -0,0 +1,137 @@ +# Bugsnag Rails v6.0 demo + +This Rails application demonstrates how to use Bugsnag with Rails v6.0, as well as integrating it into Sidekiq, Que, and Resque. +Further details about integrating Bugsnag with Rails applications can be found [here.](https://docs.bugsnag.com/platforms/ruby/rails/) + +Install dependencies + +```shell +bundle install +``` + +Install local binaries + +```shell +bundle exec rake app:update:bin +``` + +## Rails v6.0 + +### Configuration + +There are two methods of configuring Bugsnag within a Rails application: + +1. Your `API_KEY` can be exported as an environment variable `BUGSNAG_API_KEY`. + +2. Generate a bugsnag configuration file at `config/initializers/bugsnag.rb` which can be populated with the [available configuration options](https://docs.bugsnag.com/platforms/ruby/rails/configuration-options/) by running the rails command: + + ```shell + bundle exec bin/rails generate bugsnag YOUR_API_KEY_HERE + ``` + +This is sufficient to start reporting unhandled exceptions to Bugsnag. + +### Running the example + +Run the example using: + +```shell +bundle exec bin/rails server +``` + +Once the server is running, head to the default path for more information on Bugsnag logging examples. + +## Sidekiq in Rails + +Sidekiq requires a datastore to run, this example uses [redis](https://redis.io/), installation instructions for which can be found [here](https://redis.io/topics/quickstart) and an official docker image can be found [here](https://hub.docker.com/_/redis/). + +### Configuration + +Once the configuration has been added to the Rails environment there is no need to further configure Sidekiq. + +### Running the examples + +Start the Rails server as mentioned above. + +Navigate to the `/sidekiq` page and run any of the examples using the links provided. + +The worker code can be found in `app/workers/sidekiq_workers.rb`. + +To process the jobs, run Sidekiq using the following command: + +```shell +bundle exec sidekiq +``` + +## Que in Rails + +Que requires a database backend in order to queue jobs. By default this database will be PostgreSQL although this can be changed via options as detailed in [the que documentation](https://github.com/chanks/que). + +Once PostgreSQL is set up as detailed using [the PostgreSQL documentation](https://www.postgresql.org/docs/), ensure Que can connect correctly before running any of the following examples which reference a `quedb` that can be created with the following command: + +```shell +createdb quedb +``` + +You can configure your connection in the `config/database.yml` file. + +### Configuration + +All tasks run with Que should set the rails environment to `que`. This ensures that the correct database and connection settings are used. +Do this by prepending `RAILS_ENV=que` before each command, or run: + +```shell +export RAILS_ENV=que +``` + +Ensure that the initial Que setup is complete by running: + +```shell +bundle exec bin/rails generate que:install +``` + +and + +```shell +bundle exec bin/rake db:migrate +``` + +Further configuration will be taken from the Rails environment. + +### Running the examples + +Start the Rails server as mentioned above. + +Navigate to the `/que` page and queue jobs for any of the examples using links provided. + +To process the jobs, run Que using the cli command: + +```shell +bundle exec que ./config/environment.rb +``` + +## Resque in Rails + +Resque requires a datastore to run, this example uses [redis](https://redis.io/), installation instructions for which can be found [here](https://redis.io/topics/quickstart) and an official docker image can be found [here](https://hub.docker.com/_/redis/). + +### Configuration + +Resque can be configured by using the Rails environment by making sure it depends on the `environment` task. This can be achieved when running the worker: + +```shell +QUEUE=crash bundle exec rake environment resque:work +``` + +Or by creating a task, `resque:setup`, that depends on the `environment` task. An example of this can be found in `lib/tasks/resque:setup.rake`. + +### Running the examples + +Start the Rails server as mentioned above. + +Navigate to the `/resque` page and queue any of the examples using links provided. + +To process the queues, run the `resque:work` task as stated in the example webpage. In order to process any of the queues on a single thread start the resque worker using the command: + +```shell +QUEUE=crash,callback,metadata bundle exec rake resque:work +``` diff --git a/example/rails-60/Rakefile b/example/rails-60/Rakefile new file mode 100644 index 000000000..e85f91391 --- /dev/null +++ b/example/rails-60/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/example/rails-60/app/assets/config/manifest.js b/example/rails-60/app/assets/config/manifest.js new file mode 100644 index 000000000..591819335 --- /dev/null +++ b/example/rails-60/app/assets/config/manifest.js @@ -0,0 +1,2 @@ +//= link_tree ../images +//= link_directory ../stylesheets .css diff --git a/example/rails-60/app/assets/images/.keep b/example/rails-60/app/assets/images/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/example/rails-60/app/channels/application_cable/channel.rb b/example/rails-60/app/channels/application_cable/channel.rb new file mode 100644 index 000000000..d67269728 --- /dev/null +++ b/example/rails-60/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/example/rails-60/app/channels/application_cable/connection.rb b/example/rails-60/app/channels/application_cable/connection.rb new file mode 100644 index 000000000..0ff5442f4 --- /dev/null +++ b/example/rails-60/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/example/rails-60/app/controllers/application_controller.rb b/example/rails-60/app/controllers/application_controller.rb new file mode 100644 index 000000000..4be69567f --- /dev/null +++ b/example/rails-60/app/controllers/application_controller.rb @@ -0,0 +1,50 @@ +class ApplicationController < ActionController::Base + def crash + raise 'Bugsnag Rails demo says: It crashed! ' \ + 'Go check bugsnag.com for a new notification' + end + + def callback + Bugsnag.before_notify_callbacks << proc { |report| + report.add_tab(:diagnostics, { + message: 'Rails v6.0 demo says: Everything is great', + code: 200 + }) + } + + raise 'Bugsnag Rails demo says: It crashed! But, due to the attached callback' \ + 'the exception has meta information. Go check ' \ + 'bugsnag.com for a new notification (see the Diagnostics tab)!' + end + + def notify + Bugsnag.notify(RuntimeError.new("Bugsnag Rails demo says: False alarm, your application didn't crash")) + end + + def data + error = RuntimeError.new("Bugsnag Rails demo says: False alarm, your application didn't crash") + + Bugsnag.notify(error) do |report| + report.add_tab(:user, { + username: 'bob-hoskins', + email: 'bugsnag@bugsnag.com', + registered_user: true + }) + + report.add_tab(:diagnostics, { + message: 'Rails demo says: Everything is great', + code: 200 + }) + end + end + + def severity + error = RuntimeError.new( + "Bugsnag Rails demo says: Look at the circle on the right side — it's different!" + ) + + Bugsnag.notify(error) do |report| + report.severity = 'info' + end + end +end diff --git a/example/rails-60/app/controllers/concerns/.keep b/example/rails-60/app/controllers/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/example/rails-60/app/controllers/que_controller.rb b/example/rails-60/app/controllers/que_controller.rb new file mode 100644 index 000000000..eb7529196 --- /dev/null +++ b/example/rails-60/app/controllers/que_controller.rb @@ -0,0 +1,14 @@ +require './app/jobs/que_crash' +require './app/jobs/que_callback' + +class QueController < ActionController::Base + layout "application" + + def crash + QueCrash.enqueue + end + + def callbacks + QueCallback.enqueue + end +end diff --git a/example/rails-60/app/controllers/resque_controller.rb b/example/rails-60/app/controllers/resque_controller.rb new file mode 100644 index 000000000..2bdea9196 --- /dev/null +++ b/example/rails-60/app/controllers/resque_controller.rb @@ -0,0 +1,15 @@ +class ResqueController < ActionController::Base + layout "application" + + def crash + Resque.enqueue(ResqueWorkers::Crash) + end + + def metadata + Resque.enqueue(ResqueWorkers::Metadata) + end + + def callbacks + Resque.enqueue(ResqueWorkers::Callback) + end +end diff --git a/example/rails-60/app/controllers/sidekiq_controller.rb b/example/rails-60/app/controllers/sidekiq_controller.rb new file mode 100644 index 000000000..b925be414 --- /dev/null +++ b/example/rails-60/app/controllers/sidekiq_controller.rb @@ -0,0 +1,17 @@ +require './app/workers/sidekiq_workers' + +class SidekiqController < ActionController::Base + layout "application" + + def crash + SidekiqWorkers::CrashWorker.perform_async + end + + def metadata + SidekiqWorkers::MetadataWorker.perform_async + end + + def callbacks + SidekiqWorkers::CallbackWorker.perform_async + end +end diff --git a/example/rails-60/app/helpers/application_helper.rb b/example/rails-60/app/helpers/application_helper.rb new file mode 100644 index 000000000..de6be7945 --- /dev/null +++ b/example/rails-60/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/example/rails-60/app/javascript/channels/consumer.js b/example/rails-60/app/javascript/channels/consumer.js new file mode 100644 index 000000000..0eceb59b1 --- /dev/null +++ b/example/rails-60/app/javascript/channels/consumer.js @@ -0,0 +1,6 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. + +import { createConsumer } from "@rails/actioncable" + +export default createConsumer() diff --git a/example/rails-60/app/javascript/channels/index.js b/example/rails-60/app/javascript/channels/index.js new file mode 100644 index 000000000..0cfcf7491 --- /dev/null +++ b/example/rails-60/app/javascript/channels/index.js @@ -0,0 +1,5 @@ +// Load all the channels within this directory and all subdirectories. +// Channel files must be named *_channel.js. + +const channels = require.context('.', true, /_channel\.js$/) +channels.keys().forEach(channels) diff --git a/example/rails-60/app/javascript/packs/application.js b/example/rails-60/app/javascript/packs/application.js new file mode 100644 index 000000000..9cd55d4b9 --- /dev/null +++ b/example/rails-60/app/javascript/packs/application.js @@ -0,0 +1,17 @@ +// This file is automatically compiled by Webpack, along with any other files +// present in this directory. You're encouraged to place your actual application logic in +// a relevant structure within app/javascript and only use these pack files to reference +// that code so it'll be compiled. + +require("@rails/ujs").start() +require("turbolinks").start() +require("@rails/activestorage").start() +require("channels") + + +// Uncomment to copy all static images under ../images to the output folder and reference +// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>) +// or the `imagePath` JavaScript helper below. +// +// const images = require.context('../images', true) +// const imagePath = (name) => images(name, true) diff --git a/example/rails-60/app/jobs/application_job.rb b/example/rails-60/app/jobs/application_job.rb new file mode 100644 index 000000000..d394c3d10 --- /dev/null +++ b/example/rails-60/app/jobs/application_job.rb @@ -0,0 +1,7 @@ +class ApplicationJob < ActiveJob::Base + # Automatically retry jobs that encountered a deadlock + # retry_on ActiveRecord::Deadlocked + + # Most jobs are safe to ignore if the underlying records are no longer available + # discard_on ActiveJob::DeserializationError +end diff --git a/example/rails-60/app/jobs/que_callback.rb b/example/rails-60/app/jobs/que_callback.rb new file mode 100644 index 000000000..34efe9a48 --- /dev/null +++ b/example/rails-60/app/jobs/que_callback.rb @@ -0,0 +1,14 @@ +class QueCallback < Que::Job + @run_at = proc { 5.seconds.from_now } + + def run(_options = {}) + Bugsnag.before_notify_callbacks << proc { |report| + report.add_tab(:diagnostics, { + message: 'Que demo says: Everything is great', + code: 200 + }) + } + + raise 'Oh no!' + end +end diff --git a/example/rails-60/app/jobs/que_crash.rb b/example/rails-60/app/jobs/que_crash.rb new file mode 100644 index 000000000..b6f2a3b04 --- /dev/null +++ b/example/rails-60/app/jobs/que_crash.rb @@ -0,0 +1,7 @@ +class QueCrash < Que::Job + @run_at = proc { 5.seconds.from_now } + + def run(_options = {}) + raise "Oh no" + end +end diff --git a/example/rails-60/app/mailers/application_mailer.rb b/example/rails-60/app/mailers/application_mailer.rb new file mode 100644 index 000000000..286b2239d --- /dev/null +++ b/example/rails-60/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/example/rails-60/app/models/application_record.rb b/example/rails-60/app/models/application_record.rb new file mode 100644 index 000000000..10a4cba84 --- /dev/null +++ b/example/rails-60/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/example/rails-60/app/models/concerns/.keep b/example/rails-60/app/models/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/example/rails-60/app/views/application/data.html.erb b/example/rails-60/app/views/application/data.html.erb new file mode 100644 index 000000000..3c050280e --- /dev/null +++ b/example/rails-60/app/views/application/data.html.erb @@ -0,0 +1,10 @@ +
Bugsnag Rails demo says: It didn't crash!
+ ++ But still go check your Bugsnag dashboard + for a new notification. +
+ +Check out the user
tab to see the metadata.
This application demonstrates the use of Bugsnag with the Rails web framework.
+ +For other examples within this application see the following pages:
+ + + ++ While testing the examples open + your Bugsnag dashboard + in order to see the example errors and exceptions being received. +
+ ++ Raises an error within the framework, generating a report in the + Bugsnag dashboard. +
++ Raises an exception within the framework, but with additional data + attached to the report. By registering a callback before the error + occurs useful data can be attached as a tab in the Bugsnag dashboard. +
+
+ Sends Bugsnag a report on demand using bugsnag.notify
.
+ Allows details of handled errors or information to be sent to the
+ Bugsnag dashboard without crashing your code.
+
+ Same as notify
but allows you to attach additional data
+ within a block
, similar to the
+ before_notify_callbacks
example above.
+
+ In this case we're adding information about the user to go into the
+ user
tab, and additional diagnostics as a
+ diagnostics
tab.
+
+ This uses the same mechanism as adding meta-data, but allows you to
+ set the severity
when notifying Bugsnag of the error.
+
+ Valid severities are error
, warning
, and
+ info
. Have a look on the dashboard to see the
+ difference in these severities.
+
Bugsnag Rails demo says: It didn't crash!
+ ++ But still go check your Bugsnag dashboard + for a new notification. +
+ + diff --git a/example/rails-60/app/views/application/severity.html.erb b/example/rails-60/app/views/application/severity.html.erb new file mode 100644 index 000000000..5954e03ee --- /dev/null +++ b/example/rails-60/app/views/application/severity.html.erb @@ -0,0 +1,5 @@ ++ Bugsnag Rails demo says: Look at the circle on the right side — it's different! +
+ + diff --git a/example/rails-60/app/views/layouts/application.html.erb b/example/rails-60/app/views/layouts/application.html.erb new file mode 100644 index 000000000..6a2702144 --- /dev/null +++ b/example/rails-60/app/views/layouts/application.html.erb @@ -0,0 +1,16 @@ + + + ++ Que has queued the callbacks task, check + your Bugsnag dashboard for the result! +
+ + diff --git a/example/rails-60/app/views/que/crash.html.erb b/example/rails-60/app/views/que/crash.html.erb new file mode 100644 index 000000000..d3d004644 --- /dev/null +++ b/example/rails-60/app/views/que/crash.html.erb @@ -0,0 +1,8 @@ ++ Que has queued the crash task, check + your Bugsnag dashboard for the result! +
+ + diff --git a/example/rails-60/app/views/que/index.html.erb b/example/rails-60/app/views/que/index.html.erb new file mode 100644 index 000000000..2568880cc --- /dev/null +++ b/example/rails-60/app/views/que/index.html.erb @@ -0,0 +1,41 @@ +This route demonstrates how to use Bugsnag with Que.
+ ++ While testing the examples open + your Bugsnag dashboard + in order to see the example errors and exceptions being received. +
+ ++ Make sure you have a PostgreSQL instance running that your test application + can connect to before running these examples. +
+ ++ Raises an error within the framework, generating a report in the + Bugsnag dashboard. +
++ Raises an exception within the framework, but with additional data + attached to the report. +
+ ++ By registering a callback before the error occurs useful data can + be attached as a tab in the Bugsnag dashboard. +
++ The callback task has been queued. +
+ ++ This can be executed by running: +
+ +QUEUE=callback bundle exec rake resque:work+ +
+ Check your Bugsnag dashboard for the result! +
+ + diff --git a/example/rails-60/app/views/resque/crash.html.erb b/example/rails-60/app/views/resque/crash.html.erb new file mode 100644 index 000000000..2d28f986e --- /dev/null +++ b/example/rails-60/app/views/resque/crash.html.erb @@ -0,0 +1,17 @@ ++ The crash task has been queued. +
+ ++ This can be executed by running: +
+ +QUEUE=crash bundle exec rake resque:work+ +
+ Check your Bugsnag dashboard for the result! +
+ + diff --git a/example/rails-60/app/views/resque/index.html.erb b/example/rails-60/app/views/resque/index.html.erb new file mode 100644 index 000000000..7f5e4d763 --- /dev/null +++ b/example/rails-60/app/views/resque/index.html.erb @@ -0,0 +1,64 @@ +This route demonstrates how to use Bugsnag with Rescue.
+ ++ While testing the examples open + your Bugsnag dashboard + in order to see the example errors and exceptions being received. +
+ ++ Make sure you have a Redis instance running that your test application can + connect to before running these examples. +
+ ++ While each queue can be run individually, to run Resque so that it + automatically executes each task, use: +
+ +QUEUE=crash,callback,metadata bundle exec rake resque:work+ +
+ Raises an error within the framework, generating a report in the + Bugsnag dashboard. +
++ Raises an exception within the framework, but with additional data + attached to the report. +
+ ++ By registering a callback before the error occurs useful data can + be attached as a tab in the Bugsnag dashboard. +
+
+ Same as notify
but allows you to attach additional data
+ within a block
, similar to the
+ "crash and use callbacks" example above.
+
+ In this case we're adding information about the queue to go into the
+ queue
tab, and additional diagnostics as a
+ diagnostics
tab.
+
+ The metadata task has been queued. +
+ ++ This can be executed by running: +
+ +QUEUE=metadata bundle exec rake resque:work+ +
+ Check your Bugsnag dashboard for the result! +
+ + diff --git a/example/rails-60/app/views/sidekiq/callbacks.html.erb b/example/rails-60/app/views/sidekiq/callbacks.html.erb new file mode 100644 index 000000000..14bb48406 --- /dev/null +++ b/example/rails-60/app/views/sidekiq/callbacks.html.erb @@ -0,0 +1,12 @@ ++ Sidekiq is performing a task that will crash, but registers a callback + before this to attach additional metadata. +
+ ++ Check your Bugsnag dashboard for the result! +
+ + diff --git a/example/rails-60/app/views/sidekiq/crash.html.erb b/example/rails-60/app/views/sidekiq/crash.html.erb new file mode 100644 index 000000000..010630a2a --- /dev/null +++ b/example/rails-60/app/views/sidekiq/crash.html.erb @@ -0,0 +1,8 @@ ++ Sidekiq is performing a task that will crash, so check + your Bugsnag dashboard for the result! +
+ + diff --git a/example/rails-60/app/views/sidekiq/index.html.erb b/example/rails-60/app/views/sidekiq/index.html.erb new file mode 100644 index 000000000..110b6746c --- /dev/null +++ b/example/rails-60/app/views/sidekiq/index.html.erb @@ -0,0 +1,47 @@ +This route demonstrates how to use Bugsnag with Sidekiq.
+ ++ While testing the examples open + your Bugsnag dashboard + in order to see the example errors and exceptions being received. +
+ ++ Make sure you have a Redis instance running that your test application can + connect to before running these examples. +
+ +Raises an error within the framework, generating a report in the Bugsnag dashboard.
++ Raises an exception within the framework, but with additional data + attached to the report. By registering a callback before the error + occurs useful data can be attached as a tab in the Bugsnag dashboard. +
+
+ Sends Bugsnag a report on demand using bugsnag.notify
+ and attaches additional data within a block
, similar to
+ the "Crash and use callbacks" example above. In this case we're
+ adding information about the function being called to go into the
+ function
tab, and additional diagnostics
+ as a diagnostics
tab.
+
+ Sidekiq is performing a task that will notify an error with some metadata + without crashing. +
+ ++ Check your Bugsnag dashboard for the result! +
+ + diff --git a/example/rails-60/app/workers/resque_workers.rb b/example/rails-60/app/workers/resque_workers.rb new file mode 100644 index 000000000..1b0feee35 --- /dev/null +++ b/example/rails-60/app/workers/resque_workers.rb @@ -0,0 +1,47 @@ +module ResqueWorkers + class Crash + @queue = :crash + + def self.perform + raise 'Crashed - Check your Bugsnag dashboard' + end + end + + # Unhandled with callback Exception example + class Callback + @queue = :callback + + def self.perform + Bugsnag.before_notify_callbacks << proc { |report| + report.add_tab(:diagnostics, { + message: 'Resque demo says: Everything is great', + code: 200 + }) + } + + raise 'Crashed - Check the Bugsnag dashboard for diagnostic data' + end + end + + # Handled example with additional data + class Metadata + @queue = :metadata + + def self.perform + error = Exception.new "Didn't crash, but sent a notification anyway" + + Bugsnag.notify(error) do |report| + report.add_tab(:queue, { + :name => "metadata", + :fatal => false + }) + + report.add_tab(:diagnostics, { + :message => 'Resque demo says: Everything is great' + }) + end + + puts "The Resque worker hasn't crashed, but it has sent a notification, with additional data to the dashboard" + end + end +end diff --git a/example/rails-60/app/workers/sidekiq_workers.rb b/example/rails-60/app/workers/sidekiq_workers.rb new file mode 100644 index 000000000..59bfddef1 --- /dev/null +++ b/example/rails-60/app/workers/sidekiq_workers.rb @@ -0,0 +1,47 @@ +module SidekiqWorkers + class CallbackWorker + include Sidekiq::Worker + + sidekiq_options :retry => false + + def perform + Bugsnag.before_notify_callbacks << proc { |report| + report.add_tab(:diagnostics, { + message: 'Sidekiq demo says: Everything is great', + code: 200 + }) + } + + raise 'Sidekiq crashed, but the callback added metadata - Check your Bugsnag dashboard' + end + end + + class CrashWorker + include Sidekiq::Worker + sidekiq_options :retry => false + + def perform + raise 'Sidekiq crashed - Check your Bugsnag dashboard' + end + end + + class MetadataWorker + include Sidekiq::Worker + sidekiq_options :retry => false + + def perform + error = Exception.new('Sidekiq notified with metadata - Check your Bugsnag dashboard') + + Bugsnag.notify(error) do |report| + report.add_tab(:function, { + name: 'Metadata', + fatal: false + }) + + report.add_tab(:diagnostics, { + message: 'Sidekiq demo says: Everything is great', + }) + end + end + end +end diff --git a/example/rails-60/babel.config.js b/example/rails-60/babel.config.js new file mode 100644 index 000000000..12f98da5a --- /dev/null +++ b/example/rails-60/babel.config.js @@ -0,0 +1,72 @@ +module.exports = function(api) { + var validEnv = ['development', 'test', 'production'] + var currentEnv = api.env() + var isDevelopmentEnv = api.env('development') + var isProductionEnv = api.env('production') + var isTestEnv = api.env('test') + + if (!validEnv.includes(currentEnv)) { + throw new Error( + 'Please specify a valid `NODE_ENV` or ' + + '`BABEL_ENV` environment variables. Valid values are "development", ' + + '"test", and "production". Instead, received: ' + + JSON.stringify(currentEnv) + + '.' + ) + } + + return { + presets: [ + isTestEnv && [ + '@babel/preset-env', + { + targets: { + node: 'current' + } + } + ], + (isProductionEnv || isDevelopmentEnv) && [ + '@babel/preset-env', + { + forceAllTransforms: true, + useBuiltIns: 'entry', + corejs: 3, + modules: false, + exclude: ['transform-typeof-symbol'] + } + ] + ].filter(Boolean), + plugins: [ + 'babel-plugin-macros', + '@babel/plugin-syntax-dynamic-import', + isTestEnv && 'babel-plugin-dynamic-import-node', + '@babel/plugin-transform-destructuring', + [ + '@babel/plugin-proposal-class-properties', + { + loose: true + } + ], + [ + '@babel/plugin-proposal-object-rest-spread', + { + useBuiltIns: true + } + ], + [ + '@babel/plugin-transform-runtime', + { + helpers: false, + regenerator: true, + corejs: false + } + ], + [ + '@babel/plugin-transform-regenerator', + { + async: false + } + ] + ].filter(Boolean) + } +} diff --git a/example/rails-60/config.ru b/example/rails-60/config.ru new file mode 100644 index 000000000..f7ba0b527 --- /dev/null +++ b/example/rails-60/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/example/rails-60/config/application.rb b/example/rails-60/config/application.rb new file mode 100644 index 000000000..7606973a3 --- /dev/null +++ b/example/rails-60/config/application.rb @@ -0,0 +1,19 @@ +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Rails60 + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 6.0 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + end +end diff --git a/example/rails-60/config/boot.rb b/example/rails-60/config/boot.rb new file mode 100644 index 000000000..b9e460cef --- /dev/null +++ b/example/rails-60/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/example/rails-60/config/cable.yml b/example/rails-60/config/cable.yml new file mode 100644 index 000000000..e168aa54b --- /dev/null +++ b/example/rails-60/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: test + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: rails_60_production diff --git a/example/rails-60/config/credentials.yml.enc b/example/rails-60/config/credentials.yml.enc new file mode 100644 index 000000000..e015aa824 --- /dev/null +++ b/example/rails-60/config/credentials.yml.enc @@ -0,0 +1 @@ +KQhHHa39d1cmOiryTxmJvb3odw1lJYakJGSiQ8FJQGokXbkGPDUpG8UPuuvdKdwvh2O03jgdRlZ5ZeGtDgUeEVgSeWdGsvAXH9mwKfLxqm5lQuq5DfEnOOEpzAoReLpu4Hp7kmdJEwz/APbiEZ74NEFz94nDyWFkZwKsH1NSATVicP3gvGO0fgY0/ADOGcezOLcMrHCckCIap1oe4Fr68R0YbQxUhaNfZzsQN2RPHCw4fvQARYZcEPiTpoPRMwZsxkFdWQCpUUuQASdMFuu3+Cq//+Q57V+k3F353s52pQ1qCX/Oq0pBe8XXTzzQVK+x35xD7puFsz3N7wa2RtkmdUR0SsS/b92MRHMB94KjnQWLn7FS8/rYtDaiv6WnrXSGzwhOOtW8M3vOi35F1yoiUuM6bfIW68sCR3LR--hk5vbvf0FXhi6gl0--1WNlajBXqT6SQsGjKFHIlQ== \ No newline at end of file diff --git a/example/rails-60/config/database.yml b/example/rails-60/config/database.yml new file mode 100644 index 000000000..832c7883a --- /dev/null +++ b/example/rails-60/config/database.yml @@ -0,0 +1,32 @@ +# SQLite. Versions 3.8.0 and up are supported. +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +que: + adapter: postgresql + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + host: localhost + timeout: 5000 + database: quedb + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/example/rails-60/config/environment.rb b/example/rails-60/config/environment.rb new file mode 100644 index 000000000..426333bb4 --- /dev/null +++ b/example/rails-60/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/example/rails-60/config/environments/development.rb b/example/rails-60/config/environments/development.rb new file mode 100644 index 000000000..66df51f6f --- /dev/null +++ b/example/rails-60/config/environments/development.rb @@ -0,0 +1,62 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations. + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/example/rails-60/config/environments/production.rb b/example/rails-60/config/environments/production.rb new file mode 100644 index 000000000..244c22e00 --- /dev/null +++ b/example/rails-60/config/environments/production.rb @@ -0,0 +1,112 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress CSS using a preprocessor. + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain. + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment). + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "rails_60_production" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + + # Inserts middleware to perform automatic connection switching. + # The `database_selector` hash is used to pass options to the DatabaseSelector + # middleware. The `delay` is used to determine how long to wait after a write + # to send a subsequent read to the primary. + # + # The `database_resolver` class is used by the middleware to determine which + # database is appropriate to use based on the time delay. + # + # The `database_resolver_context` class is used by the middleware to set + # timestamps for the last write to the primary. The resolver uses the context + # class timestamps to determine how long to wait before reading from the + # replica. + # + # By default Rails will store a last write timestamp in the session. The + # DatabaseSelector middleware is designed as such you can define your own + # strategy for connection switching and pass that into the middleware through + # these configuration options. + # config.active_record.database_selector = { delay: 2.seconds } + # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver + # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session +end diff --git a/example/rails-60/config/environments/que.rb b/example/rails-60/config/environments/que.rb new file mode 100644 index 000000000..66df51f6f --- /dev/null +++ b/example/rails-60/config/environments/que.rb @@ -0,0 +1,62 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations. + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/example/rails-60/config/environments/test.rb b/example/rails-60/config/environments/test.rb new file mode 100644 index 000000000..0cb24249b --- /dev/null +++ b/example/rails-60/config/environments/test.rb @@ -0,0 +1,49 @@ +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + config.cache_classes = false + config.action_view.cache_template_loading = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.cache_store = :null_store + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations. + # config.action_view.raise_on_missing_translations = true +end diff --git a/example/rails-60/config/initializers/application_controller_renderer.rb b/example/rails-60/config/initializers/application_controller_renderer.rb new file mode 100644 index 000000000..89d2efab2 --- /dev/null +++ b/example/rails-60/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/example/rails-60/config/initializers/assets.rb b/example/rails-60/config/initializers/assets.rb new file mode 100644 index 000000000..4b828e80c --- /dev/null +++ b/example/rails-60/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/example/rails-60/config/initializers/backtrace_silencers.rb b/example/rails-60/config/initializers/backtrace_silencers.rb new file mode 100644 index 000000000..59385cdf3 --- /dev/null +++ b/example/rails-60/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/example/rails-60/config/initializers/bugsnag.rb b/example/rails-60/config/initializers/bugsnag.rb new file mode 100644 index 000000000..58c57fbf6 --- /dev/null +++ b/example/rails-60/config/initializers/bugsnag.rb @@ -0,0 +1,3 @@ +Bugsnag.configure do |config| + config.api_key = "YOUR_API_KEY_HERE" +end diff --git a/example/rails-60/config/initializers/content_security_policy.rb b/example/rails-60/config/initializers/content_security_policy.rb new file mode 100644 index 000000000..35d0f26fc --- /dev/null +++ b/example/rails-60/config/initializers/content_security_policy.rb @@ -0,0 +1,30 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # If you are using webpack-dev-server then specify webpack-dev-server host +# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Set the nonce only to specific directives +# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/example/rails-60/config/initializers/cookies_serializer.rb b/example/rails-60/config/initializers/cookies_serializer.rb new file mode 100644 index 000000000..5a6a32d37 --- /dev/null +++ b/example/rails-60/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/example/rails-60/config/initializers/filter_parameter_logging.rb b/example/rails-60/config/initializers/filter_parameter_logging.rb new file mode 100644 index 000000000..4a994e1e7 --- /dev/null +++ b/example/rails-60/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/example/rails-60/config/initializers/inflections.rb b/example/rails-60/config/initializers/inflections.rb new file mode 100644 index 000000000..ac033bf9d --- /dev/null +++ b/example/rails-60/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/example/rails-60/config/initializers/mime_types.rb b/example/rails-60/config/initializers/mime_types.rb new file mode 100644 index 000000000..dc1899682 --- /dev/null +++ b/example/rails-60/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/example/rails-60/config/initializers/wrap_parameters.rb b/example/rails-60/config/initializers/wrap_parameters.rb new file mode 100644 index 000000000..bbfc3961b --- /dev/null +++ b/example/rails-60/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/example/rails-60/config/locales/en.yml b/example/rails-60/config/locales/en.yml new file mode 100644 index 000000000..cf9b342d0 --- /dev/null +++ b/example/rails-60/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at https://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/example/rails-60/config/puma.rb b/example/rails-60/config/puma.rb new file mode 100644 index 000000000..5ed443774 --- /dev/null +++ b/example/rails-60/config/puma.rb @@ -0,0 +1,38 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +threads min_threads_count, max_threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked web server processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/example/rails-60/config/routes.rb b/example/rails-60/config/routes.rb new file mode 100644 index 000000000..b5f1747c3 --- /dev/null +++ b/example/rails-60/config/routes.rb @@ -0,0 +1,27 @@ +Rails.application.routes.draw do + # Vanilla rails routing + get '/', to: 'application#index' + get '/crash', to: 'application#crash' + get '/crash_with_callback', to: 'application#callback' + get '/notify', to: 'application#notify' + get '/notify_data', to: 'application#data' + get '/notify_severity', to: 'application#severity' + + # Sidekiq routing + get '/sidekiq', to: 'sidekiq#index' + get '/sidekiq/crash', to: 'sidekiq#crash' + get '/sidekiq/notify_data', to: 'sidekiq#metadata' + get '/sidekiq/crash_with_callback', to: 'sidekiq#callbacks' + + # Que routing + get '/que', to: 'que#index' + get '/que/crash', to: 'que#crash' + get '/que/notify_data', to: 'que#metadata' + get '/que/crash_with_callback', to: 'que#callbacks' + + # Resque routing + get '/resque', to: 'resque#index' + get '/resque/crash', to: 'resque#crash' + get '/resque/crash_with_callback', to: 'resque#callbacks' + get '/resque/notify_data', to: 'resque#metadata' +end diff --git a/example/rails-60/config/spring.rb b/example/rails-60/config/spring.rb new file mode 100644 index 000000000..db5bf1307 --- /dev/null +++ b/example/rails-60/config/spring.rb @@ -0,0 +1,6 @@ +Spring.watch( + ".ruby-version", + ".rbenv-vars", + "tmp/restart.txt", + "tmp/caching-dev.txt" +) diff --git a/example/rails-60/config/storage.yml b/example/rails-60/config/storage.yml new file mode 100644 index 000000000..d32f76e8f --- /dev/null +++ b/example/rails-60/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/example/rails-60/db/seeds.rb b/example/rails-60/db/seeds.rb new file mode 100644 index 000000000..1beea2acc --- /dev/null +++ b/example/rails-60/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) diff --git a/example/rails-60/lib/assets/.keep b/example/rails-60/lib/assets/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/example/rails-60/lib/tasks/resque:setup.rake b/example/rails-60/lib/tasks/resque:setup.rake new file mode 100644 index 000000000..1c97b45ea --- /dev/null +++ b/example/rails-60/lib/tasks/resque:setup.rake @@ -0,0 +1,5 @@ +require 'resque/tasks' + +task 'resque:setup' => :environment do + require './app/workers/resque_workers' +end diff --git a/example/rails-60/log/.keep b/example/rails-60/log/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/example/rails-60/public/404.html b/example/rails-60/public/404.html new file mode 100644 index 000000000..2be3af26f --- /dev/null +++ b/example/rails-60/public/404.html @@ -0,0 +1,67 @@ + + + +You may have mistyped the address or the page may have moved.
+If you are the application owner check the logs for more information.
+Maybe you tried to change something you didn't have access to.
+If you are the application owner check the logs for more information.
+If you are the application owner check the logs for more information.
+