[Phpmyadmin-devel] New PHPCS rule

Marc Delisle marc at infomarc.info
Mon Dec 16 23:56:13 CET 2013


Le 2013-12-16 13:12, Hugues Peccatte a écrit :
> 2013/12/16 Marc Delisle <marc at infomarc.info <mailto:marc at infomarc.info>>
> 
>     Le 2013-12-15 14:36, Hugues Peccatte a écrit :
>     > Hi,
>     >
>     > What would you think about using the "nesting level" sniff please?
>     > This sniff permits to detect when there are too much nested levels
>     like:
>     > if (...) {
>     >     if (...) {
>     >         if (...) {
>     >             if (...) {
>     >                 if (...) {
>     >                     ....
>     >                 }
>     >             }
>     >         }
>     >     }
>     > }
>     >
>     > This kind of syntax often means that a refactoring is needed or a
>     rewrite.
>     >
>     > I can add it myself if you agree.
>     >
> 
>     Good idea but how many levels is considered "too many"?  Can you give an
>     example of nesting levels you found?
> 
> 
>     --
>     Marc Delisle
>     http://infomarc.info | http://phpmyadmin.net
> 
>     ------------------------------------------------------------------------------
>     Rapidly troubleshoot problems before they affect your business. Most IT
>     organizations don't have a clear picture of how application performance
>     affects their revenue. With AppDynamics, you get 100% visibility
>     into your
>     Java,.NET, & PHP application. Start your 15-day FREE TRIAL of
>     AppDynamics Pro!
>     http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>     _______________________________________________
>     Phpmyadmin-devel mailing list
>     Phpmyadmin-devel at lists.sourceforge.net
>     <mailto:Phpmyadmin-devel at lists.sourceforge.net>
>     https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
> 
> 
> 
> Hi,
> 
> To add this new rule won't add to many PHPCS errors. I already test this
> rule and there are currently not so much this errors in the sources. (I
> don't have an exact count. I would say around 20-30.)
> 
> See: http://www.squizlabs.com/php-codesniffer/php_codesniffer-ruleset.xml-support-in-svn
> See: http://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php
> 
> The rule could be:
>   <rule ref="Generic.Metrics.NestingLevel">
>     <properties>
>       <property name="nestingLevel" value="2" />
>       <property name="absoluteNestingLevel" value="5" />
>     </properties>
>   </rule>
> 
> We don't need to define both properties.
> "nestingLevel" is the number of nested level which throw a warning.
> (default = 5)
> "absoluteNestingLevel" is the maximum of allowed nested levels. (default
> = 10)
> 
> I think that the default values don't need to be overridden, so the rule
> would be:
> <rule ref="Generic.Metrics.NestingLevel" />
> 
> Hugues.

Yes, let's try that.


-- 
Marc Delisle
http://infomarc.info | http://phpmyadmin.net




More information about the Developers mailing list