rails_best_practices

https://github.com/flyerhzm/rails_best_practices

Ruby

a code metric tool for rails projects

RailsBestPractices::Reviews::NeedlessDeepNestingReview#recursively_check

check nested route.

if the receiver of the method_add_block is with message "resources" or "resource",
then increment the @counter, recursively check the block body, and decrement the @counter.

if the node type is command_call or command,
and its message is resources or resource,
then check if @counter is greater than or equal to @nested_count,
if so, it is the needless deep nesting.

Source | Google | Stack overflow

Edit

git clone [email protected]:flyerhzm/rails_best_practices.git

cd rails_best_practices

open lib/rails_best_practices/reviews/needless_deep_nesting_review.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-RailsBestPractices--Reviews--NeedlessDeepNestingReview-recursively_check-for-pr


# Commit to git

git add lib/rails_best_practices/reviews/needless_deep_nesting_review.rbgit commit -m "better docs for RailsBestPractices::Reviews::NeedlessDeepNestingReview#recursively_check"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-RailsBestPractices--Reviews--NeedlessDeepNestingReview-recursively_check-for-pr

hub pull-request


# Celebrate!