From 811708766443620f43e18a81b02dccb0b538bf76 Mon Sep 17 00:00:00 2001 From: jelle Spijker Date: Tue, 13 Dec 2022 11:30:13 +0100 Subject: [PATCH] Revert "Fix multiline printer-linter PR suggestions" This reverts commit 7820cc98 --- .../workflows/printer-linter-pr-diagnose.yml | 2 +- .github/workflows/printer-linter-pr-post.yml | 2 +- .../src/printerlinter/linters/defintion.py | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/printer-linter-pr-diagnose.yml b/.github/workflows/printer-linter-pr-diagnose.yml index 54bbda4c1d..0dac8ba7e7 100644 --- a/.github/workflows/printer-linter-pr-diagnose.yml +++ b/.github/workflows/printer-linter-pr-diagnose.yml @@ -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@bc0bb7da034a8317d54e7fe1e819159002f4cc40 with: github_token: ${{ secrets.GITHUB_TOKEN }} clang_tidy_fixes: result.yml diff --git a/.github/workflows/printer-linter-pr-post.yml b/.github/workflows/printer-linter-pr-post.yml index f6c0924d1c..81dbf96469 100644 --- a/.github/workflows/printer-linter-pr-post.yml +++ b/.github/workflows/printer-linter-pr-post.yml @@ -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@bc0bb7da034a8317d54e7fe1e819159002f4cc40 with: github_token: ${{ secrets.GITHUB_TOKEN }} clang_tidy_fixes: printer-linter-result/fixes.yml diff --git a/printer-linter/src/printerlinter/linters/defintion.py b/printer-linter/src/printerlinter/linters/defintion.py index b0201976be..d684cd98e9 100644 --- a/printer-linter/src/printerlinter/linters/defintion.py +++ b/printer-linter/src/printerlinter/linters/defintion.py @@ -45,17 +45,24 @@ 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 = [Replacement( - file = self._file, - offset = found.span(1)[0], - length = len(found.group()), - replacement_text = "")] + replacements = replacements ) def _loadDefinitionFiles(self, definition_file) -> None: