Skip to content

Commit

Permalink
Fix warning: attribute accessor as module_function (#1138)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
GeoffKarnov authored Dec 19, 2023
1 parent d14043c commit 54b192d
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lib/rollbar/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ module Rollbar
module JSON # :nodoc:
module_function

attr_writer :options_module

def dump(object)
Rollbar.plugins.get('basic_socket').load_scoped!(true) do
::JSON.generate(object)
Expand Down

0 comments on commit 54b192d

Please sign in to comment.