Hi all, PMD recently released version 6.35, with a new check borrowed from the Sonar family called "Cognitive complexity".
In short, it's an improvement over cyclomatic complexity that accounts for the difficulty in understanding code rather than just counting the decision points in a method. You can read a short paper about it here: https://www.sonarsource.com/docs/CognitiveComplexity.pdf (10 pages excluding the appendixes, well worth it IMHO). I took this new check for a spin... it measures the cognitive complexity of methods, with a threshold of 15. That's a non-starter, we have way too many methods above that threshold. I've then tried out 50 and 100, still way too many (oh my gosh!). Pumping it up to 200 (!!!) provides a list of candidates that seems a bit more reasonable to attack. For example, gt-main only has two methods above that threshold. Here they are (brace for cognitive impact!) - "Conditionals hurricane with love for chained property calls" in DefaultTemporalPrimitive <https://github.com/geotools/geotools/blob/f66689b5305eaf381e21dc2feec8011138d4cb24/modules/library/main/src/main/java/org/geotools/temporal/object/DefaultTemporalPrimitive.java#L79> - "Gonna fit my entire program in a single method" in FilterDOMParser <https://github.com/geotools/geotools/blob/14d27a2db448454c64e8f38e9977565cc400d52b/modules/library/main/src/main/java/org/geotools/filter/FilterDOMParser.java#L113> This is different from considering just method length, for example, some time ago Gabriel was proposing to look PMD maximum method length check, which flagged only a few methods, including "reproject" which is a 400 lines long method... but only has a cognitive complexity of little above 100, I believe thanks to its flatter structure. So, what do you think? Do you mind having this kind of check as part of the ones performed by PMD? We can start with a score of 200 and go down little by little, until time and interest are exhausted. Cheers Andrea == GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- *Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.*
_______________________________________________ GeoTools-Devel mailing list GeoTools-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel