@specs-feup/clava-misra 1.0.0 → 1.0.1
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 +117 -0
- package/README.md +70 -15
- package/dist/MISRA.d.ts +129 -0
- package/dist/MISRA.d.ts.map +1 -0
- package/dist/MISRA.js +245 -0
- package/dist/MISRA.js.map +1 -0
- package/dist/MISRAContext.d.ts +21 -0
- package/dist/MISRAContext.d.ts.map +1 -0
- package/dist/MISRAContext.js +75 -0
- package/dist/MISRAContext.js.map +1 -0
- package/dist/MISRARule.d.ts +56 -0
- package/dist/MISRARule.d.ts.map +1 -0
- package/dist/MISRARule.js +45 -0
- package/dist/MISRARule.js.map +1 -0
- package/dist/MISRATool.d.ts +12 -0
- package/dist/MISRATool.d.ts.map +1 -0
- package/dist/MISRATool.js +84 -0
- package/dist/MISRATool.js.map +1 -0
- package/dist/foo.d.ts +2 -0
- package/dist/foo.d.ts.map +1 -0
- package/{src/foo.ts → dist/foo.js} +3 -2
- package/dist/foo.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +5 -0
- package/dist/main.js.map +1 -0
- package/dist/misra/MISRAAnalyser.d.ts +14 -0
- package/dist/misra/MISRAAnalyser.d.ts.map +1 -0
- package/{src/misra/MISRAAnalyser.ts → dist/misra/MISRAAnalyser.js} +13 -23
- package/dist/misra/MISRAAnalyser.js.map +1 -0
- package/dist/misra/MISRAPass.d.ts +27 -0
- package/dist/misra/MISRAPass.d.ts.map +1 -0
- package/dist/misra/MISRAPass.js +60 -0
- package/dist/misra/MISRAPass.js.map +1 -0
- package/dist/misra/MISRAPassResult.d.ts +13 -0
- package/dist/misra/MISRAPassResult.d.ts.map +1 -0
- package/dist/misra/MISRAPassResult.js +11 -0
- package/dist/misra/MISRAPassResult.js.map +1 -0
- package/dist/misra/MISRAReporter.d.ts +20 -0
- package/dist/misra/MISRAReporter.d.ts.map +1 -0
- package/dist/misra/MISRAReporter.js +43 -0
- package/dist/misra/MISRAReporter.js.map +1 -0
- package/dist/misra/passes/S10_EssentialTypePass.d.ts +42 -0
- package/dist/misra/passes/S10_EssentialTypePass.d.ts.map +1 -0
- package/dist/misra/passes/S10_EssentialTypePass.js +370 -0
- package/dist/misra/passes/S10_EssentialTypePass.js.map +1 -0
- package/dist/misra/passes/S12_ExpressionPass.d.ts +18 -0
- package/dist/misra/passes/S12_ExpressionPass.d.ts.map +1 -0
- package/dist/misra/passes/S12_ExpressionPass.js +72 -0
- package/dist/misra/passes/S12_ExpressionPass.js.map +1 -0
- package/dist/misra/passes/S13_SideEffectPass.d.ts +18 -0
- package/dist/misra/passes/S13_SideEffectPass.d.ts.map +1 -0
- package/dist/misra/passes/S13_SideEffectPass.js +105 -0
- package/dist/misra/passes/S13_SideEffectPass.js.map +1 -0
- package/dist/misra/passes/S15_ControlFlowPass.d.ts +19 -0
- package/dist/misra/passes/S15_ControlFlowPass.d.ts.map +1 -0
- package/dist/misra/passes/S15_ControlFlowPass.js +94 -0
- package/dist/misra/passes/S15_ControlFlowPass.js.map +1 -0
- package/dist/misra/passes/S16_SwitchStatementPass.d.ts +17 -0
- package/dist/misra/passes/S16_SwitchStatementPass.d.ts.map +1 -0
- package/dist/misra/passes/S16_SwitchStatementPass.js +152 -0
- package/dist/misra/passes/S16_SwitchStatementPass.js.map +1 -0
- package/dist/misra/passes/S17_FunctionPass.d.ts +12 -0
- package/dist/misra/passes/S17_FunctionPass.d.ts.map +1 -0
- package/dist/misra/passes/S17_FunctionPass.js +38 -0
- package/dist/misra/passes/S17_FunctionPass.js.map +1 -0
- package/dist/misra/passes/S18_PointersArraysPass.d.ts +17 -0
- package/dist/misra/passes/S18_PointersArraysPass.d.ts.map +1 -0
- package/dist/misra/passes/S18_PointersArraysPass.js +115 -0
- package/dist/misra/passes/S18_PointersArraysPass.js.map +1 -0
- package/dist/misra/passes/S19_OverlappingStoragePass.d.ts +11 -0
- package/dist/misra/passes/S19_OverlappingStoragePass.d.ts.map +1 -0
- package/dist/misra/passes/S19_OverlappingStoragePass.js +20 -0
- package/dist/misra/passes/S19_OverlappingStoragePass.js.map +1 -0
- package/dist/misra/passes/S21_StandardLibPass.d.ts +20 -0
- package/dist/misra/passes/S21_StandardLibPass.d.ts.map +1 -0
- package/dist/misra/passes/S21_StandardLibPass.js +77 -0
- package/dist/misra/passes/S21_StandardLibPass.js.map +1 -0
- package/dist/misra/passes/S3_CommentPass.d.ts +12 -0
- package/dist/misra/passes/S3_CommentPass.d.ts.map +1 -0
- package/dist/misra/passes/S3_CommentPass.js +27 -0
- package/dist/misra/passes/S3_CommentPass.js.map +1 -0
- package/dist/misra/passes/S5_IdentifierPass.d.ts +13 -0
- package/dist/misra/passes/S5_IdentifierPass.d.ts.map +1 -0
- package/dist/misra/passes/S5_IdentifierPass.js +60 -0
- package/dist/misra/passes/S5_IdentifierPass.js.map +1 -0
- package/dist/misra/passes/S6_TypePass.d.ts +11 -0
- package/dist/misra/passes/S6_TypePass.d.ts.map +1 -0
- package/dist/misra/passes/S6_TypePass.js +25 -0
- package/dist/misra/passes/S6_TypePass.js.map +1 -0
- package/dist/misra/passes/S7_LiteralsConstantsPass.d.ts +14 -0
- package/dist/misra/passes/S7_LiteralsConstantsPass.d.ts.map +1 -0
- package/dist/misra/passes/S7_LiteralsConstantsPass.js +71 -0
- package/dist/misra/passes/S7_LiteralsConstantsPass.js.map +1 -0
- package/dist/misra/passes/S8_DeclDefPass.d.ts +18 -0
- package/dist/misra/passes/S8_DeclDefPass.d.ts.map +1 -0
- package/dist/misra/passes/S8_DeclDefPass.js +127 -0
- package/dist/misra/passes/S8_DeclDefPass.js.map +1 -0
- package/dist/misra/sections/Section10_EssentialTypeModel.d.ts +33 -0
- package/dist/misra/sections/Section10_EssentialTypeModel.d.ts.map +1 -0
- package/{src/misra/sections/Section10_EssentialTypeModel.ts → dist/misra/sections/Section10_EssentialTypeModel.js} +58 -73
- package/dist/misra/sections/Section10_EssentialTypeModel.js.map +1 -0
- package/dist/misra/sections/Section11_PointerTypeConversions.d.ts +12 -0
- package/dist/misra/sections/Section11_PointerTypeConversions.d.ts.map +1 -0
- package/{src/misra/sections/Section11_PointerTypeConversions.ts → dist/misra/sections/Section11_PointerTypeConversions.js} +16 -27
- package/dist/misra/sections/Section11_PointerTypeConversions.js.map +1 -0
- package/dist/misra/sections/Section12_Expressions.d.ts +15 -0
- package/dist/misra/sections/Section12_Expressions.d.ts.map +1 -0
- package/dist/misra/sections/Section12_Expressions.js +70 -0
- package/dist/misra/sections/Section12_Expressions.js.map +1 -0
- package/dist/misra/sections/Section13_SideEffects.d.ts +14 -0
- package/dist/misra/sections/Section13_SideEffects.d.ts.map +1 -0
- package/dist/misra/sections/Section13_SideEffects.js +90 -0
- package/dist/misra/sections/Section13_SideEffects.js.map +1 -0
- package/dist/misra/sections/Section14_ControlStmtExprs.d.ts +8 -0
- package/dist/misra/sections/Section14_ControlStmtExprs.d.ts.map +1 -0
- package/{src/misra/sections/Section14_ControlStmtExprs.ts → dist/misra/sections/Section14_ControlStmtExprs.js} +8 -10
- package/dist/misra/sections/Section14_ControlStmtExprs.js.map +1 -0
- package/dist/misra/sections/Section15_ControlFlow.d.ts +14 -0
- package/dist/misra/sections/Section15_ControlFlow.d.ts.map +1 -0
- package/dist/misra/sections/Section15_ControlFlow.js +97 -0
- package/dist/misra/sections/Section15_ControlFlow.js.map +1 -0
- package/dist/misra/sections/Section16_SwitchStatements.d.ts +13 -0
- package/dist/misra/sections/Section16_SwitchStatements.d.ts.map +1 -0
- package/{src/misra/sections/Section16_SwitchStatements.ts → dist/misra/sections/Section16_SwitchStatements.js} +49 -74
- package/dist/misra/sections/Section16_SwitchStatements.js.map +1 -0
- package/dist/misra/sections/Section17_Functions.d.ts +9 -0
- package/dist/misra/sections/Section17_Functions.d.ts.map +1 -0
- package/{src/misra/sections/Section17_Functions.ts → dist/misra/sections/Section17_Functions.js} +10 -13
- package/dist/misra/sections/Section17_Functions.js.map +1 -0
- package/dist/misra/sections/Section18_PointersAndArrays.d.ts +13 -0
- package/dist/misra/sections/Section18_PointersAndArrays.d.ts.map +1 -0
- package/{src/misra/sections/Section18_PointersAndArrays.ts → dist/misra/sections/Section18_PointersAndArrays.js} +36 -40
- package/dist/misra/sections/Section18_PointersAndArrays.js.map +1 -0
- package/dist/misra/sections/Section19_OverlappingStorage.d.ts +8 -0
- package/dist/misra/sections/Section19_OverlappingStorage.d.ts.map +1 -0
- package/dist/misra/sections/Section19_OverlappingStorage.js +16 -0
- package/dist/misra/sections/Section19_OverlappingStorage.js.map +1 -0
- package/dist/misra/sections/Section20_PreprocessingDirectives.d.ts +8 -0
- package/dist/misra/sections/Section20_PreprocessingDirectives.d.ts.map +1 -0
- package/{src/misra/sections/Section20_PreprocessingDirectives.ts → dist/misra/sections/Section20_PreprocessingDirectives.js} +7 -9
- package/dist/misra/sections/Section20_PreprocessingDirectives.js.map +1 -0
- package/dist/misra/sections/Section21_StandardLibraries.d.ts +17 -0
- package/dist/misra/sections/Section21_StandardLibraries.d.ts.map +1 -0
- package/dist/misra/sections/Section21_StandardLibraries.js +54 -0
- package/dist/misra/sections/Section21_StandardLibraries.js.map +1 -0
- package/dist/misra/sections/Section2_UnusedCode.d.ts +9 -0
- package/dist/misra/sections/Section2_UnusedCode.d.ts.map +1 -0
- package/{src/misra/sections/Section2_UnusedCode.ts → dist/misra/sections/Section2_UnusedCode.js} +11 -16
- package/dist/misra/sections/Section2_UnusedCode.js.map +1 -0
- package/dist/misra/sections/Section3_Comments.d.ts +9 -0
- package/dist/misra/sections/Section3_Comments.d.ts.map +1 -0
- package/{src/misra/sections/Section3_Comments.ts → dist/misra/sections/Section3_Comments.js} +7 -10
- package/dist/misra/sections/Section3_Comments.js.map +1 -0
- package/dist/misra/sections/Section5_Identifiers.d.ts +12 -0
- package/dist/misra/sections/Section5_Identifiers.d.ts.map +1 -0
- package/dist/misra/sections/Section5_Identifiers.js +139 -0
- package/dist/misra/sections/Section5_Identifiers.js.map +1 -0
- package/dist/misra/sections/Section6_Types.d.ts +8 -0
- package/dist/misra/sections/Section6_Types.d.ts.map +1 -0
- package/dist/misra/sections/Section6_Types.js +23 -0
- package/dist/misra/sections/Section6_Types.js.map +1 -0
- package/dist/misra/sections/Section7_LiteralsConstants.d.ts +11 -0
- package/dist/misra/sections/Section7_LiteralsConstants.d.ts.map +1 -0
- package/{src/misra/sections/Section7_LiteralsConstants.ts → dist/misra/sections/Section7_LiteralsConstants.js} +18 -25
- package/dist/misra/sections/Section7_LiteralsConstants.js.map +1 -0
- package/dist/misra/sections/Section8_DeclarationsDefinitions.d.ts +15 -0
- package/dist/misra/sections/Section8_DeclarationsDefinitions.d.ts.map +1 -0
- package/{src/misra/sections/Section8_DeclarationsDefinitions.ts → dist/misra/sections/Section8_DeclarationsDefinitions.js} +18 -33
- package/dist/misra/sections/Section8_DeclarationsDefinitions.js.map +1 -0
- package/dist/misra/tests/utils.d.ts +10 -0
- package/dist/misra/tests/utils.d.ts.map +1 -0
- package/dist/misra/tests/utils.js +33 -0
- package/dist/misra/tests/utils.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.d.ts +15 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.d.ts.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.js +33 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.d.ts +16 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.d.ts.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.js +60 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.d.ts +19 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.d.ts.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.js +42 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.d.ts +43 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.d.ts.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.js +103 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.d.ts +26 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.d.ts.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.js +49 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.js.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.d.ts +26 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.d.ts.map +1 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.js +49 -0
- package/dist/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.js.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.d.ts +31 -0
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.d.ts.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.js +71 -0
- package/dist/rules/Section17_Functions/Rule_17_4_NonVoidReturn.js.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.d.ts +27 -0
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.d.ts.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.js +58 -0
- package/dist/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.js.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.d.ts +28 -0
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.d.ts.map +1 -0
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.js +44 -0
- package/dist/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.js.map +1 -0
- package/dist/rules/Section20-PreprocessingDirectives/Rule_20_2_InvalidHeaderFileName.d.ts +55 -0
- package/dist/rules/Section20-PreprocessingDirectives/Rule_20_2_InvalidHeaderFileName.d.ts.map +1 -0
- package/dist/rules/Section20-PreprocessingDirectives/Rule_20_2_InvalidHeaderFileName.js +108 -0
- package/dist/rules/Section20-PreprocessingDirectives/Rule_20_2_InvalidHeaderFileName.js.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.d.ts +43 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.d.ts.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.js +68 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.js.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.d.ts +29 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.d.ts.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.js +53 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.js.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.d.ts +15 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.d.ts.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.js +35 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.js.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.d.ts +13 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.d.ts.map +1 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.js +53 -0
- package/dist/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.js.map +1 -0
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.d.ts +13 -0
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.d.ts.map +1 -0
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.js +32 -0
- package/dist/rules/Section3_Comments/Rule_3_1_CommentSequences.js.map +1 -0
- package/dist/rules/Section3_Comments/Rule_3_2_LineSplicing.d.ts +10 -0
- package/dist/rules/Section3_Comments/Rule_3_2_LineSplicing.d.ts.map +1 -0
- package/dist/rules/Section3_Comments/Rule_3_2_LineSplicing.js +26 -0
- package/dist/rules/Section3_Comments/Rule_3_2_LineSplicing.js.map +1 -0
- package/dist/rules/index.d.ts +20 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +38 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/tests/Section17_Functions/misra_config.json +10 -0
- package/dist/tests/utils.d.ts +10 -0
- package/dist/tests/utils.d.ts.map +1 -0
- package/dist/tests/utils.js +29 -0
- package/dist/tests/utils.js.map +1 -0
- package/dist/utils/utils.d.ts +102 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +202 -0
- package/dist/utils/utils.js.map +1 -0
- package/jest.config.js +6 -6
- package/package.json +40 -8
- package/src/MISRA.ts +266 -0
- package/src/MISRAContext.ts +91 -0
- package/src/MISRARule.ts +77 -0
- package/src/MISRATool.ts +96 -0
- package/src/main.ts +4 -33
- package/src/misra-old/MISRAAnalyser.ts +60 -0
- package/src/misra-old/MISRAAnalyserResult.ts +16 -0
- package/src/misra-old/sections/Section10_EssentialTypeModel.ts +377 -0
- package/src/misra-old/sections/Section11_PointerTypeConversions.ts +104 -0
- package/src/{misra → misra-old}/sections/Section12_Expressions.ts +7 -7
- package/src/{misra → misra-old}/sections/Section13_SideEffects.ts +15 -15
- package/src/misra-old/sections/Section14_ControlStmtExprs.ts +27 -0
- package/src/{misra → misra-old}/sections/Section15_ControlFlow.ts +10 -10
- package/src/misra-old/sections/Section18_PointersAndArrays.ts +108 -0
- package/src/{misra → misra-old}/sections/Section19_OverlappingStorage.ts +4 -4
- package/src/misra-old/sections/Section20_PreprocessingDirectives.ts +22 -0
- package/src/misra-old/sections/Section21_StandardLibraries.ts +99 -0
- package/src/{misra → misra-old}/sections/Section5_Identifiers.ts +16 -15
- package/src/{misra → misra-old}/sections/Section6_Types.ts +4 -4
- package/src/misra-old/sections/Section7_LiteralsConstants.ts +76 -0
- package/src/misra-old/sections/Section8_DeclarationsDefinitions.ts +133 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.ts +40 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.ts +69 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.ts +46 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.ts +113 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.ts +57 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.ts +56 -0
- package/src/rules/Section17_Functions/Rule_17_4_NonVoidReturn.ts +78 -0
- package/src/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.ts +68 -0
- package/src/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.ts +47 -0
- package/src/rules/Section20-PreprocessingDirectives/Rule_20_2_InvalidHeaderFileName.ts +120 -0
- package/src/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.ts +75 -0
- package/src/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.ts +60 -0
- package/src/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.ts +46 -0
- package/src/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.ts +65 -0
- package/src/rules/Section3_Comments/Rule_3_1_CommentSequences.ts +41 -0
- package/src/rules/Section3_Comments/Rule_3_2_LineSplicing.ts +36 -0
- package/src/rules/index.ts +40 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_2_TopLevelSwitch.test.ts +55 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.test.ts +70 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.test.ts +128 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.test.ts +132 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.test.ts +146 -0
- package/src/tests/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.test.ts +102 -0
- package/src/tests/Section17_Functions/Rule_17_4_NonVoidReturn.test.ts +85 -0
- package/src/tests/Section17_Functions/Rule_17_4_NonVoidReturn_MissingConfig.test.ts +77 -0
- package/src/tests/Section17_Functions/Rule_17_6_StaticArraySizeParam.test.ts +36 -0
- package/src/tests/Section17_Functions/Rule_17_7_UnusedReturnValue.test.ts +44 -0
- package/src/tests/Section17_Functions/misra_config.json +10 -0
- package/src/tests/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.test.ts +175 -0
- package/src/tests/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.test.ts +219 -0
- package/src/tests/Section2_UnusedCode/Rule_2_6_UnusedLabels.test.ts +49 -0
- package/src/tests/Section2_UnusedCode/Rule_2_7_UnusedParameters.test.ts +55 -0
- package/src/tests/Section3_Comments/Rule_3_1_CommentSequences.test.ts +37 -0
- package/src/tests/utils.ts +39 -0
- package/src/utils/utils.ts +221 -0
- package/tsconfig.json +4 -3
- package/typedoc.config.js +1 -1
- package/CxxSources/lib.cpp +0 -3
- package/CxxSources/lib.h +0 -8
- package/CxxSources/main.cpp +0 -40
- package/TODO.md +0 -1
- package/consumer_order.txt +0 -2
- package/enum_integer_type.txt +0 -0
- package/is_temporary.txt +0 -0
- package/omp.txt +0 -0
- package/src/misra/passes/S16_SwitchStatementPass.ts +0 -168
- package/src/misra/passes/S3_CommentPass.ts +0 -40
- package/src/misra/sections/Section21_StandardLibraries.ts +0 -65
- package/src/misra/tests/S10_EssentialTypes.test.ts +0 -253
- package/src/misra/tests/S12_Expressions.test.ts +0 -43
- package/src/misra/tests/S13_SideEffects.test.ts +0 -77
- package/src/misra/tests/S15_ControlFlow.test.ts +0 -144
- package/src/misra/tests/S16_SwitchStatements.test.ts +0 -164
- package/src/misra/tests/S17_Functions.test.ts +0 -46
- package/src/misra/tests/S18_PointersArrays.test.ts +0 -167
- package/src/misra/tests/S19_OverlappingStorage.test.ts +0 -38
- package/src/misra/tests/S3_Comments.test.ts +0 -36
- package/src/misra/tests/S6_Types.test.ts +0 -36
- package/src/misra/tests/S7_LiteralsConstants.test.ts +0 -48
- package/src/misra/tests/utils.ts +0 -47
- package/types_with_templates.txt +0 -0
- /package/src/{misra → misra-old}/MISRAPass.ts +0 -0
- /package/src/{misra → misra-old}/MISRAPassResult.ts +0 -0
- /package/src/{misra → misra-old}/MISRAReporter.ts +0 -0
- /package/src/{misra → misra-old}/passes/S10_EssentialTypePass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S12_ExpressionPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S13_SideEffectPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S15_ControlFlowPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S17_FunctionPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S18_PointersArraysPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S19_OverlappingStoragePass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S21_StandardLibPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S5_IdentifierPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S6_TypePass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S7_LiteralsConstantsPass.ts +0 -0
- /package/src/{misra → misra-old}/passes/S8_DeclDefPass.ts +0 -0
@@ -0,0 +1,128 @@
|
|
1
|
+
import { FileJp, If, Switch } from "@specs-feup/clava/api/Joinpoints.js";
|
2
|
+
import { countErrorsAfterCorrection, countMISRAErrors, registerSourceCode, TestFile } from "../utils.js";
|
3
|
+
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
4
|
+
|
5
|
+
const passingCode =
|
6
|
+
`void foo16_4_1( void )
|
7
|
+
{
|
8
|
+
int x;
|
9
|
+
switch ( x )
|
10
|
+
{
|
11
|
+
case 0:
|
12
|
+
++x;
|
13
|
+
break;
|
14
|
+
case 1:
|
15
|
+
case 2:
|
16
|
+
break;
|
17
|
+
default:
|
18
|
+
break;
|
19
|
+
}
|
20
|
+
|
21
|
+
switch ( x )
|
22
|
+
{
|
23
|
+
default:
|
24
|
+
break;
|
25
|
+
case 0:
|
26
|
+
++x;
|
27
|
+
break;
|
28
|
+
case 1:
|
29
|
+
case 2:
|
30
|
+
break;
|
31
|
+
}
|
32
|
+
}`;
|
33
|
+
|
34
|
+
const failingCode1 =
|
35
|
+
`void foo16_4_3( void )
|
36
|
+
{
|
37
|
+
int x;
|
38
|
+
switch ( x )
|
39
|
+
{
|
40
|
+
case 0:
|
41
|
+
++x;
|
42
|
+
break;
|
43
|
+
case 1:
|
44
|
+
case 2:
|
45
|
+
x--;
|
46
|
+
break;
|
47
|
+
}
|
48
|
+
}`;
|
49
|
+
|
50
|
+
// 4 erros: two of them are related to having boolean switch condition
|
51
|
+
const failingCode2 =
|
52
|
+
`void foo16_4_4( void )
|
53
|
+
{
|
54
|
+
int x, a = 14;
|
55
|
+
switch ( x == 4) /* Default will not be introduced, as it will be converted by the other rule */
|
56
|
+
{
|
57
|
+
case 1:
|
58
|
+
++x;
|
59
|
+
break;
|
60
|
+
case 0:
|
61
|
+
break;
|
62
|
+
}
|
63
|
+
|
64
|
+
switch ( x == 4)
|
65
|
+
{
|
66
|
+
case 0:
|
67
|
+
++x;
|
68
|
+
if (a > 4) {
|
69
|
+
x = 7;
|
70
|
+
break;
|
71
|
+
}
|
72
|
+
break;
|
73
|
+
case 1:
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
}`;
|
77
|
+
|
78
|
+
// 4 errors: two of them are related to having less than two clauses
|
79
|
+
const failingCode3 =
|
80
|
+
`void foo16_4_5( void )
|
81
|
+
{
|
82
|
+
int x, a = 14;
|
83
|
+
switch (x) { /* Default will not be introduced, as it Will be converted by the other rule*/
|
84
|
+
case 1:
|
85
|
+
++x;
|
86
|
+
break;
|
87
|
+
}
|
88
|
+
|
89
|
+
switch ( x ) {
|
90
|
+
case 0:
|
91
|
+
++x;
|
92
|
+
if (a > 4) {
|
93
|
+
x = 7;
|
94
|
+
break;
|
95
|
+
}
|
96
|
+
break;
|
97
|
+
}
|
98
|
+
}`;
|
99
|
+
|
100
|
+
const files: TestFile[] = [
|
101
|
+
{ name: "bad1.c", code: failingCode1 },
|
102
|
+
{ name: "bad2.c", code: failingCode2 },
|
103
|
+
{ name: "bad3.c", code: failingCode3 },
|
104
|
+
{ name: "good.c", code: passingCode },
|
105
|
+
];
|
106
|
+
|
107
|
+
describe("Rule 16.4", () => {
|
108
|
+
registerSourceCode(files);
|
109
|
+
|
110
|
+
it("should detect errors in bad.c", () => {
|
111
|
+
expect(countMISRAErrors()).toBe(9);
|
112
|
+
|
113
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "bad1.c"}).first()!)).toBe(1);
|
114
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "bad2.c"}).first()!)).toBe(4);
|
115
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "bad3.c"}).first()!)).toBe(4);
|
116
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "good.c"}).first()!)).toBe(0);
|
117
|
+
});
|
118
|
+
|
119
|
+
it("should correct errors in bad.c", () => {
|
120
|
+
expect(countErrorsAfterCorrection()).toBe(1);
|
121
|
+
|
122
|
+
const bad2File = Query.search(FileJp, {name: "bad2.c"}).first()!;
|
123
|
+
expect(Query.searchFrom(bad2File, Switch).get().length).toBe(1);
|
124
|
+
|
125
|
+
const bad3File = Query.search(FileJp, {name: "bad3.c"}).first()!;
|
126
|
+
expect(Query.searchFrom(bad3File, Switch).get().length).toBe(1);
|
127
|
+
});
|
128
|
+
});
|
@@ -0,0 +1,132 @@
|
|
1
|
+
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
2
|
+
import { countErrorsAfterCorrection, countMISRAErrors, registerSourceCode, TestFile } from "../utils.js";
|
3
|
+
import { FileJp } from "@specs-feup/clava/api/Joinpoints.js";
|
4
|
+
|
5
|
+
const passingCode1 =
|
6
|
+
`void foo16_5_1( void )
|
7
|
+
{
|
8
|
+
int x;
|
9
|
+
switch ( x ) {
|
10
|
+
case 0:
|
11
|
+
++x;
|
12
|
+
break;
|
13
|
+
case 1:
|
14
|
+
case 2:
|
15
|
+
break;
|
16
|
+
default:
|
17
|
+
break;
|
18
|
+
}
|
19
|
+
|
20
|
+
switch ( x ) {
|
21
|
+
default:
|
22
|
+
break;
|
23
|
+
case 0:
|
24
|
+
++x;
|
25
|
+
break;
|
26
|
+
case 1:
|
27
|
+
case 2:
|
28
|
+
break;
|
29
|
+
}
|
30
|
+
}`;
|
31
|
+
|
32
|
+
const failingCode1 =
|
33
|
+
`void foo16_5_3( void )
|
34
|
+
{
|
35
|
+
int x;
|
36
|
+
switch ( x ) {
|
37
|
+
case 0:
|
38
|
+
++x;
|
39
|
+
break;
|
40
|
+
default:
|
41
|
+
break;
|
42
|
+
case 1:
|
43
|
+
case 2:
|
44
|
+
break;
|
45
|
+
}
|
46
|
+
}`;
|
47
|
+
|
48
|
+
const failingCode2 =
|
49
|
+
`void foo16_5_4( void )
|
50
|
+
{
|
51
|
+
int x;
|
52
|
+
switch ( x ) {
|
53
|
+
case 0:
|
54
|
+
++x;
|
55
|
+
break;
|
56
|
+
case 1:
|
57
|
+
case 2:
|
58
|
+
break;
|
59
|
+
case 5:
|
60
|
+
case 10:
|
61
|
+
default:
|
62
|
+
case 6:
|
63
|
+
case 8:
|
64
|
+
break;
|
65
|
+
}
|
66
|
+
}`;
|
67
|
+
|
68
|
+
const failingCode3 =
|
69
|
+
`void foo16_5_5( void )
|
70
|
+
{
|
71
|
+
int x;
|
72
|
+
switch ( x ) {
|
73
|
+
case 0:
|
74
|
+
++x;
|
75
|
+
break;
|
76
|
+
case 1:
|
77
|
+
case 2:
|
78
|
+
break;
|
79
|
+
case 5:
|
80
|
+
case 10:
|
81
|
+
default:
|
82
|
+
case 6:
|
83
|
+
case 8:
|
84
|
+
break;
|
85
|
+
case 7:
|
86
|
+
break;
|
87
|
+
}
|
88
|
+
}`;
|
89
|
+
|
90
|
+
const failingCode4 =
|
91
|
+
`void foo16_5_6( void )
|
92
|
+
{
|
93
|
+
int x;
|
94
|
+
switch ( x ) {
|
95
|
+
case 0:
|
96
|
+
++x;
|
97
|
+
break;
|
98
|
+
case 5:
|
99
|
+
case 6:
|
100
|
+
default:
|
101
|
+
break;
|
102
|
+
case 1:
|
103
|
+
case 2:
|
104
|
+
break;
|
105
|
+
}
|
106
|
+
}`;
|
107
|
+
|
108
|
+
const files: TestFile[] = [
|
109
|
+
{ name: "bad1.c", code: failingCode1 },
|
110
|
+
{ name: "bad2.c", code: failingCode2 },
|
111
|
+
{ name: "bad3.c", code: failingCode3 },
|
112
|
+
{ name: "bad4.c", code: failingCode4 },
|
113
|
+
{ name: "good.c", code: passingCode1 },
|
114
|
+
];
|
115
|
+
|
116
|
+
describe("Rule 16.5", () => {
|
117
|
+
registerSourceCode(files);
|
118
|
+
|
119
|
+
it("should detect errors in bad.c", () => {
|
120
|
+
expect(countMISRAErrors()).toBe(4);
|
121
|
+
|
122
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "bad1.c"}).first()!)).toBe(1);
|
123
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "bad2.c"}).first()!)).toBe(1);
|
124
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "bad3.c"}).first()!)).toBe(1);
|
125
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "bad4.c"}).first()!)).toBe(1);
|
126
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "good.c"}).first()!)).toBe(0);
|
127
|
+
});
|
128
|
+
|
129
|
+
it("should correct errors in bad.c", () => {
|
130
|
+
expect(countErrorsAfterCorrection()).toBe(0);
|
131
|
+
});
|
132
|
+
});
|
@@ -0,0 +1,146 @@
|
|
1
|
+
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
2
|
+
import { countErrorsAfterCorrection, countMISRAErrors, registerSourceCode, TestFile } from "../utils.js";
|
3
|
+
import { FileJp, FunctionJp, If, Switch } from "@specs-feup/clava/api/Joinpoints.js";
|
4
|
+
|
5
|
+
const passingCode =
|
6
|
+
`void foo16_6_1( void )
|
7
|
+
{
|
8
|
+
int x, a, b;
|
9
|
+
|
10
|
+
switch ( x )
|
11
|
+
{
|
12
|
+
case 0:
|
13
|
+
a = 10;
|
14
|
+
break;
|
15
|
+
default:
|
16
|
+
break;
|
17
|
+
}
|
18
|
+
|
19
|
+
switch ( x )
|
20
|
+
{
|
21
|
+
default:
|
22
|
+
a = 10;
|
23
|
+
break;
|
24
|
+
case 1:
|
25
|
+
case 2:
|
26
|
+
break;
|
27
|
+
}
|
28
|
+
}`;
|
29
|
+
|
30
|
+
const failingCode1 =
|
31
|
+
`int foo16_6_2( void )
|
32
|
+
{
|
33
|
+
int x = 1;
|
34
|
+
switch ( x )
|
35
|
+
{
|
36
|
+
default: /* Non-compliant*/
|
37
|
+
break;
|
38
|
+
}
|
39
|
+
|
40
|
+
switch ( x )
|
41
|
+
{
|
42
|
+
case 1: /* Non-compliant*/
|
43
|
+
default:
|
44
|
+
break;
|
45
|
+
}
|
46
|
+
return x;
|
47
|
+
}`;
|
48
|
+
|
49
|
+
const failingCode2 =
|
50
|
+
`int foo16_6_3( void )
|
51
|
+
{
|
52
|
+
int x = 10, a, b;
|
53
|
+
|
54
|
+
switch ( x )
|
55
|
+
{
|
56
|
+
case 1:
|
57
|
+
case 3:
|
58
|
+
default:
|
59
|
+
a = 10;
|
60
|
+
b = a * 2;
|
61
|
+
break;
|
62
|
+
}
|
63
|
+
return x;
|
64
|
+
}`;
|
65
|
+
|
66
|
+
// 2 erros: one is related to not having a default case
|
67
|
+
const failingCode3 =
|
68
|
+
`int foo16_6_4( void )
|
69
|
+
{
|
70
|
+
int x = 10, a, b;
|
71
|
+
|
72
|
+
switch ( x )
|
73
|
+
{
|
74
|
+
case 1: /* Non-compliant*/
|
75
|
+
case 3:
|
76
|
+
a = 10;
|
77
|
+
b = a * 2;
|
78
|
+
break;
|
79
|
+
}
|
80
|
+
return x;
|
81
|
+
}`;
|
82
|
+
|
83
|
+
const failingCode4 =
|
84
|
+
`int foo16_6_5( void )
|
85
|
+
{
|
86
|
+
int x = 10, a, b;
|
87
|
+
|
88
|
+
switch ( x )
|
89
|
+
{
|
90
|
+
case 1: /* Non-compliant*/
|
91
|
+
case 3:
|
92
|
+
default:
|
93
|
+
a = 10;
|
94
|
+
b = a * 2;
|
95
|
+
if (a + b > 14) {
|
96
|
+
a = 0;
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
b = 15;
|
100
|
+
break;
|
101
|
+
}
|
102
|
+
return x;
|
103
|
+
}`;
|
104
|
+
|
105
|
+
const files: TestFile[] = [
|
106
|
+
{ name: "bad1.c", code: failingCode1 },
|
107
|
+
{ name: "bad2.c", code: failingCode2 },
|
108
|
+
{ name: "bad3.c", code: failingCode3 },
|
109
|
+
{ name: "bad4.c", code: failingCode4 },
|
110
|
+
{ name: "good.c", code: passingCode }
|
111
|
+
];
|
112
|
+
|
113
|
+
describe("Rule 16.6", () => {
|
114
|
+
registerSourceCode(files);
|
115
|
+
|
116
|
+
it("should detect errors in non-compliant files", () => {
|
117
|
+
expect(countMISRAErrors()).toBe(6);
|
118
|
+
|
119
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "bad1.c"}).first()!)).toBe(2);
|
120
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "bad2.c"}).first()!)).toBe(1);
|
121
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "bad3.c"}).first()!)).toBe(2);
|
122
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "bad4.c"}).first()!)).toBe(1);
|
123
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "good.c"}).first()!)).toBe(0);
|
124
|
+
});
|
125
|
+
|
126
|
+
it("should correct errors in non-compliant files", () => {
|
127
|
+
expect(countErrorsAfterCorrection()).toBe(1);
|
128
|
+
|
129
|
+
const badFile = Query.search(FileJp, {name: "bad1.c"}).first()!;
|
130
|
+
expect(Query.searchFrom(badFile, Switch).get().length).toBe(0);
|
131
|
+
expect(Query.searchFrom(badFile, If).get().length).toBe(0);
|
132
|
+
expect(Query.searchFrom(badFile, FunctionJp).first()?.body.children.length).toBe(2);
|
133
|
+
|
134
|
+
const bad2File = Query.search(FileJp, {name: "bad2.c"}).first()!;
|
135
|
+
expect(Query.searchFrom(bad2File, Switch).get().length).toBe(0);
|
136
|
+
expect(Query.searchFrom(bad2File, If).get().length).toBe(0);
|
137
|
+
expect(Query.searchFrom(bad2File, FunctionJp).first()?.body.children.length).toBe(4);
|
138
|
+
|
139
|
+
const bad3File = Query.search(FileJp, {name: "bad3.c"}).first()!;
|
140
|
+
expect(Query.searchFrom(bad3File, Switch).get().length).toBe(0);
|
141
|
+
expect(Query.searchFrom(bad3File, If).get().length).toBe(1);
|
142
|
+
|
143
|
+
const bad4File = Query.search(FileJp, {name: "bad4.c"}).first()!;
|
144
|
+
expect(Query.searchFrom(bad4File, Switch).get().length).toBe(1);
|
145
|
+
});
|
146
|
+
});
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
2
|
+
import { countErrorsAfterCorrection, countMISRAErrors, registerSourceCode, TestFile } from "../utils.js";
|
3
|
+
import { FileJp } from "@specs-feup/clava/api/Joinpoints.js";
|
4
|
+
|
5
|
+
const passingCode =
|
6
|
+
`void foo16_7_1( int num )
|
7
|
+
{
|
8
|
+
switch (num) {
|
9
|
+
case 0:
|
10
|
+
num *= 2;
|
11
|
+
break;
|
12
|
+
case 1:
|
13
|
+
num += 5;
|
14
|
+
break;
|
15
|
+
default:
|
16
|
+
num -= 3;
|
17
|
+
break;
|
18
|
+
}
|
19
|
+
}`;
|
20
|
+
|
21
|
+
const failingCode1 =
|
22
|
+
`
|
23
|
+
#include <stdbool.h>
|
24
|
+
|
25
|
+
void foo16_6_2( int num )
|
26
|
+
{
|
27
|
+
int a = 7;
|
28
|
+
switch (num % 3) {
|
29
|
+
case 0:
|
30
|
+
a *= 2;
|
31
|
+
break;
|
32
|
+
case 1:
|
33
|
+
a += 5;
|
34
|
+
break;
|
35
|
+
default:
|
36
|
+
a -= 3;
|
37
|
+
break;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
void foo16_6_3( bool flag )
|
42
|
+
{
|
43
|
+
int a = 7;
|
44
|
+
switch (flag) {
|
45
|
+
case 1:
|
46
|
+
a *= 2;
|
47
|
+
break;
|
48
|
+
case 0:
|
49
|
+
a += 5;
|
50
|
+
break;
|
51
|
+
default:
|
52
|
+
a -= 3;
|
53
|
+
break;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
`;
|
57
|
+
|
58
|
+
const failingCode2 =
|
59
|
+
`
|
60
|
+
#include <stdbool.h>
|
61
|
+
|
62
|
+
void foo16_6_4( bool flag )
|
63
|
+
{
|
64
|
+
int a = 7, b = 10;
|
65
|
+
switch (flag) {
|
66
|
+
case 1:
|
67
|
+
a *= 2;
|
68
|
+
if (a * a > 10) {
|
69
|
+
b = 12;
|
70
|
+
break;
|
71
|
+
}
|
72
|
+
break;
|
73
|
+
case 0:
|
74
|
+
a += 5;
|
75
|
+
break;
|
76
|
+
default:
|
77
|
+
a -= 3;
|
78
|
+
break;
|
79
|
+
}
|
80
|
+
}`;
|
81
|
+
|
82
|
+
const files: TestFile[] = [
|
83
|
+
{ name: "bad1.c", code: failingCode1 },
|
84
|
+
{ name: "bad2.c", code: failingCode2 },
|
85
|
+
{ name: "good.c", code: passingCode }
|
86
|
+
];
|
87
|
+
|
88
|
+
describe("Rule 16.7", () => {
|
89
|
+
registerSourceCode(files);
|
90
|
+
|
91
|
+
it("should detect errors in bad.c", () => {
|
92
|
+
expect(countMISRAErrors()).toBe(3);
|
93
|
+
|
94
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "bad1.c"}).first()!)).toBe(2);
|
95
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "bad2.c"}).first()!)).toBe(1);
|
96
|
+
expect(countMISRAErrors(Query.search(FileJp, {name: "good.c"}).first()!)).toBe(0);
|
97
|
+
});
|
98
|
+
|
99
|
+
it("should correct errors in bad.c", () => {
|
100
|
+
expect(countErrorsAfterCorrection()).toBe(1);
|
101
|
+
});
|
102
|
+
});
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
2
|
+
import { countErrorsAfterCorrection, countMISRAErrors, registerSourceCode, TestFile } from "../utils.js";
|
3
|
+
import { FileJp } from "@specs-feup/clava/api/Joinpoints.js";
|
4
|
+
import path from "path";
|
5
|
+
import { fileURLToPath } from "url";
|
6
|
+
|
7
|
+
const passingCode = `
|
8
|
+
unsigned int test_17_4_1() {
|
9
|
+
return 0;
|
10
|
+
}`;
|
11
|
+
|
12
|
+
const failingCode = `
|
13
|
+
unsigned int test_17_4_2() {
|
14
|
+
|
15
|
+
}`;
|
16
|
+
|
17
|
+
const failingCode2 = `
|
18
|
+
float test_17_4_3() {
|
19
|
+
|
20
|
+
}`;
|
21
|
+
|
22
|
+
const failingCode3 = `
|
23
|
+
enum Status {
|
24
|
+
FAIL,
|
25
|
+
SUCCESS
|
26
|
+
};
|
27
|
+
|
28
|
+
typedef enum {
|
29
|
+
RED,
|
30
|
+
GREEN,
|
31
|
+
} Color;
|
32
|
+
|
33
|
+
typedef unsigned int my_int_type;
|
34
|
+
|
35
|
+
// Non-compliant
|
36
|
+
enum Status test_17_4_3() {
|
37
|
+
|
38
|
+
}
|
39
|
+
|
40
|
+
// Non-compliant
|
41
|
+
Color test_17_4_4() {
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
// Non-compliant
|
46
|
+
my_int_type test_17_4_5() {
|
47
|
+
|
48
|
+
}
|
49
|
+
|
50
|
+
/*
|
51
|
+
Non-compliant after correction:
|
52
|
+
Config file do not specify the default value for 'double' type
|
53
|
+
*/
|
54
|
+
double test_17_4_6() {
|
55
|
+
}
|
56
|
+
`;
|
57
|
+
|
58
|
+
const files: TestFile[] = [
|
59
|
+
{ name: "bad1.c", code: failingCode },
|
60
|
+
{ name: "bad2.c", code: failingCode2 },
|
61
|
+
{ name: "bad3.c", code: failingCode3 },
|
62
|
+
{ name: "good.c", code: passingCode },
|
63
|
+
];
|
64
|
+
|
65
|
+
describe("Rule 17.4", () => {
|
66
|
+
registerSourceCode(files);
|
67
|
+
|
68
|
+
it("should detect errors", () => {
|
69
|
+
expect(countMISRAErrors()).toBe(6);
|
70
|
+
expect(countMISRAErrors(Query.search(FileJp, { name: "bad1.c" }).first()!)).toBe(1);
|
71
|
+
expect(countMISRAErrors(Query.search(FileJp, { name: "bad2.c" }).first()!)).toBe(1);
|
72
|
+
expect(countMISRAErrors(Query.search(FileJp, { name: "bad3.c" }).first()!)).toBe(4);
|
73
|
+
expect(countMISRAErrors(Query.search(FileJp, { name: "good.c" }).first()!)).toBe(0);
|
74
|
+
});
|
75
|
+
|
76
|
+
it("should correct errors", () => {
|
77
|
+
const __filename = fileURLToPath(import.meta.url);
|
78
|
+
const __dirname = path.dirname(__filename);
|
79
|
+
|
80
|
+
const configFilename = "misra_config.json";
|
81
|
+
const configFilePath = path.join(__dirname, configFilename);
|
82
|
+
|
83
|
+
expect(countErrorsAfterCorrection(configFilePath)).toBe(1);
|
84
|
+
});
|
85
|
+
});
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
2
|
+
import { countErrorsAfterCorrection, countMISRAErrors, registerSourceCode, TestFile } from "../utils.js";
|
3
|
+
import { FileJp } from "@specs-feup/clava/api/Joinpoints.js";
|
4
|
+
|
5
|
+
const passingCode = `
|
6
|
+
unsigned int test_17_4_1() {
|
7
|
+
return 0;
|
8
|
+
}`;
|
9
|
+
|
10
|
+
const failingCode = `
|
11
|
+
unsigned int test_17_4_2() {
|
12
|
+
|
13
|
+
}`;
|
14
|
+
|
15
|
+
const failingCode2 = `
|
16
|
+
float test_17_4_3() {
|
17
|
+
|
18
|
+
}`;
|
19
|
+
|
20
|
+
const failingCode3 = `
|
21
|
+
enum Status {
|
22
|
+
FAIL,
|
23
|
+
SUCCESS
|
24
|
+
};
|
25
|
+
|
26
|
+
typedef enum {
|
27
|
+
RED,
|
28
|
+
GREEN,
|
29
|
+
} Color;
|
30
|
+
|
31
|
+
typedef unsigned int my_int_type;
|
32
|
+
|
33
|
+
// Non-compliant
|
34
|
+
enum Status test_17_4_3() {
|
35
|
+
|
36
|
+
}
|
37
|
+
|
38
|
+
// Non-compliant
|
39
|
+
Color test_17_4_4() {
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
// Non-compliant
|
44
|
+
my_int_type test_17_4_5() {
|
45
|
+
|
46
|
+
}
|
47
|
+
|
48
|
+
/*
|
49
|
+
Non-compliant after correction:
|
50
|
+
Config file do not specify the default value for 'double' type
|
51
|
+
*/
|
52
|
+
double test_17_4_6() {
|
53
|
+
}
|
54
|
+
`;
|
55
|
+
|
56
|
+
const files: TestFile[] = [
|
57
|
+
{ name: "bad1.c", code: failingCode },
|
58
|
+
{ name: "bad2.c", code: failingCode2 },
|
59
|
+
{ name: "bad3.c", code: failingCode3 },
|
60
|
+
{ name: "good.c", code: passingCode },
|
61
|
+
];
|
62
|
+
|
63
|
+
describe("Rule 17.4 (without config)", () => {
|
64
|
+
registerSourceCode(files);
|
65
|
+
|
66
|
+
it("should detect errors", () => {
|
67
|
+
expect(countMISRAErrors()).toBe(6);
|
68
|
+
expect(countMISRAErrors(Query.search(FileJp, { name: "bad1.c" }).first()!)).toBe(1);
|
69
|
+
expect(countMISRAErrors(Query.search(FileJp, { name: "bad2.c" }).first()!)).toBe(1);
|
70
|
+
expect(countMISRAErrors(Query.search(FileJp, { name: "bad3.c" }).first()!)).toBe(4);
|
71
|
+
expect(countMISRAErrors(Query.search(FileJp, { name: "good.c" }).first()!)).toBe(0);
|
72
|
+
});
|
73
|
+
|
74
|
+
it("should correct errors", () => {
|
75
|
+
expect(countErrorsAfterCorrection()).toBe(6);
|
76
|
+
});
|
77
|
+
});
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
2
|
+
import { countErrorsAfterCorrection, countMISRAErrors, registerSourceCode, TestFile } from "../utils.js";
|
3
|
+
import { FileJp } from "@specs-feup/clava/api/Joinpoints.js";
|
4
|
+
|
5
|
+
const passingCode = `
|
6
|
+
int test_17_6_1(int my_array[]) {
|
7
|
+
return my_array[0];
|
8
|
+
}`;
|
9
|
+
|
10
|
+
const failingCode = `
|
11
|
+
int test_17_6_2(int my_array[static 10]) {
|
12
|
+
return my_array[0];
|
13
|
+
}`;
|
14
|
+
|
15
|
+
const files: TestFile[] = [
|
16
|
+
{ name: "bad.c", code: failingCode },
|
17
|
+
{ name: "good.c", code: passingCode }
|
18
|
+
];
|
19
|
+
|
20
|
+
describe("Rule 17.6", () => {
|
21
|
+
if (process.env.STD_VERSION === "c90") {
|
22
|
+
it("should skip tests for c90", () => {});
|
23
|
+
} else {
|
24
|
+
registerSourceCode(files);
|
25
|
+
|
26
|
+
it("should detect errors in bad.c", () => {
|
27
|
+
expect(countMISRAErrors()).toBe(1);
|
28
|
+
expect(countMISRAErrors(Query.search(FileJp, { name: "bad.c" }).first()!)).toBe(1);
|
29
|
+
expect(countMISRAErrors(Query.search(FileJp, { name: "good.c" }).first()!)).toBe(0);
|
30
|
+
});
|
31
|
+
|
32
|
+
it("should correct errors in bad.c", () => {
|
33
|
+
expect(countErrorsAfterCorrection()).toBe(0);
|
34
|
+
});
|
35
|
+
}
|
36
|
+
});
|