Skip to content

Commit

Permalink
Fix nasa#338, Add MISRA Addons for cppcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
arielswalker committed Aug 18, 2021
1 parent c9aa813 commit 7f5f250
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
File renamed without changes.
20 changes: 14 additions & 6 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,41 +42,49 @@ 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
if: ${{matrix.cppcheck =='cfe'}}
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
Expand All @@ -90,4 +98,4 @@ jobs:
then
cat ${{matrix.cppcheck}}_cppcheck_err.txt
exit -1
fi
fi

0 comments on commit 7f5f250

Please sign in to comment.