@@ -952,3 +952,102 @@ Related GitHub Issues and Pull Requests are tagged with the `Inclusive Language
952952.. _Bluetooth Appropriate Language Mapping Tables : https://btprodspecificationrefs.blob.core.windows.net/language-mapping/Appropriate_Language_Mapping_Table.pdf
953953.. _OSHWA Resolution to Redefine SPI Signal Names : https://www.oshwa.org/a-resolution-to-redefine-spi-signal-names/
954954.. _Zephyr issue 27033 : https://github.com/zephyrproject-rtos/zephyr/issues/27033
955+
956+ Parasoft Codescan Tool
957+ **********************
958+
959+ Parasoft Codescan is an official static code analysis tool used by the Zephyr
960+ project. It is used to automate compliance with a range of coding and security
961+ standards.
962+ The tool is currently set to the MISRA-C:2012 Coding Standard because the Zephyr
963+ :ref: `coding_guidelines ` are based on that standard.
964+ It is used together with the Coverity Scan tool to achieve the best code health
965+ and precision in bug findings.
966+
967+ Violations fixing process
968+ =========================
969+
970+ Step 1
971+ Any Zephyr Project member, company or a developer can request access
972+ to the Parasoft reporting centre if they wish to get involved in fixing
973+ violations by submitting issues.
974+
975+ Step 2
976+ A developer starts to review violations.
977+
978+ Step 3
979+ A developer submits a Github PR with the fix. Commit messages should follow
980+ the same guidelines as other PRs in the Zephyr project. Please add a comment
981+ that your fix was found by a static coding scanning tool.
982+ Developers should follow and refer to the Zephyr :ref: `coding_guidelines `
983+ as basic rules for coding. These rules are based on the MISRA-C standard.
984+
985+ Below you can find an example of a recommended commit message::
986+
987+ lib: os: add braces to 'if' statements
988+
989+ An 'if' (expression) construct shall be followed by a compound statement.
990+ Add braces to improve readability and maintainability.
991+
992+ Found as a coding guideline violation (Rule 15.6) by static
993+ coding scanning tool.
994+
995+ Signed-off-by: Johnny Developer <[email protected] > 996+
997+ Step 4
998+ If a violation is a false positive, the developer should mark it for the Codescan
999+ tool just like they would do for the Coverity tool.
1000+ The developer should also add a comment to the code explaining that
1001+ the violation raised by the static code analysis tool should be considered a
1002+ false positive.
1003+
1004+ Step 5
1005+ If the developer has found a real violation that the community decided to ignore,
1006+ the developer must submit a PR with a suppression tag
1007+ and a comment explaining why the violation has been deviated.
1008+ The template structure of the comment and tag in the code should be::
1009+
1010+ /* Explain why that part of the code doesn't follow the standard,
1011+ * explain why it is a deliberate deviation from the standard.
1012+ * Don't refer to the Parasoft tool here, just mention that static code
1013+ * analysis tool raised a violation in the line below.
1014+ */
1015+ code_line_with_a_violation /* parasoft-suppress Rule ID */
1016+
1017+ Below you can find an example of a recommended commit message::
1018+
1019+ testsuite: suppress usage of setjmp in a testcode (rule 21.4)
1020+
1021+ According to the Rule 21.4 the standard header file <setjmp.h> shall not
1022+ be used. We will suppress this violation because it is in
1023+ test code. Tag suppresses reporting of the violation for the
1024+ line where the violation is located.
1025+ This is a deliberate deviation.
1026+
1027+ Found as a coding guideline violation (Rule 21.4) by static coding
1028+ scanning tool.
1029+
1030+ Signed-off-by: Johnny Developer <[email protected] > 1031+
1032+ The example below demonstrates how deviations can be suppressed in the code::
1033+
1034+ /* Static code analysis tool can raise a violation that the standard
1035+ * header <setjmp.h> shall not be used.
1036+ * Since this violation is in test code, we will suppress it.
1037+ * Deliberate deviation.
1038+ */
1039+ #include <setjmp.h> /* parasoft-suppress MISRAC2012-RULE_21_4-a MISRAC2012-RULE_21_4-b */
1040+
1041+ This variant above suppresses item ``MISRAC2012-RULE_21_4-a `` and ``MISRAC2012-RULE_21_4-b ``
1042+ on the line with "setjump" header include. You can add as many rules to suppress you want -
1043+ just make sure to keep the Parasoft tag on one line and separate rules with a space.
1044+ To read more about suppressing findings in the Parasoft tool, refer to the
1045+ official Parasoft `documentation `_
1046+
1047+ .. _documentation : https://docs.parasoft.com/display/CPPTEST1031/Suppressing+Findings
1048+
1049+ Step 6
1050+ After a PR is submitted, the developer should add the ``Coding guidelines ``
1051+ and ``MISRA-C `` Github labels so their PR can be easily tracked by maintainers.
1052+ If you have any concerns about what your PR should look like, you can search
1053+ on Github using those tags and refer to similar PRs that have already been merged.
0 commit comments