Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> # This cop checks for `next` (and sometimes `break`) in loops.

> ...

> # - For small loops, you can just use normal conditions instead of `next`.

This rule will just end up with devs writing this:

    array.each do |elem|
      if condition
        if another_condition
          if yet_another_condition
            do_something
          end 
        end 
      end
    end
Rather than the much easier to parse:

    array.each do |elem|
      next if !condition
      next if !another_condition
      next if !yet_another_condition
      
      do_something
    end


That cop is disabled by default in `config/default.yml`.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: