-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lint: don't fail workflow on indent fail
There are multiple cases where good human readable code block is converted to an unreadable mess by clang-format, so we don't want to rely on clang-format completely. Also there is no way, as far as I can see, to make clang-format only fix what we want it to fix without breaking something. So let's just display hints inline where clang-format is unhappy. When reviewer sees such a warning it's a good sign that something is broken in codding style around this warning. We add special script which parses diff generated by indent and generates warning for each hunk. Signed-off-by: Pavel Tikhomirov <[email protected]>
- Loading branch information
Showing
3 changed files
with
43 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/python3 | ||
import sys | ||
import re | ||
|
||
re_file = r'^diff --git a/(\S\S*)\s.*$' | ||
re_line = r'^@@ -(\d\d*)\D.*@@.*$' | ||
|
||
if __name__ == '__main__': | ||
if len(sys.argv) != 1 and len(sys.argv) != 2: | ||
print(f'usage: {sys.argv[0]} <path/to/file>') | ||
print(f'usage: <command> | {sys.argv[0]}') | ||
exit(1) | ||
|
||
input_file = sys.stdin.fileno() | ||
if len(sys.argv) == 2: | ||
input_file = sys.argv[1] | ||
|
||
with open(input_file, 'r') as fi: | ||
file_name = None | ||
line_number = None | ||
for line in fi: | ||
file_matches = re.findall(re_file, line) | ||
if len(file_matches) == 1: | ||
file_name = file_matches[0] | ||
continue | ||
|
||
if file_name is None: | ||
continue | ||
|
||
line_matches = re.findall(re_line, line) | ||
if len(line_matches) == 1: | ||
line_number = int(line_matches[0]) + 3 | ||
print('::warning file={file_name},line={line_number}::clang-format: Possible coding style problem {[coding-style](https://github.com/checkpoint-restore/criu/blob/criu-dev/CONTRIBUTING.md#automatic-tools-to-fix-coding-style)}') |