You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Autocorrect for Performance/BigDecimalWithNumericArgument cop converts an existing code to a valid code
Actual behavior
Autocorrect for Performance/BigDecimalWithNumericArgument cop converts an existing code to an invalid code.
Steps to reproduce the problem
Sinc #463, autocorrect for Performance/BigDecimalWithNumericArgument cop converts string argument of BigDecimal to numeric. But, if a value is float, that generates an invalid code.
For example, if we have BigDecimal("0.8"), autocorrect converts it to BigDecimal(0.8), but this is an invalid code.
require'bigdecimal'BigDecimal(0.8)(irb):3:in`BigDecimal': can't omit precision for a Float. (ArgumentError)BigDecimal(0.8) ^^^ from (irb):3:in `<main>' from <internal:kernel>:187:in `loop'from/home/yyagi/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/irb-1.14.0/exe/irb:9:in`<top (required)>' from /home/yyagi/.rbenv/versions/3.3.5/bin/irb:25:in `load' from /home/yyagi/.rbenv/versions/3.3.5/bin/irb:25:in `<main>'
RuboCop version
Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:
You can see extension cop versions (e.g. rubocop-performance, rubocop-rails, and others) output by rubocop -V,
include them as well. Here's an example:
Expected behavior
Autocorrect for
Performance/BigDecimalWithNumericArgument
cop converts an existing code to a valid codeActual behavior
Autocorrect for
Performance/BigDecimalWithNumericArgument
cop converts an existing code to an invalid code.Steps to reproduce the problem
Sinc #463, autocorrect for
Performance/BigDecimalWithNumericArgument
cop converts string argument ofBigDecimal
to numeric. But, if a value is float, that generates an invalid code.For example, if we have
BigDecimal("0.8")
, autocorrect converts it toBigDecimal(0.8)
, but this is an invalid code.RuboCop version
Include the output of
rubocop -V
orbundle exec rubocop -V
if using Bundler. Here's an example:You can see extension cop versions (e.g. rubocop-performance, rubocop-rails, and others) output by
rubocop -V
,include them as well. Here's an example:
Additional Information
I understand that change is caused by #454. But, if a value is a float, I think
BigDecimal("0.8")
is still faster thanBigDecimal(0.8, 0)
.The text was updated successfully, but these errors were encountered: