Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
3.5.0
-
None
-
None
Description
This issue is migrated from https://github.com/OyvindSabo/gremlint/issues/44. It is mentioned in a comment in the Gremlint code, and since OyvindSabo/gremlint will be retired, I'm adding it here now so the comment in tinkerpop/gremlint can refer to this Jira task instead.
The issue:
Currently, for nested steps, lines can sometimes be longer than the specified maximum line length because the function which checks the length does not know how deeply nested the steps are. Furthermore, commas or punctuation at the end of lines are not taken into consideration.
An example where closing parentheses are ignored:
Consider the following query formatted with a max line length of 66:
g.V().hasLabel('person').groupCount().by(values('age').choose(is(lt(28)),constant('young'),choose(is(lt(30)), constant('old'), constant('very old'))))
It is formatted like this (67 characters wide):
g.V(). hasLabel('person'). groupCount(). by( values('age'). choose( is(lt(28)), constant('young'), choose(is(lt(30)), constant('old'), constant('very old'))))
It is expected to be formatted like this:
g.V(). hasLabel('person'). groupCount(). by( values('age'). choose( is(lt(28)), constant('young'), choose( is(lt(30)), constant('old'), constant('very old'))))
A test case for this should be added to gremlint/src/formatQuery/_tests_/maxLineLength.test.ts.
An example where punctuation at the end of the line is ignored:
Consider the following query formatted with a max line length of 45:
g.V().hasLabel('person').where(outE('created').count().is(P.gte(2))).count()
It is formatted like this (46 characters wide):
g.V(). hasLabel('person'). where(outE('created').count().is(P.gte(2))). count()
It is expected to be formatted like this:
g.V(). hasLabel('person'). where( outE('created').count().is(P.gte(2))). count()
There is currently a commented out test for this in gremlint/src/formatQuery/_tests_/maxLineLength.test.ts which should be uncommented upon completion of this task.
An example where comma at the end of the line is ignored:
Consider the following query formatted with a max line length of 22:
g.V().choose(hasLabel('person'), out('created'), identity()).values('name')
It is formatted like this (23 characters wide):
g.V(). choose( hasLabel('person'), out('created'), identity()). values('name')
It is expected to be formatted like this:
g.V(). choose( hasLabel( 'person'), out('created'), identity()). values('name')
A test case for this should be added to gremlint/src/formatQuery/_tests_/maxLineLength.test.ts.