diff --git a/.github/workflows/clang-tidy-pr.yml b/.github/workflows/clang-tidy-pr.yml new file mode 100644 index 0000000000..4375139bfd --- /dev/null +++ b/.github/workflows/clang-tidy-pr.yml @@ -0,0 +1,46 @@ +# Insecure workflow with limited permissions that should provide analysis results through an artifact +name: Static analysis + +on: pull_request + +jobs: + clang-tidy: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: Fetch base branch + run: | + git remote add upstream "https://github.com/${{ github.event.pull_request.base.repo.full_name }}" + git fetch --no-tags --no-recurse-submodules upstream "${{ github.event.pull_request.base.ref }}" + - name: Install clang-tidy + + run: sudo apt-get update && sudo apt-get install -y tcl-dev tk-dev cmake clang clang-tidy make libbtbb-dev libx11-dev libglu1-mesa-dev + + - name: Prepare compile_commands.json + run: | + mkdir -p build + cd build + cmake -G "Unix Makefiles" \ + -D CMAKE_C_COMPILER=clang \ + -D CMAKE_CXX_COMPILER=clang++ \ + -D USE_FREETYPE=OFF \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. + + - name: Create results directory + run: | + mkdir clang-tidy-result + - name: Analyze + run: | + git diff -U0 "$(git merge-base HEAD "upstream/${{ github.event.pull_request.base.ref }}")" | clang-tidy-diff -p1 -path build -export-fixes clang-tidy-result/fixes.yml + - name: Save PR metadata + run: | + echo "${{ github.event.number }}" > clang-tidy-result/pr-id.txt + echo "${{ github.event.pull_request.head.repo.full_name }}" > clang-tidy-result/pr-head-repo.txt + echo "${{ github.event.pull_request.head.sha }}" > clang-tidy-result/pr-head-sha.txt + - uses: actions/upload-artifact@v4 + with: + name: clang-tidy-result + path: clang-tidy-result/ diff --git a/src/HLRTest/HLRTest.cxx b/src/HLRTest/HLRTest.cxx index 7dd633a738..cf7d58d255 100644 --- a/src/HLRTest/HLRTest.cxx +++ b/src/HLRTest/HLRTest.cxx @@ -54,6 +54,8 @@ Standard_Boolean HLRTest::GetProjector (Standard_CString& Name, Handle(HLRTest_Projector) HP = Handle(HLRTest_Projector)::DownCast(Draw::Get(Name)); if (HP.IsNull()) return Standard_False; + HP.Nullify(); + HP = nullptr; P = HP->Projector(); return Standard_True; diff --git a/src/HLRTest/HLRTest_OutLiner.cxx b/src/HLRTest/HLRTest_OutLiner.cxx index 782fe974ea..60afa414bd 100644 --- a/src/HLRTest/HLRTest_OutLiner.cxx +++ b/src/HLRTest/HLRTest_OutLiner.cxx @@ -52,6 +52,7 @@ Handle(Draw_Drawable3D) HLRTest_OutLiner::Copy () const Handle(HLRTest_OutLiner) O = new HLRTest_OutLiner(myOutLiner->OriginalShape()); return O; + return nullptr; } //=======================================================================