diff options
Diffstat (limited to 'python/tidy/servo_tidy/tidy.py')
-rw-r--r-- | python/tidy/servo_tidy/tidy.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index fac5f8e7063..93b5d8f6452 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -163,13 +163,23 @@ def licensed_apache(header): def check_license(file_name, lines): if any(file_name.endswith(ext) for ext in (".toml", ".lock", ".json")): raise StopIteration - block = min(len(lines), licenseck.MAX_LICENSE_LINESPAN) + + if lines[0].startswith("#!") and lines[1].strip(): + yield (1, "missing blank line after shebang") + + blank_lines = 0 + max_blank_lines = 2 if lines[0].startswith("#!") else 1 license_block = [] - for l in lines[:block]: + + for l in lines: l = l.rstrip('\n') + if not l.strip(): + blank_lines += 1 + if blank_lines >= max_blank_lines: + break line = uncomment(l) if line is not None: - license_block += [line] + license_block.append(line) contents = " ".join(license_block) valid_license = licensed_mpl(contents) or licensed_apache(contents) acknowledged_bad_license = "xfail-license" in contents |