OyvindSabo / gremlint

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

Relative indentation should be maintained in non-Gremlin code blocks. #66

Closed OyvindSabo closed 3 years ago

OyvindSabo commented 3 years ago

Consider that we want to format the following query, with a max line length of 85 (the high max line length is required until https://github.com/OyvindSabo/gremlint/issues/65 is fixed):

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') })

It should be formatted to

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 instead it is formatted to

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') })

This is because the absolute indentation of the code block are preserved, instead of the relative indentation between the lines of the code blocks. In other words, when we move a code block to align with a surrounding, we want to move all lines of the block, not just the first.