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

Fix warning: attribute accessor as module_function #1138

Merged

Conversation

GeoffKarnov
Copy link
Contributor

@GeoffKarnov GeoffKarnov commented Dec 4, 2023

Description of the change

When Running rspec with --warnings enabled a warning is emitted by the rollbar gem.

$ rspec --warnings
/my/path/ruby-3.2.2/gems/rollbar-3.4.1/lib/rollbar/json.rb:8: warning: attribute accessor as module_function

This is caused by the line

attr_writer :options_module

Within lib/rollbar/json.rb

The line was introduced here, when there was a more complicated way of configuring the json parser.

e33f10e#diff-9e64389290ff8e4e50cba9436521333bdd3307baa63ed84b74f0f9b28a6cfceaR13

However in 2019 this code was removed, and replaced with Ruby's JSON module

de45e80#diff-9e64389290ff8e4e50cba9436521333bdd3307baa63ed84b74f0f9b28a6cfceaL39-L41

But the attr_writer was not removed.

As the options_module attribute writer is not documented or referenced anywhere else in the project I believe it can be removed.

This commit removes the unused attr_writer and fixes the warning.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Maintenance
  • New release

Related issues

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests - The removed line was not previously tested, it is still not tested, but it is also not there.
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers assigned
  • Issue from task tracker has a link to this pull request
  • Changes have been reviewed by at least one other engineer

When Running rspec with --warnings enabled a warning is emitted by the
rollbar gem.

```
$ rspec --warnings
/my/path/ruby-3.2.2/gems/rollbar-3.4.1/lib/rollbar/json.rb:8: warning: attribute accessor as module_function
```

This is caused by the line
```
attr_writer :options_module
```
Within [lib/rollbar/json.rb](https://github.com/rollbar/rollbar-gem/blob/8c6a9e94629c0a8b964f0a3b13eab742c3800841/lib/rollbar/json.rb#L8)

The line was introduced here, when there was a more complicated way of configuring the json parser.

rollbar@e33f10e#diff-9e64389290ff8e4e50cba9436521333bdd3307baa63ed84b74f0f9b28a6cfceaR13

However in 2019 this code was removed, and replaced with Ruby's JSON module

rollbar@de45e80#diff-9e64389290ff8e4e50cba9436521333bdd3307baa63ed84b74f0f9b28a6cfceaL39-L41

But the attr_writer was (accidentally?) not removed.

As the `options_module` attribute writer is not documented or referenced anywhere else in the project I believe it can be removed.

This commit removes the unused `attr_writer` and fixes the warning.

Fixes: rollbar#1108
Copy link
Contributor

@waltjones waltjones left a comment

Choose a reason for hiding this comment

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

@GeoffKarnov Thank you for the PR and the detailed description.

@waltjones waltjones merged commit 54b192d into rollbar:master Dec 19, 2023
25 checks passed
@GeoffKarnov GeoffKarnov deleted the fix_attribute_accessor_warning branch January 2, 2024 10:15
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.

"warning: attribute accessor as module_function" (with JRuby)
2 participants