OyvindSabo / gremlint

Linter/Code formatter for Gremlin
https://gremlint.com
Apache License 2.0
11 stars 6 forks source link

Semicolon at the end of query breaks formatting #67

Closed OyvindSabo closed 3 years ago

OyvindSabo commented 3 years ago

Consider the following query formatted with a max line length of 72:

g.V(ids).
has('factor_a').
has('factor_b').
project('Factor A', 'Factor B', 'Product').
by(values('factor_a')).
by(values('factor_b')).
by(map{ it.get().value('factor_a') * 
        it.get().value('factor_b') });

Without the semicolon it will (as expected) be formatted like this:

g.V(ids).
  has('factor_a').
  has('factor_b').
  project('Factor A', 'Factor B', 'Product').
    by(values('factor_a')).
    by(values('factor_b')).
    by(map{ it.get().value('factor_a') * 
            it.get().value('factor_b') })

but with the semicolon it is currently formatted like this:

g.V(ids).
  has('factor_a').
  has('factor_b').
  project('Factor A', 'Factor B', 'Product').
    by(values('factor_a')).
    by(values('factor_b')).
  by(map{ it.get().value('factor_a') * 
        it.get().value('factor_b') });

while it should be formatted like this:

g.V(ids).
  has('factor_a').
  has('factor_b').
  project('Factor A', 'Factor B', 'Product').
    by(values('factor_a')).
    by(values('factor_b')).
    by(map{ it.get().value('factor_a') * 
            it.get().value('factor_b') });

Rather than fixing this particular edge case, the fix should be universal and identify which parts of the top-level code can be interpreted as a Gremlin query and leave the surrounding code as it is. This will hopefully also fix https://github.com/OyvindSabo/gremlint/issues/64.