-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix #3331] MultilineMethodCallIndentation references only method chain
* Change alignment_base to a more readable case statement * Add CHANGELOG entry * Update documentation with indented_relative_to_receiver * Move some indentation tests out of the 'common' shared example We're going to change the behavior of `indented_relative_to_receiver` such that it will not behave the same as `aligned` and `indented` any longer. This keeps the specs passing. * Fix MultilineMethodCallIndentation references only method chain It appears as if the current behavior was potentially desired by the original author, however I feel as if it's incorrect. Not only does `aligned` and `indented` already behave the same as the current behavior of `indented_relative_to_receiver`, but the name of `indented_relative_to_receiver` is completely misleading to what the current behavior actually does. The current code looks all the way up the call stack such that if it's an _argument_ to a method call, it traverses up _that_ method's call chain until it can go no further. Take this code as an example: ```ruby existing_customer = Customer.find(customer_id) order = existing_customer .orders .status(SUCCESSFUL_STATES) .order(:scheduled_delivery_date) ``` Whereas before it would have wanted this: ```ruby existing_customer = Customer.find(customer_id) order = existing_customer .orders .status(SUCCESSFUL_STATES) .order(:scheduled_delivery_date) ``` Now it wants this: ```ruby existing_customer = Customer.find(customer_id) order = existing_customer .orders .status(SUCCESSFUL_STATES) .order(:scheduled_delivery_date) ``` Or this: ```ruby expect(my_reading).to be.within(.005) .of(5.0) ``` Whereas before it would have wanted this: ```ruby expect(my_reading).to be.within(.005) .of(5.0) ``` Now it wants this: ```ruby expect(my_reading).to be.within(.005) .of(5.0) ``` if you want to always indent relative to the leftmost character or column 0, then this cop _already_ has a style for those scenarios: `aligned` and `indented`.
- Loading branch information
Showing
4 changed files
with
144 additions
and
64 deletions.
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
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