@specs-feup/clava-misra 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitignore +8 -0
- package/README.md +53 -19
- package/dist/MISRA.d.ts +28 -10
- package/dist/MISRA.d.ts.map +1 -1
- package/dist/MISRA.js +30 -10
- package/dist/MISRA.js.map +1 -1
- package/dist/MISRAContext.d.ts +65 -11
- package/dist/MISRAContext.d.ts.map +1 -1
- package/dist/MISRAContext.js +131 -35
- package/dist/MISRAContext.js.map +1 -1
- package/dist/MISRARule.d.ts +38 -25
- package/dist/MISRARule.d.ts.map +1 -1
- package/dist/MISRARule.js +40 -18
- package/dist/MISRARule.js.map +1 -1
- package/dist/MISRATool.d.ts +46 -5
- package/dist/MISRATool.d.ts.map +1 -1
- package/dist/MISRATool.js +118 -45
- package/dist/MISRATool.js.map +1 -1
- package/dist/StandardGuideline.d.ts +22 -0
- package/dist/StandardGuideline.d.ts.map +1 -0
- package/dist/StandardGuideline.js +12 -0
- package/dist/StandardGuideline.js.map +1 -0
- package/dist/ast-visitor/Context.d.ts +11 -0
- package/dist/ast-visitor/Context.d.ts.map +1 -0
- package/dist/ast-visitor/Context.js +15 -0
- package/dist/ast-visitor/Context.js.map +1 -0
- package/dist/ast-visitor/Visit.d.ts +23 -0
- package/dist/ast-visitor/Visit.d.ts.map +1 -0
- package/dist/ast-visitor/Visit.js +18 -0
- package/dist/ast-visitor/Visit.js.map +1 -0
- package/dist/ast-visitor/VisitWithContext.d.ts +32 -0
- package/dist/ast-visitor/VisitWithContext.d.ts.map +1 -0
- package/dist/ast-visitor/VisitWithContext.js +26 -0
- package/dist/ast-visitor/VisitWithContext.js.map +1 -0
- package/dist/main.js +1 -2
- package/dist/main.js.map +1 -1
- package/dist/rules/Section13_SideEffects/Rule_13_6_SafeSizeOfOperand.d.ts +27 -0
- package/dist/rules/Section13_SideEffects/Rule_13_6_SafeSizeOfOperand.d.ts.map +1 -0
- package/dist/rules/Section13_SideEffects/Rule_13_6_SafeSizeOfOperand.js +98 -0
- package/dist/rules/Section13_SideEffects/Rule_13_6_SafeSizeOfOperand.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.d.ts +45 -6
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.d.ts.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.js +91 -8
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.js.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.d.ts +15 -5
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.d.ts.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.js +20 -6
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.js.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.d.ts +11 -5
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.d.ts.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.js +13 -10
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.js.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.d.ts +11 -6
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.d.ts.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.js +19 -11
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.js.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.d.ts +15 -5
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.d.ts.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.js +24 -10
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.js.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.d.ts +22 -6
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.d.ts.map +1 -1
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.js +37 -10
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.js.map +1 -1
- package/dist/rules/Section17_Functions/Rule_17_3_ImplicitFunction.d.ts +66 -0
- package/dist/rules/Section17_Functions/Rule_17_3_ImplicitFunction.d.ts.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_3_ImplicitFunction.js +209 -0
- package/dist/rules/Section17_Functions/Rule_17_3_ImplicitFunction.js.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.d.ts +37 -12
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.d.ts.map +1 -1
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.js +112 -39
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.js.map +1 -1
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.d.ts +15 -5
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.d.ts.map +1 -1
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.js +21 -7
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.js.map +1 -1
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.d.ts +11 -6
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.d.ts.map +1 -1
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.js +17 -8
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.js.map +1 -1
- package/dist/rules/Section21-StandardLibraries/DisallowedStdLibFunctionRule.d.ts +105 -0
- package/dist/rules/Section21-StandardLibraries/DisallowedStdLibFunctionRule.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/DisallowedStdLibFunctionRule.js +258 -0
- package/dist/rules/Section21-StandardLibraries/DisallowedStdLibFunctionRule.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_10_NoTimeDateFunctions.d.ts +25 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_10_NoTimeDateFunctions.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_10_NoTimeDateFunctions.js +27 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_10_NoTimeDateFunctions.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_11_NoTgmathFunctions.d.ts +29 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_11_NoTgmathFunctions.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_11_NoTgmathFunctions.js +31 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_11_NoTgmathFunctions.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory.d.ts +25 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory.js +27 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.d.ts +25 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.js +27 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.d.ts +25 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.js +27 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.d.ts +30 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.js +32 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.js.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.d.ts +25 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.d.ts.map +1 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.js +27 -0
- package/dist/rules/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.js.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.d.ts +6 -14
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.d.ts.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.js +17 -27
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.js.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.d.ts +13 -7
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.d.ts.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.js +31 -17
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.js.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.d.ts +26 -7
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.d.ts.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.js +32 -14
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.js.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.d.ts +48 -6
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.d.ts.map +1 -1
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.js +84 -34
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.js.map +1 -1
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.d.ts +24 -5
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.d.ts.map +1 -1
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.js +27 -7
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.js.map +1 -1
- package/dist/rules/Section5_Identifiers/IdentifierRenameRule.d.ts +46 -0
- package/dist/rules/Section5_Identifiers/IdentifierRenameRule.d.ts.map +1 -0
- package/dist/rules/Section5_Identifiers/IdentifierRenameRule.js +40 -0
- package/dist/rules/Section5_Identifiers/IdentifierRenameRule.js.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_1_DistinctExternalIdentifiers.d.ts +25 -0
- package/dist/rules/Section5_Identifiers/Rule_5_1_DistinctExternalIdentifiers.d.ts.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_1_DistinctExternalIdentifiers.js +46 -0
- package/dist/rules/Section5_Identifiers/Rule_5_1_DistinctExternalIdentifiers.js.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_6_UniqueTypedefNames.d.ts +26 -0
- package/dist/rules/Section5_Identifiers/Rule_5_6_UniqueTypedefNames.d.ts.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_6_UniqueTypedefNames.js +54 -0
- package/dist/rules/Section5_Identifiers/Rule_5_6_UniqueTypedefNames.js.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_7_UniqueTagNames.d.ts +27 -0
- package/dist/rules/Section5_Identifiers/Rule_5_7_UniqueTagNames.d.ts.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_7_UniqueTagNames.js +55 -0
- package/dist/rules/Section5_Identifiers/Rule_5_7_UniqueTagNames.js.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_8_UniqueExternalLinkIdentifiers.d.ts +24 -0
- package/dist/rules/Section5_Identifiers/Rule_5_8_UniqueExternalLinkIdentifiers.d.ts.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_8_UniqueExternalLinkIdentifiers.js +42 -0
- package/dist/rules/Section5_Identifiers/Rule_5_8_UniqueExternalLinkIdentifiers.js.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_9_UniqueInternalLinkIdentifiers.d.ts +24 -0
- package/dist/rules/Section5_Identifiers/Rule_5_9_UniqueInternalLinkIdentifiers.d.ts.map +1 -0
- package/dist/rules/Section5_Identifiers/Rule_5_9_UniqueInternalLinkIdentifiers.js +42 -0
- package/dist/rules/Section5_Identifiers/Rule_5_9_UniqueInternalLinkIdentifiers.js.map +1 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_6_SingleExternalDefinition.d.ts +35 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_6_SingleExternalDefinition.d.ts.map +1 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_6_SingleExternalDefinition.js +98 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_6_SingleExternalDefinition.js.map +1 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_7_RestrictExternalLinkage.d.ts +35 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_7_RestrictExternalLinkage.d.ts.map +1 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_7_RestrictExternalLinkage.js +76 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_7_RestrictExternalLinkage.js.map +1 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_9_BlockScopeDefinition.d.ts +32 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_9_BlockScopeDefinition.d.ts.map +1 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_9_BlockScopeDefinition.js +57 -0
- package/dist/rules/Section8_DeclarationsAndDefinitions/Rule_8_9_BlockScopeDefinition.js.map +1 -0
- package/dist/rules/UserConfigurableRule.d.ts +55 -0
- package/dist/rules/UserConfigurableRule.d.ts.map +1 -0
- package/dist/rules/UserConfigurableRule.js +16 -0
- package/dist/rules/UserConfigurableRule.js.map +1 -0
- package/dist/rules/index.d.ts +11 -18
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +47 -7
- package/dist/rules/index.js.map +1 -1
- package/dist/tests/Section17_Functions/misra_config.json +10 -0
- package/dist/tests/Section21-StandardLibraries/misra_config.json +88 -0
- package/dist/tests/Section21-StandardLibraries/problematic_misra_config.json +19 -0
- package/dist/tests/utils.d.ts +6 -3
- package/dist/tests/utils.d.ts.map +1 -1
- package/dist/tests/utils.js +33 -7
- package/dist/tests/utils.js.map +1 -1
- package/dist/utils/CallUtils.d.ts +15 -0
- package/dist/utils/CallUtils.d.ts.map +1 -0
- package/dist/utils/CallUtils.js +34 -0
- package/dist/utils/CallUtils.js.map +1 -0
- package/dist/utils/CommentUtils.d.ts +21 -0
- package/dist/utils/CommentUtils.d.ts.map +1 -0
- package/dist/utils/CommentUtils.js +27 -0
- package/dist/utils/CommentUtils.js.map +1 -0
- package/dist/utils/FileUtils.d.ts +67 -0
- package/dist/utils/FileUtils.d.ts.map +1 -0
- package/dist/utils/FileUtils.js +144 -0
- package/dist/utils/FileUtils.js.map +1 -0
- package/dist/utils/FunctionUtils.d.ts +47 -0
- package/dist/utils/FunctionUtils.d.ts.map +1 -0
- package/dist/utils/FunctionUtils.js +87 -0
- package/dist/utils/FunctionUtils.js.map +1 -0
- package/dist/utils/IdentifierUtils.d.ts +63 -0
- package/dist/utils/IdentifierUtils.d.ts.map +1 -0
- package/dist/utils/IdentifierUtils.js +133 -0
- package/dist/utils/IdentifierUtils.js.map +1 -0
- package/dist/utils/JoinpointUtils.d.ts +36 -0
- package/dist/utils/JoinpointUtils.d.ts.map +1 -0
- package/dist/utils/JoinpointUtils.js +63 -0
- package/dist/utils/JoinpointUtils.js.map +1 -0
- package/dist/utils/ProgramUtils.d.ts +39 -0
- package/dist/utils/ProgramUtils.d.ts.map +1 -0
- package/dist/utils/ProgramUtils.js +97 -0
- package/dist/utils/ProgramUtils.js.map +1 -0
- package/dist/utils/SwitchUtils.d.ts +21 -0
- package/dist/utils/SwitchUtils.d.ts.map +1 -0
- package/dist/utils/SwitchUtils.js +47 -0
- package/dist/utils/SwitchUtils.js.map +1 -0
- package/dist/utils/TypeDeclUtils.d.ts +35 -0
- package/dist/utils/TypeDeclUtils.d.ts.map +1 -0
- package/dist/utils/TypeDeclUtils.js +78 -0
- package/dist/utils/TypeDeclUtils.js.map +1 -0
- package/dist/utils/VarUtils.d.ts +51 -0
- package/dist/utils/VarUtils.d.ts.map +1 -0
- package/dist/utils/VarUtils.js +91 -0
- package/dist/utils/VarUtils.js.map +1 -0
- package/package.json +16 -7
- package/src/MISRA.ts +33 -17
- package/src/MISRAContext.ts +128 -30
- package/src/MISRARule.ts +61 -29
- package/src/MISRATool.ts +126 -42
- package/src/StandardGuideline.ts +23 -0
- package/src/ast-visitor/Context.ts +16 -0
- package/src/ast-visitor/Visit.ts +26 -0
- package/src/ast-visitor/VisitWithContext.ts +42 -0
- package/src/main.ts +1 -4
- package/src/rules/Section13_SideEffects/Rule_13_6_SafeSizeOfOperand.ts +114 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.ts +103 -13
- package/src/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.ts +24 -10
- package/src/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.ts +17 -8
- package/src/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.ts +20 -12
- package/src/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.ts +23 -12
- package/src/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.ts +44 -13
- package/src/rules/Section17_Functions/Rule_17_3_ImplicitFunction.ts +153 -104
- package/src/rules/Section17_Functions/Rule_17_4_NonVoidReturn.ts +114 -44
- package/src/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.ts +27 -10
- package/src/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.ts +20 -12
- package/src/rules/Section21-StandardLibraries/DisallowedStdLibFunctionRule.ts +317 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_10_NoTimeDateFunctions.ts +30 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_11_NoTgmathFunctions.ts +35 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory.ts +30 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.ts +30 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.ts +29 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.ts +36 -0
- package/src/rules/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.ts +30 -0
- package/src/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.ts +14 -29
- package/src/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.ts +33 -19
- package/src/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.ts +33 -20
- package/src/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.ts +90 -45
- package/src/rules/Section3_Comments/Rule_3_1_CommentSequences.ts +27 -8
- package/src/rules/Section5_Identifiers/IdentifierRenameRule.ts +63 -0
- package/src/rules/Section5_Identifiers/Rule_5_1_DistinctExternalIdentifiers.ts +52 -0
- package/src/rules/Section5_Identifiers/Rule_5_6_UniqueTypedefNames.ts +62 -0
- package/src/rules/Section5_Identifiers/Rule_5_7_UniqueTagNames.ts +61 -0
- package/src/rules/Section5_Identifiers/Rule_5_8_UniqueExternalLinkIdentifiers.ts +47 -0
- package/src/rules/Section5_Identifiers/Rule_5_9_UniqueInternalLinkIdentifiers.ts +47 -0
- package/src/rules/Section8_DeclarationsAndDefinitions/Rule_8_6_SingleExternalDefinition.ts +118 -0
- package/src/rules/Section8_DeclarationsAndDefinitions/Rule_8_7_RestrictExternalLinkage.ts +89 -0
- package/src/rules/Section8_DeclarationsAndDefinitions/Rule_8_9_BlockScopeDefinition.ts +65 -0
- package/src/rules/UserConfigurableRule.ts +60 -0
- package/src/rules/index.ts +45 -7
- package/src/tests/Section13_SideEffects/Rule_13_6_SafeSizeOfOperand.test.ts +114 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.test.ts +7 -5
- package/src/tests/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.test.ts +40 -13
- package/src/tests/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.test.ts +10 -12
- package/src/tests/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.test.ts +5 -5
- package/src/tests/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.test.ts +5 -5
- package/src/tests/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.test.ts +5 -5
- package/src/tests/Section17_Functions/Rule_17_3_ImplicitFunctions.test.ts +68 -40
- package/src/tests/Section17_Functions/Rule_17_3_ImplicitFunctions_MissingConfig.test.ts +98 -0
- package/src/tests/Section17_Functions/Rule_17_3_ImplicitFunctions_ProblematicConfig.test.ts +71 -0
- package/src/tests/Section17_Functions/Rule_17_4_NonVoidReturn.test.ts +103 -49
- package/src/tests/Section17_Functions/Rule_17_4_NonVoidReturn_MissingConfig.test.ts +7 -7
- package/src/tests/Section17_Functions/Rule_17_6_StaticArraySizeParam.test.ts +36 -7
- package/src/tests/Section17_Functions/Rule_17_7_UnusedReturnValue.test.ts +25 -21
- package/src/tests/Section17_Functions/misra_config.json +4 -3
- package/src/tests/Section21-StandardLibraries/Rule_21_10_NoTimeDateFunctions.test.ts +62 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_11_NoTgmathFunctions.test.ts +67 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory.test.ts +84 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory_MissingConfig.test.ts +33 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory_ProblematicConfig.test.ts +71 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.test.ts +63 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.test.ts +91 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.test.ts +65 -0
- package/src/tests/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.test.ts +89 -0
- package/src/tests/Section21-StandardLibraries/misra_config.json +88 -0
- package/src/tests/Section21-StandardLibraries/problematic_misra_config.json +19 -0
- package/src/tests/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.test.ts +148 -113
- package/src/tests/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.test.ts +243 -163
- package/src/tests/Section2_UnusedCode/Rule_2_6_UnusedLabels.test.ts +32 -20
- package/src/tests/Section2_UnusedCode/Rule_2_7_UnusedParameters.test.ts +36 -30
- package/src/tests/Section3_Comments/Rule_3_1_CommentSequences.test.ts +37 -8
- package/src/tests/Section5_Identifiers/Rule_5_1_DistinctExternalIdentifiers.test.ts +78 -0
- package/src/tests/Section5_Identifiers/Rule_5_6_UniqueTypedefNames.test.ts +120 -0
- package/src/tests/Section5_Identifiers/Rule_5_7_UniqueTagNames.test.ts +51 -0
- package/src/tests/Section5_Identifiers/Rule_5_8_UniqueExternalLinkIdentifiers.test.ts +73 -0
- package/src/tests/Section5_Identifiers/Rule_5_9_UniqueInternalLinkIdentifiers.test.ts +97 -0
- package/src/tests/Section8_DeclarationsAndDefinitions/Rule_8_6_SingleExternalDefinition.test.ts +160 -0
- package/src/tests/Section8_DeclarationsAndDefinitions/Rule_8_7_RestrictExternalLinkage.test.ts +46 -0
- package/src/tests/Section8_DeclarationsAndDefinitions/Rule_8_9_BlockScopeDefinition.test.ts +69 -0
- package/src/tests/utils.ts +32 -7
- package/src/utils/CallUtils.ts +37 -0
- package/src/utils/CommentUtils.ts +29 -0
- package/src/utils/FileUtils.ts +169 -0
- package/src/utils/FunctionUtils.ts +97 -0
- package/src/utils/IdentifierUtils.ts +142 -0
- package/src/utils/JoinpointUtils.ts +70 -0
- package/src/utils/ProgramUtils.ts +107 -0
- package/src/utils/SwitchUtils.ts +52 -0
- package/src/utils/TypeDeclUtils.ts +88 -0
- package/src/utils/VarUtils.ts +102 -0
- package/tsconfig.json +2 -1
- package/src/rules/Section20-PreprocessingDirectives/Rule_20_2_InvalidHeaderFileName.ts +0 -120
- package/src/rules/Section3_Comments/Rule_3_2_LineSplicing.ts +0 -36
- package/src/utils/utils.ts +0 -280
package/src/tests/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory_ProblematicConfig.test.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { countErrorsAfterCorrection, countMISRAErrors, registerSourceCode, TestFile } from "../utils.js";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
|
|
5
|
+
const failingCode = `
|
|
6
|
+
#include <stdlib.h>
|
|
7
|
+
|
|
8
|
+
int main() {
|
|
9
|
+
|
|
10
|
+
// Provided fix has internal linkage
|
|
11
|
+
int *a = calloc(1, sizeof(int));
|
|
12
|
+
|
|
13
|
+
// Provided fix has different num of parameters
|
|
14
|
+
int *b = malloc(sizeof(int));
|
|
15
|
+
|
|
16
|
+
// Provided file does not include provided function name
|
|
17
|
+
a = realloc(a, 2 * sizeof(int));
|
|
18
|
+
|
|
19
|
+
// Config has missing parameters
|
|
20
|
+
free(a);
|
|
21
|
+
free(b);
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
const customStdLib = `
|
|
27
|
+
#include <stddef.h>
|
|
28
|
+
|
|
29
|
+
static void* my_calloc(size_t num, size_t size) {
|
|
30
|
+
(void)num;
|
|
31
|
+
(void)size;
|
|
32
|
+
return NULL;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Missing "static" keyword; Will have external decl after correction
|
|
36
|
+
void* my_malloc(size_t num, size_t size) {
|
|
37
|
+
(void)num;
|
|
38
|
+
(void)size;
|
|
39
|
+
return NULL;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Missing "static" keyword; Will have external decl after correction
|
|
43
|
+
void my_free(void* ptr) {
|
|
44
|
+
(void)ptr;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
const files: TestFile[] = [
|
|
50
|
+
{ name: "bad1.c", code: failingCode },
|
|
51
|
+
{ name: "custom_stdlib.c", code: customStdLib }
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
describe("Rule 21.3", () => {
|
|
55
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
56
|
+
const __dirname = path.dirname(__filename);
|
|
57
|
+
|
|
58
|
+
const configFilename = "problematic_misra_config.json";
|
|
59
|
+
const configFilePath = path.join(__dirname, configFilename);
|
|
60
|
+
|
|
61
|
+
registerSourceCode(files, configFilePath);
|
|
62
|
+
|
|
63
|
+
it("should detect errors", () => {
|
|
64
|
+
expect(countMISRAErrors()).toBe(7);
|
|
65
|
+
expect(countMISRAErrors("21.3")).toBe(5);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("should correct errors", () => {
|
|
69
|
+
expect(countErrorsAfterCorrection()).toBe(5);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { countErrorsAfterCorrection, countMISRAErrors, registerSourceCode, TestFile } from "../utils.js";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
|
|
5
|
+
const failingCode = `
|
|
6
|
+
#include <stdio.h> /* Non-compliant */
|
|
7
|
+
|
|
8
|
+
static void test_21_6_1() {
|
|
9
|
+
char buffer[100];
|
|
10
|
+
|
|
11
|
+
// Non-compliant: call to stdlib function
|
|
12
|
+
(void) printf("Enter input: "); // Violation of rule 21.6
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const customStdIO = `
|
|
17
|
+
void my_printf(const char* fmt, ...) {
|
|
18
|
+
(void)fmt;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
char* my_fgets(char* str, int num, void* stream) {
|
|
22
|
+
(void)str;
|
|
23
|
+
(void)num;
|
|
24
|
+
(void)stream;
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
const systemFile = `
|
|
30
|
+
extern void my_printf(const char* fmt, ...);
|
|
31
|
+
extern char* my_fgets(char* str, int num, void* stream);
|
|
32
|
+
|
|
33
|
+
static void use_externs_21_6() {
|
|
34
|
+
char buffer_21_6[10];
|
|
35
|
+
my_printf("Done");
|
|
36
|
+
(void) my_fgets(buffer_21_6, 10, 0);
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const files: TestFile[] = [
|
|
41
|
+
{ name: "bad.c", code: failingCode },
|
|
42
|
+
{ name: "custom_stdio.c", code: customStdIO },
|
|
43
|
+
{ name: "rule_21_6_system.c", code: systemFile }
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
describe("Rule 21.6", () => {
|
|
47
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
48
|
+
const __dirname = path.dirname(__filename);
|
|
49
|
+
|
|
50
|
+
const configFilename = "misra_config.json";
|
|
51
|
+
const configFilePath = path.join(__dirname, configFilename);
|
|
52
|
+
|
|
53
|
+
registerSourceCode(files, configFilePath);
|
|
54
|
+
|
|
55
|
+
it("should detect errors", () => {
|
|
56
|
+
expect(countMISRAErrors()).toBe(2);
|
|
57
|
+
expect(countMISRAErrors("21.6")).toBeGreaterThanOrEqual(2);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("should correct errors", () => {
|
|
61
|
+
expect(countErrorsAfterCorrection()).toBe(0);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import Clava from "@specs-feup/clava/api/clava/Clava.js";
|
|
2
|
+
import { countErrorsAfterCorrection, countMISRAErrors, registerSourceCode, TestFile } from "../utils.js";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
|
|
6
|
+
const failingCode_C90 = `
|
|
7
|
+
#include <stdlib.h>
|
|
8
|
+
|
|
9
|
+
int main() {
|
|
10
|
+
double d = atof("3.14");
|
|
11
|
+
int i = atoi("42");
|
|
12
|
+
long l = atol("123456");
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
const failingCode_C99 = `
|
|
18
|
+
#include <stdlib.h>
|
|
19
|
+
|
|
20
|
+
int main() {
|
|
21
|
+
double d = atof("3.14");
|
|
22
|
+
int i = atoi("42");
|
|
23
|
+
long l = atol("123456");
|
|
24
|
+
long long ll = atoll("1234567890");
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
const customStdLib = `
|
|
30
|
+
#include <stddef.h>
|
|
31
|
+
|
|
32
|
+
double my_atof(const char* str) {
|
|
33
|
+
(void)str;
|
|
34
|
+
return 0.0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
int my_atoi(const char* str) {
|
|
38
|
+
(void)str;
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
long my_atol(const char* str) {
|
|
43
|
+
(void)str;
|
|
44
|
+
return 0L;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
long long my_atoll(const char* str) {
|
|
48
|
+
(void)str;
|
|
49
|
+
return 0LL;
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
const systemFile = `
|
|
54
|
+
extern double my_atof(const char* str);
|
|
55
|
+
extern int my_atoi(const char* str);
|
|
56
|
+
extern long my_atol(const char* str);
|
|
57
|
+
extern long long my_atoll(const char* str);
|
|
58
|
+
|
|
59
|
+
static void use_externs_21_7(void) {
|
|
60
|
+
(void) my_atof("3.14");
|
|
61
|
+
(void) my_atoi("42");
|
|
62
|
+
(void) my_atol("100000");
|
|
63
|
+
(void) my_atoll("9223372036854775807");
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
const stdVerstion = Clava.getStandard();
|
|
68
|
+
const files: TestFile[] = [
|
|
69
|
+
{ name: "bad1.c", code: stdVerstion === "c90" ? failingCode_C90 : failingCode_C99 },
|
|
70
|
+
{ name: "custom_stdlib.c", code: customStdLib },
|
|
71
|
+
{ name: "rule_21_7_system.c", code: systemFile }
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
describe("Rule 21.7", () => {
|
|
75
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
76
|
+
const __dirname = path.dirname(__filename);
|
|
77
|
+
|
|
78
|
+
const configFilename = "misra_config.json";
|
|
79
|
+
const configFilePath = path.join(__dirname, configFilename);
|
|
80
|
+
|
|
81
|
+
registerSourceCode(files, configFilePath);
|
|
82
|
+
|
|
83
|
+
it("should detect errors", () => {
|
|
84
|
+
expect(countMISRAErrors()).toBe(stdVerstion === "c90" ? 3 : 4);
|
|
85
|
+
expect(countMISRAErrors("21.7")).toBe(stdVerstion === "c90" ? 3 : 4);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("should correct errors", () => {
|
|
89
|
+
expect(countErrorsAfterCorrection()).toBe(0);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import Clava from "@specs-feup/clava/api/clava/Clava.js";
|
|
2
|
+
import { countErrorsAfterCorrection, countMISRAErrors, registerSourceCode, TestFile } from "../utils.js";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
|
|
6
|
+
const failingCode = `
|
|
7
|
+
#include <stdlib.h>
|
|
8
|
+
|
|
9
|
+
static int test_21_8_1() {
|
|
10
|
+
abort(); // Violation of rule 21.8
|
|
11
|
+
exit(1); // Violation of rule 21.8
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
// Custom implementations that will be used for correction
|
|
17
|
+
const customStdLib = `
|
|
18
|
+
#include <stddef.h>
|
|
19
|
+
|
|
20
|
+
void my_abort(void) {
|
|
21
|
+
// safe replacement
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
void my_exit(int status) {
|
|
25
|
+
(void)status;
|
|
26
|
+
// safe replacement
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const systemFile = `
|
|
31
|
+
extern void my_abort(void);
|
|
32
|
+
extern void my_exit(int status);
|
|
33
|
+
|
|
34
|
+
static void use_externs_21_8() {
|
|
35
|
+
my_abort();
|
|
36
|
+
my_exit(1);
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const files: TestFile[] = [
|
|
41
|
+
{ name: "bad.c", code: failingCode },
|
|
42
|
+
{ name: "custom_stdlib.c", code: customStdLib },
|
|
43
|
+
{ name: "rule_21_8_system.c", code: systemFile }
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
describe("Rule 21.8", () => {
|
|
47
|
+
if (Clava.getStandard() === "c11") {
|
|
48
|
+
it("should skip tests for c11", () => {});
|
|
49
|
+
} else {
|
|
50
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
51
|
+
const __dirname = path.dirname(__filename);
|
|
52
|
+
const configFilePath = path.join(__dirname, "misra_config.json");
|
|
53
|
+
|
|
54
|
+
registerSourceCode(files, configFilePath);
|
|
55
|
+
|
|
56
|
+
it("should detect errors", () => {
|
|
57
|
+
expect(countMISRAErrors()).toBe(2);
|
|
58
|
+
expect(countMISRAErrors("21.8")).toBe(2);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should correct errors", () => {
|
|
62
|
+
expect(countErrorsAfterCorrection()).toBe(0);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { countErrorsAfterCorrection, countMISRAErrors, registerSourceCode, TestFile } from "../utils.js";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
|
|
5
|
+
const bad = `
|
|
6
|
+
#include <stdlib.h>
|
|
7
|
+
|
|
8
|
+
static int compare(const void* a, const void* b) {
|
|
9
|
+
return (*(int*)a - *(int*)b);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static int test_21_9_1() {
|
|
13
|
+
int arr1[] = { 5, 3, 1, 4, 2 };
|
|
14
|
+
int n1 = sizeof(arr1) / sizeof(arr1[0]);
|
|
15
|
+
qsort(arr1, n1, sizeof(int), compare); // Non-compliant
|
|
16
|
+
|
|
17
|
+
int arr2[] = { 1, 2, 3, 4, 5 };
|
|
18
|
+
int key = 3;
|
|
19
|
+
int n2 = sizeof(arr2) / sizeof(arr2[0]);
|
|
20
|
+
int* item = (int*)bsearch(&key, arr2, n2, sizeof(int), compare); // Non-compliant
|
|
21
|
+
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
const customStdLib = `
|
|
27
|
+
#include <stddef.h>
|
|
28
|
+
|
|
29
|
+
void my_qsort(void* base, size_t num, size_t size, int (*compar)(const void*, const void*)) {
|
|
30
|
+
(void)base;
|
|
31
|
+
(void)num;
|
|
32
|
+
(void)size;
|
|
33
|
+
(void)compar;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void* my_bsearch(const void* key, const void* base, size_t num, size_t size, int (*compar)(const void*, const void*)) {
|
|
37
|
+
(void)key;
|
|
38
|
+
(void)base;
|
|
39
|
+
(void)num;
|
|
40
|
+
(void)size;
|
|
41
|
+
(void)compar;
|
|
42
|
+
return NULL;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
|
|
46
|
+
const systemFile = `
|
|
47
|
+
#include <stddef.h>
|
|
48
|
+
extern void my_qsort(void* base, size_t num, size_t size, int (*compar)(const void*, const void*));
|
|
49
|
+
extern void* my_bsearch(const void* key, const void* base, size_t num, size_t size, int (*compar)(const void*, const void*));
|
|
50
|
+
|
|
51
|
+
static int compare_21_9(const void* a, const void* b) {
|
|
52
|
+
int arg1 = *(const int*)a;
|
|
53
|
+
int arg2 = *(const int*)b;
|
|
54
|
+
return (arg1 > arg2) - (arg1 < arg2);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static void use_externs_21_9(void) {
|
|
58
|
+
int arr[5] = {5, 3, 1, 4, 2};
|
|
59
|
+
int key = 3;
|
|
60
|
+
|
|
61
|
+
my_qsort(arr, 5, sizeof(int), compare_21_9);
|
|
62
|
+
(void) my_bsearch(&key, arr, 5, sizeof(int), compare_21_9);
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
const files: TestFile[] = [
|
|
67
|
+
{ name: "bad.c", code: bad },
|
|
68
|
+
{ name: "custom_stdlib.c", code: customStdLib },
|
|
69
|
+
{ name: "rule_21_9_system.c", code: systemFile }
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
describe("Rule 21.9", () => {
|
|
73
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
74
|
+
const __dirname = path.dirname(__filename);
|
|
75
|
+
|
|
76
|
+
const configFilename = "misra_config.json";
|
|
77
|
+
const configFilePath = path.join(__dirname, configFilename);
|
|
78
|
+
|
|
79
|
+
registerSourceCode(files, configFilePath);
|
|
80
|
+
|
|
81
|
+
it("should detect errors", () => {
|
|
82
|
+
expect(countMISRAErrors()).toBe(2);
|
|
83
|
+
expect(countMISRAErrors("21.9")).toBe(2);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("should correct errors", () => {
|
|
87
|
+
expect(countErrorsAfterCorrection()).toBe(0);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"disallowedFunctions": {
|
|
3
|
+
"stdlib.h": {
|
|
4
|
+
"malloc": {
|
|
5
|
+
"replacement": "my_malloc",
|
|
6
|
+
"location": "custom_stdlib.c"
|
|
7
|
+
},
|
|
8
|
+
"calloc": {
|
|
9
|
+
"replacement": "my_calloc",
|
|
10
|
+
"location": "custom_stdlib.c"
|
|
11
|
+
},
|
|
12
|
+
"realloc": {
|
|
13
|
+
"replacement": "my_realloc",
|
|
14
|
+
"location": "custom_stdlib.c"
|
|
15
|
+
},
|
|
16
|
+
"free": {
|
|
17
|
+
"replacement": "my_free",
|
|
18
|
+
"location": "custom_stdlib.c"
|
|
19
|
+
},
|
|
20
|
+
"atof": {
|
|
21
|
+
"replacement": "my_atof",
|
|
22
|
+
"location": "custom_stdlib.c"
|
|
23
|
+
},
|
|
24
|
+
"atoi": {
|
|
25
|
+
"replacement": "my_atoi",
|
|
26
|
+
"location": "custom_stdlib.c"
|
|
27
|
+
},
|
|
28
|
+
"atol": {
|
|
29
|
+
"replacement": "my_atol",
|
|
30
|
+
"location": "custom_stdlib.c"
|
|
31
|
+
},
|
|
32
|
+
"atoll": {
|
|
33
|
+
"replacement": "my_atoll",
|
|
34
|
+
"location": "custom_stdlib.c"
|
|
35
|
+
},
|
|
36
|
+
"abort": {
|
|
37
|
+
"replacement": "my_abort",
|
|
38
|
+
"location": "custom_stdlib.c"
|
|
39
|
+
},
|
|
40
|
+
"exit": {
|
|
41
|
+
"replacement": "my_exit",
|
|
42
|
+
"location": "custom_stdlib.c"
|
|
43
|
+
},
|
|
44
|
+
"getenv": {
|
|
45
|
+
"replacement": "my_getenv",
|
|
46
|
+
"location": "custom_stdlib.c"
|
|
47
|
+
},
|
|
48
|
+
"system": {
|
|
49
|
+
"replacement": "my_system",
|
|
50
|
+
"location": "custom_stdlib.c"
|
|
51
|
+
},
|
|
52
|
+
"qsort": {
|
|
53
|
+
"replacement": "my_qsort",
|
|
54
|
+
"location": "custom_stdlib.c"
|
|
55
|
+
},
|
|
56
|
+
"bsearch": {
|
|
57
|
+
"replacement": "my_bsearch",
|
|
58
|
+
"location": "custom_stdlib.c"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"stdio.h": {
|
|
62
|
+
"printf": {
|
|
63
|
+
"replacement": "my_printf",
|
|
64
|
+
"location": "custom_stdio.c"
|
|
65
|
+
},
|
|
66
|
+
"fgets": {
|
|
67
|
+
"replacement": "my_fgets",
|
|
68
|
+
"location": "custom_stdio.c"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"time.h": {
|
|
72
|
+
"difftime": {
|
|
73
|
+
"replacement": "my_difftime",
|
|
74
|
+
"location": "custom_time.c"
|
|
75
|
+
},
|
|
76
|
+
"clock": {
|
|
77
|
+
"replacement": "my_clock",
|
|
78
|
+
"location": "custom_time.c"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"tgmath.h": {
|
|
82
|
+
"__tg_sqrt": {
|
|
83
|
+
"replacement": "my_sqrt",
|
|
84
|
+
"location": "custom_math.c"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"disallowedFunctions": {
|
|
3
|
+
"stdlib.h": {
|
|
4
|
+
"malloc": {
|
|
5
|
+
"replacement": "my_malloc",
|
|
6
|
+
"location": "custom_stdlib.c"
|
|
7
|
+
},
|
|
8
|
+
"calloc": {
|
|
9
|
+
"replacement": "my_calloc",
|
|
10
|
+
"location": "custom_stdlib.c"
|
|
11
|
+
},
|
|
12
|
+
"realloc": {
|
|
13
|
+
"replacement": "my_realloc",
|
|
14
|
+
"location": "custom_stdlib.c"
|
|
15
|
+
},
|
|
16
|
+
"free": {}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|