sky-uk / bslint

A linter for the BrightScript language.
BSD 3-Clause "New" or "Revised" License
24 stars 9 forks source link

Wrong indentation for Arrays #167

Open pawelhertman opened 6 years ago

pawelhertman commented 6 years ago

"check_indentation" rule enforces wrong indentations for arrays.

When it's turned on this code is correct:

variable = [
'sdfsdfg',
'sdfgsdfg',
]

while this is not:

variable = [
  'sdfsdfg',
  'sdfgsdfg',
]

In (not only) my opinion the second notation should be accepted. For associative arrays the rule works correct.

I'm not familiar with Python, so I'm not able to contribute, but I guess the problem occurs because in lexer/regexs.py signs [ and ] are matched with "NO_INDENTATION"

[r"\[", const.OPEN_SQUARE_BRACKET, const.OPEN_SQUARE_BRACKET, const.NO_INDENTATION],
    [r"\]", const.CLOSE_SQUARE_BRACKET, const.CLOSE_SQUARE_BRACKET, const.NO_INDENTATION],

what in fact is correct because these signs can be used as Array Operator to access array's value. So the solution probably is to create another regexes to recognize brackets as array initialization when they appear after = sign.