Skip to content

How can I check the empty lines between variables? #14605

Closed Answered by nrmancuso
gabryellr asked this question in Q&A
Discussion options

You must be logged in to vote

You need to write custom Check to validate what you want.

Unless I am missing something, this is overkill.

MatchXpath

MatchXpath is going to be very difficult or impossible to use to achieve this. I suggest that you go with my suggestion above: use EmptyLineSeparator with a SuppressionXpathSingleFilter.

Example:

➜  src cat Test.java

public class Test {
    @Value("")
    private int a;

    @Value("")
    private int b;

    private int c;
    private int d; // ok, no annotation

    @Value("")
    private int e;
    @Value("")
    private int f;// violation, no line break between fields with annotation

    void m() {
        int x = 2;
        int y = 3; // ok, not a field
    }

 …

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@nrmancuso
Comment options

@romani
Comment options

@gabryellr
Comment options

@nrmancuso
Comment options

Answer selected by gabryellr
@gabryellr
Comment options

@gabryellr
Comment options

@nrmancuso
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants