From 81eed5846f250ad2980d87b5ade6b2ce3f940801 Mon Sep 17 00:00:00 2001 From: Luke Cartey Date: Fri, 27 Dec 2024 23:33:56 +0000 Subject: [PATCH] Skip external help integration from forks PRs from forks do not have access to the help repo. --- .github/workflows/code-scanning-pack-gen.yml | 4 +++- change_notes/2024-12-10-m0-1-3-perf.md | 2 ++ cpp/autosar/src/rules/M0-1-3/UnusedLocalVariable.ql | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 change_notes/2024-12-10-m0-1-3-perf.md diff --git a/.github/workflows/code-scanning-pack-gen.yml b/.github/workflows/code-scanning-pack-gen.yml index 1b620260c..51ffb1edb 100644 --- a/.github/workflows/code-scanning-pack-gen.yml +++ b/.github/workflows/code-scanning-pack-gen.yml @@ -80,6 +80,8 @@ jobs: - name: Checkout external help files id: checkout-external-help-files + # Forks do not have access to an appropriate token for the help files + if: !github.event.pull_request.head.repo.fork uses: actions/checkout@v4 with: ssh-key: ${{ secrets.CODEQL_CODING_STANDARDS_HELP_KEY }} @@ -88,7 +90,7 @@ jobs: path: external-help-files - name: Include external help files - if: steps.checkout-external-help-files.outcome == 'success' + if: !github.event.pull_request.head.repo.fork && steps.checkout-external-help-files.outcome == 'success' run: | pushd external-help-files find . -name '*.md' -exec rsync -av --relative {} "$GITHUB_WORKSPACE" \; diff --git a/change_notes/2024-12-10-m0-1-3-perf.md b/change_notes/2024-12-10-m0-1-3-perf.md new file mode 100644 index 000000000..4ab4202a6 --- /dev/null +++ b/change_notes/2024-12-10-m0-1-3-perf.md @@ -0,0 +1,2 @@ + - `M0-1-3` - `UnusedLocalVariable.ql`: + - Improve performance on codebases with a large number of variables with the same name. \ No newline at end of file diff --git a/cpp/autosar/src/rules/M0-1-3/UnusedLocalVariable.ql b/cpp/autosar/src/rules/M0-1-3/UnusedLocalVariable.ql index e89e9ec13..886519b8d 100644 --- a/cpp/autosar/src/rules/M0-1-3/UnusedLocalVariable.ql +++ b/cpp/autosar/src/rules/M0-1-3/UnusedLocalVariable.ql @@ -48,7 +48,7 @@ where not exists(v.getAnAccess()) and // Sometimes multiple objects representing the same entities are created in // the AST. Check if those are not accessed as well. Refer issue #658 - not exists(LocalScopeVariable another | + not exists(PotentiallyUnusedLocalVariable another | another.getDefinitionLocation() = v.getDefinitionLocation() and another.hasName(v.getName()) and exists(another.getAnAccess()) and