Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress method redefined warnings #510

Merged
merged 2 commits into from
Sep 5, 2019
Merged

Conversation

pocke
Copy link
Contributor

@pocke pocke commented Dec 10, 2018

Goal

This gem has Ruby's warnings. This change will suppress them.

Reproduce

$ bundle exec ruby -w -Ilib -rbugsnag -e ''
/home/pocke/ghq/github.com/bugsnag/bugsnag-ruby/lib/bugsnag/configuration.rb:54: warning: method redefined; discarding old track_sessions
/home/pocke/ghq/github.com/bugsnag/bugsnag-ruby/lib/bugsnag/configuration.rb:55: warning: method redefined; discarding old track_sessions=
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.6.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:288: warning: method redefined; discarding old max_attempts
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/core_ext/module/attribute_accessors.rb:67: warning: previous definition of max_attempts was here
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.6.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:292: warning: method redefined; discarding old max_run_time
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/core_ext/module/attribute_accessors.rb:67: warning: previous definition of max_run_time was here

See the first two lines (other lines are dependency gem's warnings).

Changeset

This pull request does not change any interface.

Tests

No tests added.

Discussion

Alternative Approaches

Outstanding Questions

nothing

Linked issues

nothing

Review

For the submitter, initial self-review:

  • Commented on code changes inline explain the reasoning behind the approach
  • Reviewed the test cases added for completeness and possible points for discussion
  • A changelog entry was added for the goal of this pull request
  • Check the scope of the changeset - is everything in the diff required for the pull request?
  • This pull request is ready for:
    • Initial review of the intended approach, not yet feature complete
    • Structural review of the classes, functions, and properties modified
    • Final review

For the pull request reviewer(s), this changeset has been reviewed for:

  • Consistency across platforms for structures or concepts added or modified
  • Consistency between the changeset and the goal stated above
  • Internal consistency with the rest of the library - is there any overlap between existing interfaces and any which have been added?
  • Usage friction - is the proposed change in usage cumbersome or complicated?
  • Performance and complexity - are there any cases of unexpected O(n^3) when iterating, recursing, flat mapping, etc?
  • Concurrency concerns - if components are accessed asynchronously, what issues will arise
  • Thoroughness of added tests and any missing edge cases
  • Idiomatic use of the language

Problem
===

`Bugsnag::Configuration#track_sessions` and `Bugsnag::Configuration#track_sessions=` are defined twice. Ruby warns them.

Reproduce
===

```
$ bundle exec ruby -w -Ilib -rbugsnag -e ''
/home/pocke/ghq/github.com/bugsnag/bugsnag-ruby/lib/bugsnag/configuration.rb:54: warning: method redefined; discarding old track_sessions
/home/pocke/ghq/github.com/bugsnag/bugsnag-ruby/lib/bugsnag/configuration.rb:55: warning: method redefined; discarding old track_sessions=
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.6.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:288: warning: method redefined; discarding old max_attempts
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/core_ext/module/attribute_accessors.rb:67: warning: previous definition of max_attempts was here
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.6.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:292: warning: method redefined; discarding old max_run_time
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/core_ext/module/attribute_accessors.rb:67: warning: previous definition of max_run_time was here
```

See the first two lines (other lines are dependency gem's warnings).

Cause
===

`track_sessions` and `track_sessions=` are defined by `attr_accessor` and `alias`. The definition by `attr_accessor` has no meaning because `alias` conceal it.

Solution
===

Remove the `attr_accessor` definition.
@tomlongridge tomlongridge changed the base branch from master to next September 5, 2019 11:59
@tomlongridge tomlongridge merged commit 2168531 into bugsnag:next Sep 5, 2019
@tomlongridge
Copy link
Contributor

Thanks for the contribution @pocke

@pocke pocke deleted the ruby-waring branch September 5, 2019 15:10
@mattdyoung mattdyoung added the released This feature/bug fix has been released label Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This feature/bug fix has been released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants