summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-02-06 18:05:13 +0000
committerw0rp <devw0rp@gmail.com>2019-02-06 18:05:13 +0000
commit3e11cbd18da3852fab5dee3f743bc60dc87f0775 (patch)
tree0ca2b5c0e3a8a60b48ffbe569a12f6ac9687cd65 /test
parent4d426bf2873c6e1cd2c71e478c756903307628d3 (diff)
downloadale-3e11cbd18da3852fab5dee3f743bc60dc87f0775.zip
Update syntax checking
* Line continuation characters should be on the same lines. * .vim file line indentation should be a multiple of 4.
Diffstat (limited to 'test')
-rwxr-xr-xtest/script/block-padding-checker25
1 files changed, 23 insertions, 2 deletions
diff --git a/test/script/block-padding-checker b/test/script/block-padding-checker
index b13c9b92..97ae7646 100755
--- a/test/script/block-padding-checker
+++ b/test/script/block-padding-checker
@@ -10,7 +10,7 @@ import re
INDENTATION_RE = re.compile(r'^ *')
COMMENT_LINE_RE = re.compile(r'^ *"')
-COMMAND_RE = re.compile(r'^ *([a-zA-Z]+)')
+COMMAND_RE = re.compile(r'^ *([a-zA-Z\\]+)')
START_BLOCKS = set(['if', 'for', 'while', 'try', 'function'])
END_BLOCKS = set(['endif', 'endfor', 'endwhile', 'endtry', 'endfunction'])
@@ -21,6 +21,7 @@ WHITESPACE_BEFORE_SET = START_BLOCKS | TERMINATORS
WHITESPACE_FORBIDDEN_BEFORE_SET = END_BLOCKS | MIDDLE_BLOCKS
WHITESPACE_AFTER_SET = END_BLOCKS
WHITESPACE_FORBIDDEN_AFTER_SET = START_BLOCKS | MIDDLE_BLOCKS
+SAME_INDENTATION_SET = set(['\\'])
def remove_comment_lines(line_iter):
@@ -44,7 +45,7 @@ def check_lines(line_iter):
):
yield (
line_number,
- 'Blank line forbidden after `%s`' % (command,)
+ 'Blank line forbidden after `%s`' % (previous_command,)
)
previous_line_blank = True
@@ -56,6 +57,26 @@ def check_lines(line_iter):
if command_match:
command = command_match.group(1)
+ if (
+ command in SAME_INDENTATION_SET
+ and previous_indentation_level is not None
+ and indentation_level != previous_indentation_level
+ ):
+ yield (
+ line_number,
+ 'Line continuation should match previous indentation'
+ )
+
+ if (
+ previous_indentation_level is not None
+ and indentation_level != previous_indentation_level
+ and abs(indentation_level - previous_indentation_level) != 4
+ ):
+ yield (
+ line_number,
+ 'Indentation should be 4 spaces'
+ )
+
# Check for commands requiring blank lines before them, if they
# aren't at the start of a block.
if (