[Phpmyadmin-devel] New PHPCS rule

Hugues Peccatte hugues.peccatte at gmail.com
Tue Dec 17 08:09:42 CET 2013


2013/12/16 Marc Delisle <marc at infomarc.info>

> 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
>
>
> ------------------------------------------------------------------------------
> 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
> https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
>

Hi,

I just committed the add of the new rule. Jenkins should find new errors
now.
[ ... wait for Jenkins result ... ]
My estimate was almost good. There are 27 new errors because of the nested
levels. I think that many of them could be fixed.

I'll look at this.

Hugues.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20131217/e75b5f88/attachment.html>


More information about the Developers mailing list