Fix multiline printer-linter PR suggestions

This commit is contained in:
jspijker 2022-12-02 10:28:36 +01:00
parent b788987ae1
commit 7820cc9840
3 changed files with 7 additions and 14 deletions

View file

@ -52,7 +52,7 @@ jobs:
path: printer-linter-result/
- name: Run clang-tidy-pr-comments action
uses: platisd/clang-tidy-pr-comments@master
uses: platisd/clang-tidy-pr-comments@fix_suggestions_for_multiline_comments
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
clang_tidy_fixes: result.yml

View file

@ -73,7 +73,7 @@ jobs:
unzip printer-linter-result.zip -d printer-linter-result
- name: Run clang-tidy-pr-comments action
uses: platisd/clang-tidy-pr-comments@master
uses: platisd/clang-tidy-pr-comments@fix_suggestions_for_multiline_comments
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
clang_tidy_fixes: printer-linter-result/fixes.yml

View file

@ -45,24 +45,17 @@ class Definition(Linter):
if is_redefined:
redefined = re.compile(r'.*(\"' + key + r'\"[\s\:\S]*?)\{[\s\S]*?\},?')
found = redefined.search(self._content)
# TODO: Figure out a way to support multiline fixes in the PR review GH Action, for now suggest no fix to ensure no ill-formed json are created
# see: https://github.com/platisd/clang-tidy-pr-comments/issues/37
if len(found.group().splitlines()) > 1:
replacements = []
else:
replacements = [Replacement(
file = self._file,
offset = found.span(1)[0],
length = len(found.group()),
replacement_text = "")]
yield Diagnostic(
file = self._file,
diagnostic_name = "diagnostic-definition-redundant-override",
message = f"Overriding {key} with the same value ({value}) as defined in parent definition: {definition['inherits']}",
level = "Warning",
offset = found.span(0)[0],
replacements = replacements
replacements = [Replacement(
file = self._file,
offset = found.span(1)[0],
length = len(found.group()),
replacement_text = "")]
)
def _loadDefinitionFiles(self, definition_file) -> None: