Enhance IndentationRule to take into account Label Indent#729
Conversation
a04aa19 to
217d8f2
Compare
|
Nice contribution. I like it. Would it be acceptable and sufficient to just have a boolean that controls whether the statements under a label should be indented a single level or not? The existing rule configuration property is |
|
Good point @chrismair, I was also wondering the same. But I suppose most users will be using the same number of spaces everywhere. |
|
I can think of good reasons for either way, but let's go with the boolean. I would suggest |
217d8f2 to
7844f53
Compare
|
@chrismair done :) |
|
Looks good. Thanks for the contribution. |

Fixes #712
Description
Currently, the following syntax is considered as a violation of
IndentationRuleThis PR introduces an
indentUnderLabelboolean property to make this configurable.The default value is
falsein order to be backwards compatible.When it is set to
true, then code within the label should be indented with the number of spaces defined by thespacesPerIndentLevelproperty.Additionally, the following change is made in order to allow labels without a text description.
private static boolean isSpockBlockLabel(Statement statement) { return (statement.statementLabel in SPOCK_BLOCKS && statement instanceof ExpressionStatement && - statement.expression.class == ConstantExpression && - statement.expression.type.clazz == String ) }How has this been tested
Unit test are added covering:
indentUnderLabelproperty is not respected