forked from rubocop/rubocop-performance
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…lse positives Some codebases may contain non-numeric classes which implement a `:+` method. If `a`, `b` and `c` are objects of such a class, then certain corrections do not apply: ```ruby [a, b].reduce(c, :+) # is equivalent to [a, b].sum(c) [a, b].map(&:to_i).sum # is equivalent to [a, b].sum(&:to_i) [a, b].reduce(:+) # works [a, b].sum # raises TypeError ``` For users who wish to only register offenses where auto-correction is unproblematic, we add the option `OnlySumOrWithInitialValue` to the `Performance/Sum` cop. The option is disabled by default, so standard behavior is preserved, and can be activated by setting `OnlySumOrWithInitialValue: true`.
- Loading branch information
Showing
6 changed files
with
210 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* [#204](https://github.com/rubocop/rubocop-performance/issues/204): Add `Performance/Sum` option to ignore potential false positives. ([@leoarnold][]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters