@specs-feup/clava-misra 1.0.2 → 1.0.3
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 +39 -5
- package/dist/MISRATool.d.ts.map +1 -1
- package/dist/MISRATool.js +102 -46
- 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 -1
- 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 +51 -0
- package/dist/utils/FileUtils.d.ts.map +1 -0
- package/dist/utils/FileUtils.js +121 -0
- package/dist/utils/FileUtils.js.map +1 -0
- package/dist/utils/FunctionUtils.d.ts +25 -0
- package/dist/utils/FunctionUtils.d.ts.map +1 -0
- package/dist/utils/FunctionUtils.js +65 -0
- package/dist/utils/FunctionUtils.js.map +1 -0
- package/dist/utils/IdentifierUtils.d.ts +14 -0
- package/dist/utils/IdentifierUtils.d.ts.map +1 -0
- package/dist/utils/IdentifierUtils.js +87 -0
- package/dist/utils/IdentifierUtils.js.map +1 -0
- package/dist/utils/JoinpointUtils.d.ts +19 -0
- package/dist/utils/JoinpointUtils.d.ts.map +1 -0
- package/dist/utils/JoinpointUtils.js +46 -0
- package/dist/utils/JoinpointUtils.js.map +1 -0
- package/dist/utils/ProgramUtils.d.ts +14 -0
- package/dist/utils/ProgramUtils.d.ts.map +1 -0
- package/dist/utils/ProgramUtils.js +72 -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 +19 -0
- package/dist/utils/VarUtils.d.ts.map +1 -0
- package/dist/utils/VarUtils.js +59 -0
- package/dist/utils/VarUtils.js.map +1 -0
- package/package.json +16 -6
- package/src/MISRA.ts +33 -17
- package/src/MISRAContext.ts +128 -30
- package/src/MISRARule.ts +61 -29
- package/src/MISRATool.ts +108 -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 -1
- 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 +40 -0
- package/src/utils/CommentUtils.ts +29 -0
- package/src/utils/FileUtils.ts +141 -0
- package/src/utils/FunctionUtils.ts +75 -0
- package/src/utils/IdentifierUtils.ts +94 -0
- package/src/utils/JoinpointUtils.ts +53 -0
- package/src/utils/ProgramUtils.ts +83 -0
- package/src/utils/SwitchUtils.ts +52 -0
- package/src/utils/TypeDeclUtils.ts +89 -0
- package/src/utils/VarUtils.ts +70 -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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AnalysisType } from "../../MISRA.js";
|
|
2
|
+
import DisallowedStdLibFunctionRule from "./DisallowedStdLibFunctionRule.js";
|
|
3
|
+
/**
|
|
4
|
+
* MISRA-C Rule 21.3: The memory allocation and deallocation functions of <stdlib.h> shall not be used
|
|
5
|
+
*/
|
|
6
|
+
export default class Rule_21_3_NoDynamicMemory extends DisallowedStdLibFunctionRule {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the standard library
|
|
9
|
+
*/
|
|
10
|
+
standardLibrary = "stdlib.h";
|
|
11
|
+
/**
|
|
12
|
+
* Names of functions from {@link standardLibrary} that are forbidden.
|
|
13
|
+
* If the set is empty, all functions from {@link standardLibrary} are forbidden.
|
|
14
|
+
*/
|
|
15
|
+
invalidFunctions = new Set(["calloc", "malloc", "aligned_alloc", "realloc", "free"]);
|
|
16
|
+
/**
|
|
17
|
+
* Scope of analysis
|
|
18
|
+
*/
|
|
19
|
+
analysisType = AnalysisType.SINGLE_TRANSLATION_UNIT;
|
|
20
|
+
/**
|
|
21
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
22
|
+
*/
|
|
23
|
+
get name() {
|
|
24
|
+
return "21.3";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=Rule_21_3_NoDynamicMemory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rule_21_3_NoDynamicMemory.js","sourceRoot":"","sources":["../../../src/rules/Section21-StandardLibraries/Rule_21_3_NoDynamicMemory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,4BAA4B,MAAM,mCAAmC,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,yBAA0B,SAAQ,4BAA4B;IAC/E;;OAEG;IACO,eAAe,GAAG,UAAU,CAAC;IAEvC;;;OAGG;IACO,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;IAE/F;;OAEG;IACM,YAAY,GAAG,YAAY,CAAC,uBAAuB,CAAC;IAE7D;;OAEG;IACH,IAAa,IAAI;QACb,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AnalysisType } from "../../MISRA.js";
|
|
2
|
+
import DisallowedStdLibFunctionRule from "./DisallowedStdLibFunctionRule.js";
|
|
3
|
+
/**
|
|
4
|
+
* MISRA-C Rule 21.6: The Standard Library input/output functions shall not be used
|
|
5
|
+
*/
|
|
6
|
+
export default class Rule_21_6_NoStdIOFunctions extends DisallowedStdLibFunctionRule {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the standard library
|
|
9
|
+
*/
|
|
10
|
+
protected standardLibrary: string;
|
|
11
|
+
/**
|
|
12
|
+
* Names of functions from {@link standardLibrary} that are forbidden.
|
|
13
|
+
* If the set is empty, all functions from {@link standardLibrary} are forbidden.
|
|
14
|
+
*/
|
|
15
|
+
protected invalidFunctions: Set<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Scope of analysis
|
|
18
|
+
*/
|
|
19
|
+
readonly analysisType = AnalysisType.SINGLE_TRANSLATION_UNIT;
|
|
20
|
+
/**
|
|
21
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
22
|
+
*/
|
|
23
|
+
get name(): string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=Rule_21_6_NoStdIOFunctions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rule_21_6_NoStdIOFunctions.d.ts","sourceRoot":"","sources":["../../../src/rules/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,4BAA4B,MAAM,mCAAmC,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,4BAA4B;IAChF;;OAEG;IACH,SAAS,CAAC,eAAe,SAAa;IAEtC;;;OAGG;IACH,SAAS,CAAC,gBAAgB,cAAqB;IAE/C;;OAEG;IACH,QAAQ,CAAC,YAAY,wCAAwC;IAE7D;;OAEG;IACH,IAAa,IAAI,IAAI,MAAM,CAE1B;CACJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AnalysisType } from "../../MISRA.js";
|
|
2
|
+
import DisallowedStdLibFunctionRule from "./DisallowedStdLibFunctionRule.js";
|
|
3
|
+
/**
|
|
4
|
+
* MISRA-C Rule 21.6: The Standard Library input/output functions shall not be used
|
|
5
|
+
*/
|
|
6
|
+
export default class Rule_21_6_NoStdIOFunctions extends DisallowedStdLibFunctionRule {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the standard library
|
|
9
|
+
*/
|
|
10
|
+
standardLibrary = "stdio.h";
|
|
11
|
+
/**
|
|
12
|
+
* Names of functions from {@link standardLibrary} that are forbidden.
|
|
13
|
+
* If the set is empty, all functions from {@link standardLibrary} are forbidden.
|
|
14
|
+
*/
|
|
15
|
+
invalidFunctions = new Set();
|
|
16
|
+
/**
|
|
17
|
+
* Scope of analysis
|
|
18
|
+
*/
|
|
19
|
+
analysisType = AnalysisType.SINGLE_TRANSLATION_UNIT;
|
|
20
|
+
/**
|
|
21
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
22
|
+
*/
|
|
23
|
+
get name() {
|
|
24
|
+
return "21.6";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=Rule_21_6_NoStdIOFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rule_21_6_NoStdIOFunctions.js","sourceRoot":"","sources":["../../../src/rules/Section21-StandardLibraries/Rule_21_6_NoStdIOFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,4BAA4B,MAAM,mCAAmC,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,4BAA4B;IAChF;;OAEG;IACO,eAAe,GAAG,SAAS,CAAC;IAEtC;;;OAGG;IACO,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/C;;OAEG;IACM,YAAY,GAAG,YAAY,CAAC,uBAAuB,CAAC;IAE7D;;OAEG;IACH,IAAa,IAAI;QACb,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AnalysisType } from "../../MISRA.js";
|
|
2
|
+
import DisallowedStdLibFunctionRule from "./DisallowedStdLibFunctionRule.js";
|
|
3
|
+
/**
|
|
4
|
+
* MISRA-C Rule 21.7: The atof, atoi, atol and atoll functions of <stdlib.h> shall not be used.
|
|
5
|
+
*/
|
|
6
|
+
export default class Rule_21_7_NoNumericStringConversions extends DisallowedStdLibFunctionRule {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the standard library
|
|
9
|
+
*/
|
|
10
|
+
protected standardLibrary: string;
|
|
11
|
+
/**
|
|
12
|
+
* Names of functions from {@link standardLibrary} that are forbidden.
|
|
13
|
+
* If the set is empty, all functions from {@link standardLibrary} are forbidden.
|
|
14
|
+
*/
|
|
15
|
+
protected invalidFunctions: Set<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Scope of analysis
|
|
18
|
+
*/
|
|
19
|
+
readonly analysisType = AnalysisType.SINGLE_TRANSLATION_UNIT;
|
|
20
|
+
/**
|
|
21
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
22
|
+
*/
|
|
23
|
+
get name(): string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=Rule_21_7_NoNumericStringConversions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rule_21_7_NoNumericStringConversions.d.ts","sourceRoot":"","sources":["../../../src/rules/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,4BAA4B,MAAM,mCAAmC,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,oCAAqC,SAAQ,4BAA4B;IAC1F;;OAEG;IACH,SAAS,CAAC,eAAe,SAAc;IAEvC;;;OAGG;IACH,SAAS,CAAC,gBAAgB,cAA8C;IACxE;;OAEG;IACH,QAAQ,CAAC,YAAY,wCAAwC;IAE7D;;OAEG;IACH,IAAa,IAAI,IAAI,MAAM,CAE1B;CACJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AnalysisType } from "../../MISRA.js";
|
|
2
|
+
import DisallowedStdLibFunctionRule from "./DisallowedStdLibFunctionRule.js";
|
|
3
|
+
/**
|
|
4
|
+
* MISRA-C Rule 21.7: The atof, atoi, atol and atoll functions of <stdlib.h> shall not be used.
|
|
5
|
+
*/
|
|
6
|
+
export default class Rule_21_7_NoNumericStringConversions extends DisallowedStdLibFunctionRule {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the standard library
|
|
9
|
+
*/
|
|
10
|
+
standardLibrary = "stdlib.h";
|
|
11
|
+
/**
|
|
12
|
+
* Names of functions from {@link standardLibrary} that are forbidden.
|
|
13
|
+
* If the set is empty, all functions from {@link standardLibrary} are forbidden.
|
|
14
|
+
*/
|
|
15
|
+
invalidFunctions = new Set(["atof", "atoi", "atol", "atoll"]);
|
|
16
|
+
/**
|
|
17
|
+
* Scope of analysis
|
|
18
|
+
*/
|
|
19
|
+
analysisType = AnalysisType.SINGLE_TRANSLATION_UNIT;
|
|
20
|
+
/**
|
|
21
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
22
|
+
*/
|
|
23
|
+
get name() {
|
|
24
|
+
return "21.7";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=Rule_21_7_NoNumericStringConversions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rule_21_7_NoNumericStringConversions.js","sourceRoot":"","sources":["../../../src/rules/Section21-StandardLibraries/Rule_21_7_NoNumericStringConversions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,4BAA4B,MAAM,mCAAmC,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,oCAAqC,SAAQ,4BAA4B;IAC1F;;OAEG;IACO,eAAe,GAAG,UAAU,CAAC;IAEvC;;;OAGG;IACO,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACxE;;OAEG;IACM,YAAY,GAAG,YAAY,CAAC,uBAAuB,CAAC;IAE7D;;OAEG;IACH,IAAa,IAAI;QACb,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AnalysisType } from "../../MISRA.js";
|
|
2
|
+
import DisallowedStdLibFunctionRule from "./DisallowedStdLibFunctionRule.js";
|
|
3
|
+
/**
|
|
4
|
+
* MISRA-C Rule 21.8: The library functions abort, exit, getenv and system of <stdlib.h>
|
|
5
|
+
* shall not be used
|
|
6
|
+
*/
|
|
7
|
+
export default class Rule_21_8_NoProcessControlFunctions extends DisallowedStdLibFunctionRule {
|
|
8
|
+
/**
|
|
9
|
+
* Standards to which this rule applies to
|
|
10
|
+
*/
|
|
11
|
+
protected readonly appliesTo: Set<string>;
|
|
12
|
+
/**
|
|
13
|
+
* The name of the standard library
|
|
14
|
+
*/
|
|
15
|
+
protected standardLibrary: string;
|
|
16
|
+
/**
|
|
17
|
+
* Names of functions from {@link standardLibrary} that are forbidden.
|
|
18
|
+
* If the set is empty, all functions from {@link standardLibrary} are forbidden.
|
|
19
|
+
*/
|
|
20
|
+
protected invalidFunctions: Set<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Scope of analysis
|
|
23
|
+
*/
|
|
24
|
+
readonly analysisType = AnalysisType.SINGLE_TRANSLATION_UNIT;
|
|
25
|
+
/**
|
|
26
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
27
|
+
*/
|
|
28
|
+
get name(): string;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=Rule_21_8_NoProcessControlFunctions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rule_21_8_NoProcessControlFunctions.d.ts","sourceRoot":"","sources":["../../../src/rules/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,4BAA4B,MAAM,mCAAmC,CAAC;AAE7E;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,mCAAoC,SAAQ,4BAA4B;IACzF;;OAEG;IACH,mBAA4B,SAAS,cAA2B;IAEhE;;OAEG;IACH,SAAS,CAAC,eAAe,SAAc;IAEvC;;;OAGG;IACH,SAAS,CAAC,gBAAgB,cAAkD;IAE5E;;OAEG;IACH,QAAQ,CAAC,YAAY,wCAAwC;IAE7D;;OAEG;IACH,IAAa,IAAI,IAAI,MAAM,CAE1B;CACJ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AnalysisType } from "../../MISRA.js";
|
|
2
|
+
import DisallowedStdLibFunctionRule from "./DisallowedStdLibFunctionRule.js";
|
|
3
|
+
/**
|
|
4
|
+
* MISRA-C Rule 21.8: The library functions abort, exit, getenv and system of <stdlib.h>
|
|
5
|
+
* shall not be used
|
|
6
|
+
*/
|
|
7
|
+
export default class Rule_21_8_NoProcessControlFunctions extends DisallowedStdLibFunctionRule {
|
|
8
|
+
/**
|
|
9
|
+
* Standards to which this rule applies to
|
|
10
|
+
*/
|
|
11
|
+
appliesTo = new Set(["c90", "c99"]);
|
|
12
|
+
/**
|
|
13
|
+
* The name of the standard library
|
|
14
|
+
*/
|
|
15
|
+
standardLibrary = "stdlib.h";
|
|
16
|
+
/**
|
|
17
|
+
* Names of functions from {@link standardLibrary} that are forbidden.
|
|
18
|
+
* If the set is empty, all functions from {@link standardLibrary} are forbidden.
|
|
19
|
+
*/
|
|
20
|
+
invalidFunctions = new Set(["abort", "exit", "getenv", "system"]);
|
|
21
|
+
/**
|
|
22
|
+
* Scope of analysis
|
|
23
|
+
*/
|
|
24
|
+
analysisType = AnalysisType.SINGLE_TRANSLATION_UNIT;
|
|
25
|
+
/**
|
|
26
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
27
|
+
*/
|
|
28
|
+
get name() {
|
|
29
|
+
return "21.8";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=Rule_21_8_NoProcessControlFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rule_21_8_NoProcessControlFunctions.js","sourceRoot":"","sources":["../../../src/rules/Section21-StandardLibraries/Rule_21_8_NoProcessControlFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,4BAA4B,MAAM,mCAAmC,CAAC;AAE7E;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,mCAAoC,SAAQ,4BAA4B;IACzF;;OAEG;IACyB,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAEhE;;OAEG;IACO,eAAe,GAAG,UAAU,CAAC;IAEvC;;;OAGG;IACO,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE5E;;OAEG;IACM,YAAY,GAAG,YAAY,CAAC,uBAAuB,CAAC;IAE7D;;OAEG;IACH,IAAa,IAAI;QACb,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AnalysisType } from "../../MISRA.js";
|
|
2
|
+
import DisallowedStdLibFunctionRule from "./DisallowedStdLibFunctionRule.js";
|
|
3
|
+
/**
|
|
4
|
+
* MISRA-C Rule 21.9: The library functions bsearch and qsort of <stdlib.h> shall not be used.
|
|
5
|
+
*/
|
|
6
|
+
export default class Rule_21_9_NoGenericSearchOrSort extends DisallowedStdLibFunctionRule {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the standard library
|
|
9
|
+
*/
|
|
10
|
+
protected standardLibrary: string;
|
|
11
|
+
/**
|
|
12
|
+
* Names of functions from {@link standardLibrary} that are forbidden.
|
|
13
|
+
* If the set is empty, all functions from {@link standardLibrary} are forbidden.
|
|
14
|
+
*/
|
|
15
|
+
protected invalidFunctions: Set<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Scope of analysis
|
|
18
|
+
*/
|
|
19
|
+
readonly analysisType = AnalysisType.SINGLE_TRANSLATION_UNIT;
|
|
20
|
+
/**
|
|
21
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
22
|
+
*/
|
|
23
|
+
get name(): string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=Rule_21_9_NoGenericSearchOrSort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rule_21_9_NoGenericSearchOrSort.d.ts","sourceRoot":"","sources":["../../../src/rules/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,4BAA4B,MAAM,mCAAmC,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,+BAAgC,SAAQ,4BAA4B;IACrF;;OAEG;IACH,SAAS,CAAC,eAAe,SAAc;IAEvC;;;OAGG;IACH,SAAS,CAAC,gBAAgB,cAAiC;IAE3D;;OAEG;IACH,QAAQ,CAAC,YAAY,wCAAwC;IAE7D;;OAEG;IACH,IAAa,IAAI,IAAI,MAAM,CAE1B;CACJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AnalysisType } from "../../MISRA.js";
|
|
2
|
+
import DisallowedStdLibFunctionRule from "./DisallowedStdLibFunctionRule.js";
|
|
3
|
+
/**
|
|
4
|
+
* MISRA-C Rule 21.9: The library functions bsearch and qsort of <stdlib.h> shall not be used.
|
|
5
|
+
*/
|
|
6
|
+
export default class Rule_21_9_NoGenericSearchOrSort extends DisallowedStdLibFunctionRule {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the standard library
|
|
9
|
+
*/
|
|
10
|
+
standardLibrary = "stdlib.h";
|
|
11
|
+
/**
|
|
12
|
+
* Names of functions from {@link standardLibrary} that are forbidden.
|
|
13
|
+
* If the set is empty, all functions from {@link standardLibrary} are forbidden.
|
|
14
|
+
*/
|
|
15
|
+
invalidFunctions = new Set(["bsearch", "qsort"]);
|
|
16
|
+
/**
|
|
17
|
+
* Scope of analysis
|
|
18
|
+
*/
|
|
19
|
+
analysisType = AnalysisType.SINGLE_TRANSLATION_UNIT;
|
|
20
|
+
/**
|
|
21
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
22
|
+
*/
|
|
23
|
+
get name() {
|
|
24
|
+
return "21.9";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=Rule_21_9_NoGenericSearchOrSort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rule_21_9_NoGenericSearchOrSort.js","sourceRoot":"","sources":["../../../src/rules/Section21-StandardLibraries/Rule_21_9_NoGenericSearchOrSort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,4BAA4B,MAAM,mCAAmC,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,+BAAgC,SAAQ,4BAA4B;IACrF;;OAEG;IACO,eAAe,GAAG,UAAU,CAAC;IAEvC;;;OAGG;IACO,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;IAE3D;;OAEG;IACM,YAAY,GAAG,YAAY,CAAC,uBAAuB,CAAC;IAE7D;;OAEG;IACH,IAAa,IAAI;QACb,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
import { Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
|
2
2
|
import MISRARule from "../../MISRARule.js";
|
|
3
|
-
import
|
|
4
|
-
import { MISRATransformationReport } from "../../MISRA.js";
|
|
3
|
+
import { AnalysisType, MISRATransformationReport } from "../../MISRA.js";
|
|
5
4
|
/**
|
|
6
5
|
* MISRA-C Rule 2.3: A project should not contain unused type declarations.
|
|
7
6
|
*/
|
|
8
7
|
export default class Rule_2_3_UnusedTypeDecl extends MISRARule {
|
|
9
|
-
constructor(context: MISRAContext);
|
|
10
8
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @param jp - The joinpoint to check
|
|
13
|
-
* @param typeDecl - The typedef declaration to check against
|
|
14
|
-
* @returns Returns true if the joinpoint uses the given typedef declaration, false otherwise
|
|
9
|
+
* Scope of analysis
|
|
15
10
|
*/
|
|
16
|
-
|
|
11
|
+
readonly analysisType = AnalysisType.SYSTEM;
|
|
17
12
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @param typeDecl - The typedef declaration to search for in the joinpoints
|
|
21
|
-
* @returns Array of joinpoints that use the given typedef declaration
|
|
13
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
22
14
|
*/
|
|
23
|
-
|
|
15
|
+
get name(): string;
|
|
24
16
|
/**
|
|
25
17
|
* Checks if the given joinpoint represents an unused type declaration
|
|
26
18
|
* @param $jp - Joinpoint to analyze
|
|
@@ -38,6 +30,6 @@ export default class Rule_2_3_UnusedTypeDecl extends MISRARule {
|
|
|
38
30
|
* @param $jp - Joinpoint to transform
|
|
39
31
|
* @returns Report detailing the transformation result
|
|
40
32
|
*/
|
|
41
|
-
|
|
33
|
+
apply($jp: Joinpoint): MISRATransformationReport;
|
|
42
34
|
}
|
|
43
35
|
//# sourceMappingURL=Rule_2_3_UnusedTypeDecl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rule_2_3_UnusedTypeDecl.d.ts","sourceRoot":"","sources":["../../../src/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Rule_2_3_UnusedTypeDecl.d.ts","sourceRoot":"","sources":["../../../src/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAA2B,MAAM,gBAAgB,CAAC;AAIlG;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,SAAS;IAC1D;;OAEG;IACH,QAAQ,CAAC,YAAY,uBAAuB;IAE5C;;OAEG;IACH,IAAa,IAAI,IAAI,MAAM,CAE1B;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,GAAE,OAAe,GAAG,OAAO;IAW1D;;;;;;;;;OASG;IACH,KAAK,CAAC,GAAG,EAAE,SAAS,GAAG,yBAAyB;CAanD"}
|
|
@@ -1,32 +1,20 @@
|
|
|
1
|
-
import { EnumDecl, RecordJp, TypedefType } from "@specs-feup/clava/api/Joinpoints.js";
|
|
2
1
|
import MISRARule from "../../MISRARule.js";
|
|
3
|
-
import { MISRATransformationReport, MISRATransformationType } from "../../MISRA.js";
|
|
4
|
-
import {
|
|
2
|
+
import { AnalysisType, MISRATransformationReport, MISRATransformationType } from "../../MISRA.js";
|
|
3
|
+
import { getTypeDefDecl, isTypeDeclUsed } from "../../utils/TypeDeclUtils.js";
|
|
4
|
+
import { isTagDecl } from "../../utils/JoinpointUtils.js";
|
|
5
5
|
/**
|
|
6
6
|
* MISRA-C Rule 2.3: A project should not contain unused type declarations.
|
|
7
7
|
*/
|
|
8
8
|
export default class Rule_2_3_UnusedTypeDecl extends MISRARule {
|
|
9
|
-
constructor(context) {
|
|
10
|
-
super("2.3", context);
|
|
11
|
-
}
|
|
12
9
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param jp - The joinpoint to check
|
|
15
|
-
* @param typeDecl - The typedef declaration to check against
|
|
16
|
-
* @returns Returns true if the joinpoint uses the given typedef declaration, false otherwise
|
|
10
|
+
* Scope of analysis
|
|
17
11
|
*/
|
|
18
|
-
|
|
19
|
-
const jpType = getBaseType(jp);
|
|
20
|
-
return !jpType?.isBuiltin && jpType instanceof TypedefType && jpType.decl.astId === typeDecl.astId;
|
|
21
|
-
}
|
|
12
|
+
analysisType = AnalysisType.SYSTEM;
|
|
22
13
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @param typeDecl - The typedef declaration to search for in the joinpoints
|
|
26
|
-
* @returns Array of joinpoints that use the given typedef declaration
|
|
14
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
27
15
|
*/
|
|
28
|
-
|
|
29
|
-
return
|
|
16
|
+
get name() {
|
|
17
|
+
return "2.3";
|
|
30
18
|
}
|
|
31
19
|
/**
|
|
32
20
|
* Checks if the given joinpoint represents an unused type declaration
|
|
@@ -35,12 +23,12 @@ export default class Rule_2_3_UnusedTypeDecl extends MISRARule {
|
|
|
35
23
|
* @returns Returns true if the joinpoint violates the rule, false otherwise
|
|
36
24
|
*/
|
|
37
25
|
match($jp, logErrors = false) {
|
|
38
|
-
const typeDecl =
|
|
26
|
+
const typeDecl = getTypeDefDecl($jp);
|
|
39
27
|
if (typeDecl === undefined)
|
|
40
28
|
return false;
|
|
41
|
-
const isUnused =
|
|
29
|
+
const isUnused = !isTypeDeclUsed(typeDecl);
|
|
42
30
|
if (logErrors && isUnused) {
|
|
43
|
-
this.logMISRAError($jp, `Type declaration ${typeDecl.name} is declared but not used.`);
|
|
31
|
+
this.logMISRAError($jp, `Type declaration '${typeDecl.name}' is declared but not used.`);
|
|
44
32
|
}
|
|
45
33
|
return isUnused;
|
|
46
34
|
}
|
|
@@ -54,15 +42,17 @@ export default class Rule_2_3_UnusedTypeDecl extends MISRARule {
|
|
|
54
42
|
* @param $jp - Joinpoint to transform
|
|
55
43
|
* @returns Report detailing the transformation result
|
|
56
44
|
*/
|
|
57
|
-
|
|
45
|
+
apply($jp) {
|
|
58
46
|
if (!this.match($jp))
|
|
59
47
|
return new MISRATransformationReport(MISRATransformationType.NoChange);
|
|
60
|
-
if (($jp
|
|
48
|
+
if (isTagDecl($jp) && $jp.name && isTypeDeclUsed($jp)) {
|
|
61
49
|
$jp.lastChild.detach();
|
|
62
50
|
return new MISRATransformationReport(MISRATransformationType.DescendantChange);
|
|
63
51
|
}
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
else {
|
|
53
|
+
$jp.detach();
|
|
54
|
+
return new MISRATransformationReport(MISRATransformationType.Removal);
|
|
55
|
+
}
|
|
66
56
|
}
|
|
67
57
|
}
|
|
68
58
|
//# sourceMappingURL=Rule_2_3_UnusedTypeDecl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rule_2_3_UnusedTypeDecl.js","sourceRoot":"","sources":["../../../src/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Rule_2_3_UnusedTypeDecl.js","sourceRoot":"","sources":["../../../src/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,SAAS;IAC1D;;OAEG;IACM,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC;IAE5C;;OAEG;IACH,IAAa,IAAI;QACb,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAc,EAAE,YAAqB,KAAK;QAC5C,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAEzC,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC3C,IAAI,SAAS,IAAI,QAAQ,EAAE,CAAC;YACxB,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,qBAAqB,QAAQ,CAAC,IAAI,6BAA6B,CAAC,CAAA;QAC5F,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,GAAc;QAChB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;YAChB,OAAO,IAAI,yBAAyB,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;QAE3E,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,IAAI,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YACpD,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;YACvB,OAAO,IAAI,yBAAyB,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;QACnF,CAAC;aAAM,CAAC;YACJ,GAAG,CAAC,MAAM,EAAE,CAAC;YACb,OAAO,IAAI,yBAAyB,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;QAC1E,CAAC;IAEL,CAAC;CACJ"}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
|
2
2
|
import MISRARule from "../../MISRARule.js";
|
|
3
|
-
import
|
|
4
|
-
import { MISRATransformationReport } from "../../MISRA.js";
|
|
3
|
+
import { AnalysisType, MISRATransformationReport } from "../../MISRA.js";
|
|
5
4
|
/**
|
|
6
5
|
* MISRA-C Rule 2.4: A project should not contain unused tag declarations.
|
|
7
6
|
*/
|
|
8
7
|
export default class Rule_2_4_UnusedTagDecl extends MISRARule {
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Scope of analysis
|
|
10
|
+
*/
|
|
11
|
+
readonly analysisType = AnalysisType.SYSTEM;
|
|
12
|
+
/**
|
|
13
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
14
|
+
*/
|
|
15
|
+
get name(): string;
|
|
10
16
|
/**
|
|
11
17
|
* Checks if the given joinpoint is an unused tag declaration
|
|
12
|
-
* A tag is considered
|
|
18
|
+
* A tag is considered unused if it has no references in the code or if it's only used within a typedef
|
|
13
19
|
*
|
|
14
20
|
* @param $jp - Joinpoint to analyze
|
|
15
21
|
* @param logErrors - [logErrors=false] - Whether to log errors if a violation is detected
|
|
@@ -18,12 +24,12 @@ export default class Rule_2_4_UnusedTagDecl extends MISRARule {
|
|
|
18
24
|
match($jp: Joinpoint, logErrors?: boolean): boolean;
|
|
19
25
|
/**
|
|
20
26
|
* Transforms the joinpoint if it is an unused tag declaration
|
|
21
|
-
* - If the
|
|
22
|
-
* - Otherwise, the
|
|
27
|
+
* - If the joinpoint is a tag declared in a typedef, it removes the name.
|
|
28
|
+
* - Otherwise, the joinpoint is detached.
|
|
23
29
|
*
|
|
24
30
|
* @param $jp - Joinpoint to transform
|
|
25
31
|
* @returns Report detailing the transformation result
|
|
26
32
|
*/
|
|
27
|
-
|
|
33
|
+
apply($jp: Joinpoint): MISRATransformationReport;
|
|
28
34
|
}
|
|
29
35
|
//# sourceMappingURL=Rule_2_4_UnusedTagDecl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rule_2_4_UnusedTagDecl.d.ts","sourceRoot":"","sources":["../../../src/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"Rule_2_4_UnusedTagDecl.d.ts","sourceRoot":"","sources":["../../../src/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,qCAAqC,CAAC;AAC1E,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAA2B,MAAM,gBAAgB,CAAC;AAIlG;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,SAAS;IACzD;;OAEG;IACH,QAAQ,CAAC,YAAY,uBAAuB;IAE5C;;OAEG;IACH,IAAa,IAAI,IAAI,MAAM,CAE1B;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,GAAE,OAAe,GAAG,OAAO;IAwB1D;;;;;;;OAOG;IACH,KAAK,CAAC,GAAG,EAAE,SAAS,GAAG,yBAAyB;CAYnD"}
|
|
@@ -1,49 +1,63 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DeclStmt } from "@specs-feup/clava/api/Joinpoints.js";
|
|
2
2
|
import MISRARule from "../../MISRARule.js";
|
|
3
|
-
import { MISRATransformationReport, MISRATransformationType } from "../../MISRA.js";
|
|
4
|
-
import {
|
|
3
|
+
import { AnalysisType, MISRATransformationReport, MISRATransformationType } from "../../MISRA.js";
|
|
4
|
+
import { hasTypeDefDecl, isTypeDeclUsed } from "../../utils/TypeDeclUtils.js";
|
|
5
|
+
import { isTagDecl } from "../../utils/JoinpointUtils.js";
|
|
5
6
|
/**
|
|
6
7
|
* MISRA-C Rule 2.4: A project should not contain unused tag declarations.
|
|
7
8
|
*/
|
|
8
9
|
export default class Rule_2_4_UnusedTagDecl extends MISRARule {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Scope of analysis
|
|
12
|
+
*/
|
|
13
|
+
analysisType = AnalysisType.SYSTEM;
|
|
14
|
+
/**
|
|
15
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
16
|
+
*/
|
|
17
|
+
get name() {
|
|
18
|
+
return "2.4";
|
|
11
19
|
}
|
|
12
20
|
/**
|
|
13
21
|
* Checks if the given joinpoint is an unused tag declaration
|
|
14
|
-
* A tag is considered
|
|
22
|
+
* A tag is considered unused if it has no references in the code or if it's only used within a typedef
|
|
15
23
|
*
|
|
16
24
|
* @param $jp - Joinpoint to analyze
|
|
17
25
|
* @param logErrors - [logErrors=false] - Whether to log errors if a violation is detected
|
|
18
26
|
* @returns Returns true if the joinpoint violates the rule, false otherwise
|
|
19
27
|
*/
|
|
20
28
|
match($jp, logErrors = false) {
|
|
21
|
-
if (!($jp instanceof
|
|
29
|
+
if (!(isTagDecl($jp) || ($jp instanceof DeclStmt && $jp.decls.length === 1))) {
|
|
22
30
|
return false;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
}
|
|
32
|
+
if ($jp instanceof DeclStmt && !isTagDecl($jp.decls[0])) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const tagJp = $jp instanceof DeclStmt ? $jp.decls[0] : $jp;
|
|
36
|
+
const containsTypeDecl = hasTypeDefDecl(tagJp);
|
|
37
|
+
const jpName = tagJp.name;
|
|
38
|
+
if (containsTypeDecl && (jpName === undefined || jpName === null || jpName.trim().length === 0)) {
|
|
26
39
|
return false;
|
|
27
40
|
}
|
|
28
|
-
const isUnused =
|
|
41
|
+
const isUnused = !isTypeDeclUsed(tagJp);
|
|
29
42
|
if (isUnused && logErrors) {
|
|
30
|
-
this.logMISRAError(
|
|
43
|
+
this.logMISRAError(tagJp, containsTypeDecl ? `The tag '${tagJp.name}' is declared but only used in a typedef.` : `The tag '${tagJp.name}' is declared but not used.`);
|
|
31
44
|
}
|
|
32
45
|
return isUnused;
|
|
33
46
|
}
|
|
34
47
|
/**
|
|
35
48
|
* Transforms the joinpoint if it is an unused tag declaration
|
|
36
|
-
* - If the
|
|
37
|
-
* - Otherwise, the
|
|
49
|
+
* - If the joinpoint is a tag declared in a typedef, it removes the name.
|
|
50
|
+
* - Otherwise, the joinpoint is detached.
|
|
38
51
|
*
|
|
39
52
|
* @param $jp - Joinpoint to transform
|
|
40
53
|
* @returns Report detailing the transformation result
|
|
41
54
|
*/
|
|
42
|
-
|
|
55
|
+
apply($jp) {
|
|
43
56
|
if (!this.match($jp))
|
|
44
57
|
return new MISRATransformationReport(MISRATransformationType.NoChange);
|
|
45
|
-
|
|
46
|
-
|
|
58
|
+
const tagJp = $jp instanceof DeclStmt ? $jp.decls[0] : $jp;
|
|
59
|
+
if (hasTypeDefDecl(tagJp)) {
|
|
60
|
+
(tagJp).setName('');
|
|
47
61
|
return new MISRATransformationReport(MISRATransformationType.DescendantChange);
|
|
48
62
|
}
|
|
49
63
|
$jp.detach();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rule_2_4_UnusedTagDecl.js","sourceRoot":"","sources":["../../../src/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"Rule_2_4_UnusedTagDecl.js","sourceRoot":"","sources":["../../../src/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAW,MAAM,+BAA+B,CAAC;AAEnE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,SAAS;IACzD;;OAEG;IACM,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC;IAE5C;;OAEG;IACH,IAAa,IAAI;QACb,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,GAAc,EAAE,YAAqB,KAAK;QAC5C,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,YAAY,QAAQ,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3E,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,IAAI,GAAG,YAAY,QAAQ,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACtD,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,MAAM,KAAK,GAAY,GAAG,YAAY,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAY,CAAC,CAAC,CAAC,GAAG,CAAC;QAC/E,MAAM,gBAAgB,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC;QAC1B,IAAI,gBAAgB,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI,IAAK,MAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;YAC1G,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,QAAQ,IAAI,SAAS,EAAE,CAAC;YACxB,IAAI,CAAC,aAAa,CAAC,KAAK,EACpB,gBAAgB,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,IAAI,2CAA2C,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,IAAI,6BAA6B,CAAC,CAAC;QACpJ,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,GAAc;QAChB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;YAChB,OAAO,IAAI,yBAAyB,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;QAE3E,MAAM,KAAK,GAAY,GAAG,YAAY,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAY,CAAC,CAAC,CAAC,GAAc,CAAC;QAC1F,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACpB,OAAO,IAAI,yBAAyB,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;QACnF,CAAC;QACD,GAAG,CAAC,MAAM,EAAE,CAAC;QACb,OAAO,IAAI,yBAAyB,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAC1E,CAAC;CACJ"}
|
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
import { Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
|
2
2
|
import MISRARule from "../../MISRARule.js";
|
|
3
|
-
import
|
|
4
|
-
import { MISRATransformationReport } from "../../MISRA.js";
|
|
3
|
+
import { AnalysisType, MISRATransformationReport } from "../../MISRA.js";
|
|
5
4
|
/**
|
|
6
|
-
* Rule 2.6:
|
|
7
|
-
*
|
|
5
|
+
* MISRA-C Rule 2.6: A function should not contain unused label declarations.
|
|
6
|
+
*
|
|
8
7
|
*/
|
|
9
8
|
export default class Rule_2_6_UnusedLabels extends MISRARule {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Scope of analysis
|
|
11
|
+
*/
|
|
12
|
+
readonly analysisType = AnalysisType.SINGLE_TRANSLATION_UNIT;
|
|
13
|
+
/**
|
|
14
|
+
* @returns Rule identifier according to MISRA-C:2012
|
|
15
|
+
*/
|
|
16
|
+
get name(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if the given joinpoint represents a function with unused labels.
|
|
19
|
+
* A tag is considered unused if it is declared but not referenced by any goto statement.
|
|
20
|
+
*
|
|
21
|
+
* @param $jp - Joinpoint to analyze
|
|
22
|
+
* @param logErrors - [logErrors=false] - Whether to log errors if a violation is detected
|
|
23
|
+
* @returns Returns true if the joinpoint violates the rule, false otherwise
|
|
24
|
+
*/
|
|
12
25
|
match($jp: Joinpoint, logErrors?: boolean): boolean;
|
|
13
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Removes all unused labels if the provided joinpoint represents a function
|
|
28
|
+
*
|
|
29
|
+
* @param $jp - Joinpoint to transform
|
|
30
|
+
* @returns Report detailing the transformation result
|
|
31
|
+
*/
|
|
32
|
+
apply($jp: Joinpoint): MISRATransformationReport;
|
|
14
33
|
}
|
|
15
34
|
//# sourceMappingURL=Rule_2_6_UnusedLabels.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rule_2_6_UnusedLabels.d.ts","sourceRoot":"","sources":["../../../src/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Rule_2_6_UnusedLabels.d.ts","sourceRoot":"","sources":["../../../src/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAA2B,MAAM,gBAAgB,CAAC;AAGlG;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,SAAS;IACxD;;OAEG;IACH,QAAQ,CAAC,YAAY,wCAAwC;IAE7D;;OAEG;IACH,IAAa,IAAI,IAAI,MAAM,CAE1B;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,GAAE,OAAe,GAAG,OAAO;IAa1D;;;;;OAKG;IACH,KAAK,CAAC,GAAG,EAAE,SAAS,GAAG,yBAAyB;CAUnD"}
|