Hi all, I'd like to introduce a Checkstyle check that verifies lines are not too deeply nested. The Google format we are using is indenting excessively long lines that are overflowing on the next line 8 chars instead of 4, I believe as a way to discourage too deep nesting.
However, we have a lot of old code that has been reformatted blindly, and we have situations in the code like these: https://github.com/geotools/geotools/blob/f66689b5305eaf381e21dc2feec8011138d4cb24/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/GeocentricTransform.java#L446 https://github.com/geotools/geotools/blob/f66689b5305eaf381e21dc2feec8011138d4cb24/modules/library/referencing/src/main/java/org/geotools/referencing/operation/projection/TransverseMercator.java#L174 The first one can be easily fixed using Objects.hashCode(....) while the second is in need of a bit of expression splitting. There are other egregious cases around, mostly due to excessive usage of nested classes (e.g., Wicket GUI code). I've found a simple checkstyle configuration can spot all of them: <module name="RegexpSingleline"> <property name="format" value="^\s{70}"/> <property name="message" value="Excessive nesting found. Please try to factor out the deeply nested code using support variables, or in a separate methods, or classes"/> <property name="minimum" value="0"/> <property name="maximum" value="1"/> </module> This should make the code overall more readable, and stop new too deeply nested bits to show up in the codebase. Opinions? Cheers Andrea
_______________________________________________ GeoTools-Devel mailing list GeoTools-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel