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

"warning: attribute accessor as module_function" (with JRuby) #1108

Closed
thbar opened this issue Oct 19, 2022 · 3 comments · Fixed by #1138
Closed

"warning: attribute accessor as module_function" (with JRuby) #1108

thbar opened this issue Oct 19, 2022 · 3 comments · Fixed by #1138

Comments

@thbar
Copy link
Contributor

thbar commented Oct 19, 2022

I've noticed a warning during our test suite with JRuby (9.3.1.0, 9.3.8.0), so I'm reporting it here:

/Users/thbar/.rbenv/versions/jruby-9.3.1.0/lib/ruby/gems/shared/gems/rollbar-3.3.1/lib/rollbar/json.rb:8: 
warning: attribute accessor as module_function

I do not know yet why it appears only with JRuby (a good part of the test suite is also compatible with MRI 2.7.x), nor if it is problematic at this point.

@thbar
Copy link
Contributor Author

thbar commented Oct 19, 2022

@thbar
Copy link
Contributor Author

thbar commented Aug 4, 2023

GeoffKarnov added a commit to GeoffKarnov/rollbar-gem that referenced this issue Dec 4, 2023
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
waltjones pushed a commit that referenced this issue Dec 19, 2023
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.

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 (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: #1108
@thbar
Copy link
Contributor Author

thbar commented Mar 2, 2024

Thanks for the fix @waltjones!

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 a pull request may close this issue.

1 participant