[QA] Ruby Coding Conventions and RuboCop (was: Rubocop style checker)

Antoine Musso hashar+wmf at free.fr
Thu Nov 20 17:05:39 UTC 2014


Le 20/11/2014 01:38, Dan Duvall a écrit :
> Ironically enough, it has failed the Travis CI check because of an
> overzealous `GuardClause` check. (Seriously, who can't read an `if`
> statement ... :)

http://www.rubydoc.info/github/bbatsov/rubocop/Rubocop/Cop/Style/GuardClause

Well, one could name it early return.  That saves a level of indentation
and make it obvious that on that condition nothing else is executed.
Else you have to browse down at the end of the condition to look at
potentially additional code.

In php I definitely prefers:

 if ( ! $cond ) {
   return;
 }
 // lot of code

Against:

 if ( $cond ) {
   // lot of code
 }

But yeah might be overzealous :]


-- 
Antoine "hashar" Musso




More information about the QA mailing list