From 7f5f250857f8f8ff3b0dcebf14cc50c81c4f840a Mon Sep 17 00:00:00 2001 From: ArielSAdamsNASA Date: Wed, 18 Aug 2021 07:14:58 -0500 Subject: [PATCH] Fix #338, Add MISRA Addons for cppcheck --- .../{misra-2012-rules.txt => misra-rules.txt} | 0 .github/workflows/static-analysis.yml | 20 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) rename .github/cppcheck/{misra-2012-rules.txt => misra-rules.txt} (100%) diff --git a/.github/cppcheck/misra-2012-rules.txt b/.github/cppcheck/misra-rules.txt similarity index 100% rename from .github/cppcheck/misra-2012-rules.txt rename to .github/cppcheck/misra-rules.txt diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index bfe9cd2f7..d0dbec294 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -42,22 +42,24 @@ jobs: with: submodules: true - - name: Get MISRA addon + - name: get MISRA addon run: | sudo apt-get install git -y - git clone https://github.com/danmar/cppcheck.git --branch 2.5 + git clone https://github.com/danmar/cppcheck.git cp cppcheck/addons/misra.py misra.py cp cppcheck/addons/test/misra/misra-test.h misra-test.h cp cppcheck/addons/test/misra/misra-test.c misra-test.c - wget https://raw.githubusercontent.com/danmar/cppcheck/main/addons/cppcheckdata.py - wget https://raw.githubusercontent.com/danmar/cppcheck/main/addons/misra_9.py + cp cppcheck/addons/cppcheckdata.py cppcheckdata.py + cp cppcheck/addons/misra_9.py misra_9.py + wget https://raw.githubusercontent.com/nasa/cFS/blob/main/.github/cppcheck/misra-rules.txt + # run normal cpp check and then MISRA addon - name: Run bundle cppcheck if: ${{matrix.cppcheck =='bundle'}} run: | cppcheck --force --inline-suppr --quiet . 2> ${{matrix.cppcheck}}_cppcheck_err.txt cppcheck --dump misra-test.c - python3 misra.py --rule-texts=./.github/workflows/misra-rules.txt misra-test.c.dump + python3 misra.py --rule-texts=misra-rules.txt misra-test.c.dump # Run strict static analysis for embedded portions of cfe, osal, and psp - name: cfe strict cppcheck @@ -65,18 +67,24 @@ jobs: run: | cd ${{matrix.cppcheck}} cppcheck --force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive ./modules/core_api/fsw ./modules/core_private/fsw ./modules/es/fsw ./modules/evs/fsw ./modules/fs/fsw ./modules/msg/fsw ./modules/resourceid/fsw ./modules/sb/fsw ./modules/sbr/fsw ./modules/tbl/fsw ./modules/time/fsw -UCFE_PLATFORM_TIME_CFG_CLIENT -DCFE_PLATFORM_TIME_CFG_SERVER 2> ../${{matrix.cppcheck}}_cppcheck_err.txt + cppcheck --dump ../misra-test.c + python3 ../misra.py --rule-texts=../misra-rules.txt ../misra-test.c.dump - name: osal strict cppcheck if: ${{matrix.cppcheck =='osal'}} run: | cd ${{matrix.cppcheck}} cppcheck --force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive ./src/bsp ./src/os 2> ../${{matrix.cppcheck}}_cppcheck_err.txt + cppcheck --dump ../misra-test.c + python3 ../misra.py --rule-texts=../misra-rules.txt ../misra-test.c.dump - name: psp strict cppcheck if: ${{matrix.cppcheck =='psp'}} run: | cd ${{matrix.cppcheck}} cppcheck --force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive ./fsw 2> ../${{matrix.cppcheck}}_cppcheck_err.txt + cppcheck --dump ../misra-test.c + python3 ../misra.py --rule-texts=../misra-rules.txt ../misra-test.c.dump - name: Archive Static Analysis Artifacts uses: actions/upload-artifact@v2 @@ -90,4 +98,4 @@ jobs: then cat ${{matrix.cppcheck}}_cppcheck_err.txt exit -1 - fi + fi \ No newline at end of file