Skip to content

Commit

Permalink
Merge pull request rubocop#144 from lucasocon/doc-big-decimal-with-nu…
Browse files Browse the repository at this point in the history
…meric-argument

Add bad example for BigDecimalWithNumericArgument
  • Loading branch information
koic authored Jul 7, 2020
2 parents c135880 + 797cbe0 commit 809fae5
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 809fae5

Please sign in to comment.