Skip to content

Commit

Permalink
Add bad example for BigDecimalWithNumericArgument
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasocon committed Jul 7, 2020
1 parent b91d5a4 commit 797cbe0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
13 changes: 6 additions & 7 deletions docs/modules/ROOT/pages/cops_performance.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,17 @@ This cop identifies places where numeric argument to BigDecimal should be
converted to string. Initializing from String is faster
than from Numeric for BigDecimal.

BigDecimal(1, 2)
BigDecimal(1.2, 3, exception: true)

# good
BigDecimal('1', 2)
BigDecimal('1.2', 3, exception: true)

=== Examples

[source,ruby]
----
# bad
BigDecimal(1, 2)
BigDecimal(1.2, 3, exception: true)
# good
BigDecimal('1', 2)
BigDecimal('1.2', 3, exception: true)
----

== Performance/BindCall
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ module Performance
# than from Numeric for BigDecimal.
#
# @example
#
# # bad
# BigDecimal(1, 2)
# BigDecimal(1.2, 3, exception: true)
# BigDecimal(1, 2)
# BigDecimal(1.2, 3, exception: true)
#
# # good
# BigDecimal('1', 2)
# BigDecimal('1.2', 3, exception: true)
# BigDecimal('1', 2)
# BigDecimal('1.2', 3, exception: true)
#
class BigDecimalWithNumericArgument < Cop
MSG = 'Convert numeric argument to string before passing to `BigDecimal`.'
Expand Down

0 comments on commit 797cbe0

Please sign in to comment.