Skip to content

Conversation

@pramod-mahadev-bhat-1996
Copy link
Contributor

@pramod-mahadev-bhat-1996 pramod-mahadev-bhat-1996 commented Mar 18, 2025

This pull request introduces a new custom RuboCop cop to ensure the deprecation of Bugsnag in the codebase and mandates the usage of ErrorNotifierService for error notifications. The following updates have been implemented:

JIRA Ticket:- https://bugcrowd.atlassian.net/browse/BC-30344

Key Changes:

  1. New RuboCop Custom Cop to Prevent Bugsnag Usage:

    • File: lib/rubocop/cop/bugcrowd/prevent_bugsnag_usage.rb
    • A new custom RuboCop cop, PreventBugsnagUsage, has been implemented. This cop scans for and raises offenses whenever Bugsnag.notify or the Bugsnag constant is used in the codebase. The offense message prompts the developer to use ErrorNotifierService instead, reflecting the recent shift in error notification handling in the application.
  2. Update to RuboCop Configuration:

    • File: config/default.yml
    • The newly created PreventBugsnagUsage cop is added to the RuboCop configuration, ensuring that it is enabled for the relevant Ruby files in the project (app/**/*.rb, lib/**/*.rb).
  3. RuboCop Cop Registration:

    • File: lib/rubocop/cop/bugcrowd_cops.rb
    • The new cop, PreventBugsnagUsage, is registered within the RuboCop setup to allow for seamless integration and enforcement during linting.
  4. Unit Tests for the New Cop:

    • File: spec/rubocop/cop/bugcrowd/prevent_bugsnag_usage_spec.rb
    • A comprehensive set of test cases has been added to validate the behavior of the new cop. These tests ensure:
      • An offense is raised when Bugsnag.notify is used.
      • An offense is raised when Bugsnag is referenced as a constant.
      • No offense is raised when ErrorNotifierService is used.
      • No offense is raised when an alternative service is used.

Summary of Changes:

  • New RuboCop Cop: PreventBugsnagUsage that enforces the non-usage of Bugsnag in favor of ErrorNotifierService.
  • Configuration Update: Added the cop to the RuboCop configuration for relevant Ruby files.
  • Test Coverage: RSpec tests to ensure the correct functionality of the cop.

This PR ensures that the application aligns with the updated error notification strategy by deprecating Bugsnag and requiring ErrorNotifierService. The implementation aims to improve maintainability and consistency across the codebase.

Screenshot 2025-03-21 at 11 57 13 AM

@pramod-mahadev-bhat-1996 pramod-mahadev-bhat-1996 changed the title Bc 26568 [BC-26568] Add rubocop warning for the use of Bugsnag Mar 20, 2025
Copy link

@ram-bugcrowd ram-bugcrowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pramod-mahadev-bhat-1996 pramod-mahadev-bhat-1996 marked this pull request as ready for review March 21, 2025 04:50
Copy link

@mandargokhale-Bugcrowd mandargokhale-Bugcrowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@pramod-mahadev-bhat-1996 pramod-mahadev-bhat-1996 merged commit 9e2f51d into master Mar 21, 2025
4 checks passed
@pramod-mahadev-bhat-1996 pramod-mahadev-bhat-1996 deleted the BC-26568 branch March 21, 2025 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants