@specs-feup/clava-misra 1.0.0 → 1.0.2
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 +44 -8
- package/src/MISRA.ts +276 -0
- package/src/MISRAContext.ts +84 -0
- package/src/MISRARule.ts +64 -0
- package/src/MISRATool.ts +95 -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 +41 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_3_UnconditionalBreak.ts +70 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_4_SwitchHasDefault.ts +41 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_5_DefaultFirstOrLast.ts +113 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_6_SwitchMinTwoClauses.ts +61 -0
- package/src/rules/Section16_SwitchStatements/Rule_16_7_NonBooleanSwitchCondition.ts +57 -0
- package/src/rules/Section17_Functions/Rule_17_3_ImplicitFunction.ts +180 -0
- package/src/rules/Section17_Functions/Rule_17_4_NonVoidReturn.ts +91 -0
- package/src/rules/Section17_Functions/Rule_17_6_StaticArraySizeParam.ts +68 -0
- package/src/rules/Section17_Functions/Rule_17_7_UnusedReturnValue.ts +49 -0
- package/src/rules/Section20-PreprocessingDirectives/Rule_20_2_InvalidHeaderFileName.ts +120 -0
- package/src/rules/Section2_UnusedCode/Rule_2_3_UnusedTypeDecl.ts +78 -0
- package/src/rules/Section2_UnusedCode/Rule_2_4_UnusedTagDecl.ts +61 -0
- package/src/rules/Section2_UnusedCode/Rule_2_6_UnusedLabels.ts +47 -0
- package/src/rules/Section2_UnusedCode/Rule_2_7_UnusedParameters.ts +67 -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 +44 -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_3_ImplicitFunctions.test.ts +79 -0
- package/src/tests/Section17_Functions/Rule_17_4_NonVoidReturn.test.ts +98 -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 +19 -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 +51 -0
- package/src/utils/utils.ts +280 -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
@@ -1,144 +0,0 @@
|
|
1
|
-
import MISRAReporter from "../MISRAReporter.js";
|
2
|
-
import S15_ControlFlowPass from "../passes/S15_ControlFlowPass.js";
|
3
|
-
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
4
|
-
import { FileJp, Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
5
|
-
import { expectNumberOfErrors, registerSourceCode, TestFile } from "./utils.js";
|
6
|
-
|
7
|
-
const passingCode = `void f ( void )
|
8
|
-
{
|
9
|
-
int j = 0;
|
10
|
-
++j;
|
11
|
-
if ( 10 == j )
|
12
|
-
{
|
13
|
-
goto L2; /* Compliant */
|
14
|
-
}
|
15
|
-
L2 :
|
16
|
-
++j;
|
17
|
-
}
|
18
|
-
|
19
|
-
void f1 ( int a )
|
20
|
-
{
|
21
|
-
if ( a <= 0 )
|
22
|
-
{
|
23
|
-
}
|
24
|
-
goto L1; /* Compliant */
|
25
|
-
if ( a == 0 )
|
26
|
-
{
|
27
|
-
goto L1; /* Compliant */
|
28
|
-
}
|
29
|
-
L1:
|
30
|
-
if ( a > 0 )
|
31
|
-
{
|
32
|
-
L2:
|
33
|
-
;
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
void f2() {
|
38
|
-
int x,y,z;
|
39
|
-
while ( x != 0u )
|
40
|
-
{
|
41
|
-
x = 5;
|
42
|
-
if ( x == 1u )
|
43
|
-
{
|
44
|
-
break;
|
45
|
-
}
|
46
|
-
while ( y != 0u )
|
47
|
-
{
|
48
|
-
y = 6;
|
49
|
-
if ( y == 1u )
|
50
|
-
{
|
51
|
-
goto L1;
|
52
|
-
}
|
53
|
-
}
|
54
|
-
L1:
|
55
|
-
z = x + y;
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
int main(int argc, char *argv[]) {
|
60
|
-
|
61
|
-
|
62
|
-
return 0;
|
63
|
-
}`;
|
64
|
-
|
65
|
-
const failingCode = `void g ( void )
|
66
|
-
{
|
67
|
-
int j = 0;
|
68
|
-
L1:
|
69
|
-
++j;
|
70
|
-
if ( 10 == j )
|
71
|
-
{
|
72
|
-
goto L2; /* Compliant */
|
73
|
-
}
|
74
|
-
goto L1; /* Non-compliant */
|
75
|
-
L2 :
|
76
|
-
++j;
|
77
|
-
}
|
78
|
-
|
79
|
-
void g1 ( int a )
|
80
|
-
{
|
81
|
-
if ( a <= 0 )
|
82
|
-
{
|
83
|
-
goto L2; /* Non-compliant */
|
84
|
-
}
|
85
|
-
goto L1; /* Compliant */
|
86
|
-
if ( a == 0 )
|
87
|
-
{
|
88
|
-
goto L1; /* Compliant */
|
89
|
-
}
|
90
|
-
goto L2; /* Non-compliant */
|
91
|
-
L1:
|
92
|
-
if ( a > 0 )
|
93
|
-
{
|
94
|
-
L2:
|
95
|
-
;
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
void g2() {
|
100
|
-
int x,y,z;
|
101
|
-
while ( x != 0u )
|
102
|
-
{
|
103
|
-
x = 5;
|
104
|
-
if ( x == 1u )
|
105
|
-
{
|
106
|
-
break;
|
107
|
-
}
|
108
|
-
while ( y != 0u )
|
109
|
-
{
|
110
|
-
y = 6;
|
111
|
-
if ( y == 1u )
|
112
|
-
{
|
113
|
-
goto L1;
|
114
|
-
}
|
115
|
-
}
|
116
|
-
}
|
117
|
-
L1:
|
118
|
-
z = x + y;
|
119
|
-
}
|
120
|
-
|
121
|
-
int test(int argc, char *argv[]) {
|
122
|
-
|
123
|
-
|
124
|
-
return 0;
|
125
|
-
}`;
|
126
|
-
|
127
|
-
const files: TestFile[] = [
|
128
|
-
{name: "bad.cpp", code: failingCode},
|
129
|
-
{name: "good.cpp", code: passingCode}
|
130
|
-
]
|
131
|
-
|
132
|
-
describe("Expressions", () => {
|
133
|
-
const reporter = new MISRAReporter();
|
134
|
-
const pass = new S15_ControlFlowPass(true, [1, 2, 3, 4]);
|
135
|
-
registerSourceCode(files);
|
136
|
-
|
137
|
-
it("should pass", () => {
|
138
|
-
expectNumberOfErrors(reporter, pass, 4, Query.search(FileJp, {name: "good.cpp"}).first() as Joinpoint);
|
139
|
-
});
|
140
|
-
|
141
|
-
it("should fail", () => {
|
142
|
-
expectNumberOfErrors(reporter, pass, 11, Query.search(FileJp, {name: "bad.cpp"}).first() as Joinpoint);
|
143
|
-
});
|
144
|
-
});
|
@@ -1,164 +0,0 @@
|
|
1
|
-
import MISRAReporter from "../MISRAReporter.js";
|
2
|
-
import S16_SwitchStatementPass from "../passes/S16_SwitchStatementPass.js";
|
3
|
-
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
4
|
-
import { FileJp, Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
5
|
-
import { expectNumberOfErrors, registerSourceCode, TestFile } from "./utils.js";
|
6
|
-
|
7
|
-
const passingMisc = `void f ( void )
|
8
|
-
{
|
9
|
-
int x;
|
10
|
-
bool flag;
|
11
|
-
switch ( x )
|
12
|
-
{
|
13
|
-
case 1:
|
14
|
-
case 2:
|
15
|
-
x = 1;
|
16
|
-
break;
|
17
|
-
default:
|
18
|
-
break;
|
19
|
-
}
|
20
|
-
switch (x) {
|
21
|
-
case 1:
|
22
|
-
case 2:
|
23
|
-
default:
|
24
|
-
break;
|
25
|
-
}
|
26
|
-
}`;
|
27
|
-
|
28
|
-
const failingMisc = `void f ( void )
|
29
|
-
{
|
30
|
-
int x;
|
31
|
-
bool flag;
|
32
|
-
switch ( x )
|
33
|
-
{
|
34
|
-
case 1: /* Compliant */
|
35
|
-
if ( flag )
|
36
|
-
{
|
37
|
-
case 2: /* Non-compliant */
|
38
|
-
x = 1;
|
39
|
-
}
|
40
|
-
break;
|
41
|
-
default:
|
42
|
-
break;
|
43
|
-
case 3:
|
44
|
-
break;
|
45
|
-
}
|
46
|
-
switch (x) {
|
47
|
-
case 1:
|
48
|
-
case 2:
|
49
|
-
break;
|
50
|
-
}
|
51
|
-
}`;
|
52
|
-
|
53
|
-
const passingFormat = `void f ( void )
|
54
|
-
{
|
55
|
-
int x, y, z;
|
56
|
-
int flag;
|
57
|
-
switch (x) {
|
58
|
-
case 1:
|
59
|
-
z = y+x;
|
60
|
-
break;
|
61
|
-
case 2:
|
62
|
-
z = y-x;
|
63
|
-
break;
|
64
|
-
default:
|
65
|
-
z = 4;
|
66
|
-
break;
|
67
|
-
}
|
68
|
-
switch (flag) {
|
69
|
-
case 0:
|
70
|
-
x = 2;
|
71
|
-
break;
|
72
|
-
case 1:
|
73
|
-
x = 4;
|
74
|
-
break;
|
75
|
-
case 2:
|
76
|
-
x = 6;
|
77
|
-
break;
|
78
|
-
}
|
79
|
-
switch (z) {
|
80
|
-
case 1:
|
81
|
-
y = 0;
|
82
|
-
break;
|
83
|
-
case 6:
|
84
|
-
case 42:
|
85
|
-
y = 1;
|
86
|
-
break;
|
87
|
-
case 9139:
|
88
|
-
default:
|
89
|
-
y = 2;
|
90
|
-
break;
|
91
|
-
}
|
92
|
-
}`;
|
93
|
-
|
94
|
-
const failingFormat = `void f ( void )
|
95
|
-
{
|
96
|
-
int x, y, z;
|
97
|
-
bool flag;
|
98
|
-
switch (x) {
|
99
|
-
case 1:
|
100
|
-
z = y+x;
|
101
|
-
case 2:
|
102
|
-
z = y-x;
|
103
|
-
break;
|
104
|
-
default:
|
105
|
-
z = 4;
|
106
|
-
}
|
107
|
-
switch (flag) {
|
108
|
-
case 0:
|
109
|
-
x = 2;
|
110
|
-
break;
|
111
|
-
case 1:
|
112
|
-
x = 4;
|
113
|
-
break;
|
114
|
-
}
|
115
|
-
switch (z) {
|
116
|
-
case 1:
|
117
|
-
case 6:
|
118
|
-
case 42:
|
119
|
-
y = 1;
|
120
|
-
break;
|
121
|
-
case 9139:
|
122
|
-
default:
|
123
|
-
y = 2;
|
124
|
-
break;
|
125
|
-
}
|
126
|
-
}`;
|
127
|
-
|
128
|
-
const miscFiles: TestFile[] = [
|
129
|
-
{name: "badmmisc.cpp", code: failingMisc},
|
130
|
-
{name: "goodmisc.cpp", code: passingMisc}
|
131
|
-
];
|
132
|
-
|
133
|
-
const formatFiles: TestFile[] = [
|
134
|
-
{name: "badformat.cpp", code: failingFormat},
|
135
|
-
{name: "goodformat.cpp", code: passingFormat}
|
136
|
-
];
|
137
|
-
|
138
|
-
describe("Switch statements: misc", () => {
|
139
|
-
const reporter = new MISRAReporter();
|
140
|
-
const pass = new S16_SwitchStatementPass(true, [2, 4, 5]);
|
141
|
-
registerSourceCode(miscFiles);
|
142
|
-
|
143
|
-
it("should pass", () => {
|
144
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "goodmisc.cpp"}).first() as Joinpoint);
|
145
|
-
});
|
146
|
-
|
147
|
-
it("should fail", () => {
|
148
|
-
expectNumberOfErrors(reporter, pass, 3, Query.search(FileJp, {name: "badmisc.cpp"}).first() as Joinpoint);
|
149
|
-
});
|
150
|
-
});
|
151
|
-
|
152
|
-
describe("Switch statements: format", () => {
|
153
|
-
const reporter = new MISRAReporter();
|
154
|
-
const pass = new S16_SwitchStatementPass(true, [1, 6, 7]);
|
155
|
-
registerSourceCode(formatFiles);
|
156
|
-
|
157
|
-
it("should pass", () => {
|
158
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "goodformat.cpp"}).first() as Joinpoint);
|
159
|
-
});
|
160
|
-
|
161
|
-
it("should fail", () => {
|
162
|
-
expectNumberOfErrors(reporter, pass, 5, Query.search(FileJp, {name: "badformat.cpp"}).first() as Joinpoint);
|
163
|
-
});
|
164
|
-
});
|
@@ -1,46 +0,0 @@
|
|
1
|
-
import MISRAReporter from "../MISRAReporter.js";
|
2
|
-
import S17_FunctionPass from "../passes/S17_FunctionPass.js";
|
3
|
-
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
4
|
-
import { FileJp, Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
5
|
-
import { expectNumberOfErrors, registerSourceCode, TestFile } from "./utils.js";
|
6
|
-
|
7
|
-
const passingCode = `int g() {
|
8
|
-
return 5;
|
9
|
-
}
|
10
|
-
|
11
|
-
int main(int argc, char *argv[]) {
|
12
|
-
(void)g();
|
13
|
-
|
14
|
-
return 0;
|
15
|
-
}`;
|
16
|
-
|
17
|
-
const failingCode = `#include <stdarg.h>
|
18
|
-
|
19
|
-
int f() {
|
20
|
-
return 5;
|
21
|
-
}
|
22
|
-
|
23
|
-
int test(int argc, char *argv[]) {
|
24
|
-
f();
|
25
|
-
|
26
|
-
return 0;
|
27
|
-
}`;
|
28
|
-
|
29
|
-
const files: TestFile[] = [
|
30
|
-
{name: "bad.cpp", code: failingCode},
|
31
|
-
{name: "good.cpp", code: passingCode}
|
32
|
-
]
|
33
|
-
|
34
|
-
describe("Expressions", () => {
|
35
|
-
const reporter = new MISRAReporter();
|
36
|
-
const pass = new S17_FunctionPass(true, [1, 7]);
|
37
|
-
registerSourceCode(files);
|
38
|
-
|
39
|
-
it("should pass", () => {
|
40
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "good.cpp"}).first() as Joinpoint);
|
41
|
-
});
|
42
|
-
|
43
|
-
it("should fail", () => {
|
44
|
-
expectNumberOfErrors(reporter, pass, 2, Query.search(FileJp, {name: "bad.cpp"}).first() as Joinpoint);
|
45
|
-
});
|
46
|
-
});
|
@@ -1,167 +0,0 @@
|
|
1
|
-
import MISRAReporter from "../MISRAReporter.js";
|
2
|
-
import S18_PointersArraysPass from "../passes/S18_PointersArraysPass.js";
|
3
|
-
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
4
|
-
import { FileJp, Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
5
|
-
import { expectNumberOfErrors, registerSourceCode, TestFile } from "./utils.js";
|
6
|
-
|
7
|
-
const passingArithmetic = `void fn1 ( void )
|
8
|
-
{
|
9
|
-
int a[ 10 ];
|
10
|
-
int *ptr;
|
11
|
-
int index = 0U;
|
12
|
-
index = index + 1U; /* Compliant - rule only applies to pointers */
|
13
|
-
a[ index ] = 0U; /* Compliant */
|
14
|
-
ptr = &a[ 5 ]; /* Compliant */
|
15
|
-
ptr = a;
|
16
|
-
ptr++; /* Compliant - increment operator not + */
|
17
|
-
//*( ptr + 5 ) = 0U; /* Non-compliant */
|
18
|
-
ptr[ 5 ] = 0U; /* Compliant */
|
19
|
-
}
|
20
|
-
|
21
|
-
void fn3 ( int *p1, int p2[ ] )
|
22
|
-
{
|
23
|
-
p1++; /* Compliant */
|
24
|
-
//p1 = p1 + 5; /* Non-compliant */
|
25
|
-
p1[ 5 ] = 0U; /* Compliant */
|
26
|
-
p2++; /* Compliant */
|
27
|
-
//p2 = p2 + 3; /* Non-compliant */
|
28
|
-
p2[ 3 ] = 0U; /* Compliant */
|
29
|
-
}`;
|
30
|
-
|
31
|
-
const failingArithmetic = `void fn1 ( void )
|
32
|
-
{
|
33
|
-
int a[ 10 ];
|
34
|
-
int *ptr;
|
35
|
-
int index = 0U;
|
36
|
-
index = index + 1U; /* Compliant - rule only applies to pointers */
|
37
|
-
a[ index ] = 0U; /* Compliant */
|
38
|
-
ptr = &a[ 5 ]; /* Compliant */
|
39
|
-
ptr = a;
|
40
|
-
ptr++; /* Compliant - increment operator not + */
|
41
|
-
*( ptr + 5 ) = 0U; /* Non-compliant */
|
42
|
-
ptr[ 5 ] = 0U; /* Compliant */
|
43
|
-
}
|
44
|
-
|
45
|
-
void fn3 ( int *p1, int p2[ ] )
|
46
|
-
{
|
47
|
-
p1++; /* Compliant */
|
48
|
-
p1 = p1 + 5; /* Non-compliant */
|
49
|
-
p1[ 5 ] = 0U; /* Compliant */
|
50
|
-
p2++; /* Compliant */
|
51
|
-
p2 = p2 + 3; /* Non-compliant */
|
52
|
-
p2[ 3 ] = 0U; /* Compliant */
|
53
|
-
}`;
|
54
|
-
|
55
|
-
const passingDepth = ``;
|
56
|
-
|
57
|
-
const failingDepth = `typedef int * INTPTR;
|
58
|
-
void function ( int ** arrPar[ ] ) /* Non-compliant */
|
59
|
-
{
|
60
|
-
int ** obj2; /* Compliant */
|
61
|
-
int *** obj3; /* Non-compliant */
|
62
|
-
INTPTR * obj4; /* Compliant */
|
63
|
-
INTPTR * const * const obj5 = 0; /* Non-compliant */
|
64
|
-
int ** arr[ 10 ]; /* Compliant */
|
65
|
-
int ** ( *parr )[ 10 ]; /* Compliant */
|
66
|
-
int * ( **pparr )[ 10 ]; /* Compliant */
|
67
|
-
}
|
68
|
-
struct s
|
69
|
-
{
|
70
|
-
int * s1; /* Compliant */
|
71
|
-
int ** s2; /* Compliant */
|
72
|
-
int *** s3; /* Non-compliant */
|
73
|
-
};
|
74
|
-
struct s * ps1; /* Compliant */
|
75
|
-
struct s ** ps2; /* Compliant */
|
76
|
-
struct s *** ps3; /* Non-compliant */
|
77
|
-
int ** ( *pfunc1 )( void ); /* Compliant */
|
78
|
-
int ** ( **pfunc2 )( void ); /* Compliant */
|
79
|
-
int ** ( ***pfunc3 )( void ); /* Non-compliant */
|
80
|
-
int *** ( **pfunc4 )( void ); /* Non-compliant */`;
|
81
|
-
|
82
|
-
const failingSizes = `struct s
|
83
|
-
{
|
84
|
-
unsigned short len;
|
85
|
-
unsigned int data[ ]; /* Non-compliant - flexible array member */
|
86
|
-
} str;
|
87
|
-
|
88
|
-
void f ( void )
|
89
|
-
{
|
90
|
-
int n = 5;
|
91
|
-
typedef int Vector[ n ]; /* An array type with 5 elements */
|
92
|
-
n = 7;
|
93
|
-
Vector a1; /* An array type with 5 elements */
|
94
|
-
int a2[ n ]; /* An array type with 7 elements */
|
95
|
-
}`;
|
96
|
-
|
97
|
-
const passingSizes = `struct s
|
98
|
-
{
|
99
|
-
unsigned short len;
|
100
|
-
unsigned int data[ 6 ];
|
101
|
-
} str;
|
102
|
-
|
103
|
-
void f ( void )
|
104
|
-
{
|
105
|
-
int n = 5;
|
106
|
-
typedef int Vector[ 5 ]; /* An array type with 5 elements */
|
107
|
-
n = 7;
|
108
|
-
Vector a1; /* An array type with 5 elements */
|
109
|
-
int a2[ 7 ]; /* An array type with 7 elements */
|
110
|
-
}`;
|
111
|
-
|
112
|
-
const arithmeticFiles: TestFile[] = [
|
113
|
-
{name: "badarithmetic.cpp", code: failingArithmetic},
|
114
|
-
{name: "goodarithmetic.cpp", code: passingArithmetic}
|
115
|
-
];
|
116
|
-
|
117
|
-
const depthFiles: TestFile[] = [
|
118
|
-
{name: "baddepth.cpp", code: failingDepth},
|
119
|
-
{name: "gooddepth.cpp", code: passingDepth}
|
120
|
-
];
|
121
|
-
|
122
|
-
const sizeFiles: TestFile[] = [
|
123
|
-
{name: "goodsizes.cpp", code: passingSizes},
|
124
|
-
{name: "badsizes.cpp", code: failingSizes}
|
125
|
-
];
|
126
|
-
|
127
|
-
describe("Pointers and arrays: arithmetic", () => {
|
128
|
-
const reporter = new MISRAReporter();
|
129
|
-
const pass = new S18_PointersArraysPass(true, [4]);
|
130
|
-
registerSourceCode(arithmeticFiles);
|
131
|
-
|
132
|
-
it("should pass", () => {
|
133
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "goodarithmetic.cpp"}).first() as Joinpoint);
|
134
|
-
});
|
135
|
-
|
136
|
-
it("should fail", () => {
|
137
|
-
expectNumberOfErrors(reporter, pass, 3, Query.search(FileJp, {name: "badarithmetic.cpp"}).first() as Joinpoint);
|
138
|
-
});
|
139
|
-
});
|
140
|
-
|
141
|
-
describe("Pointers and arrays: declaration depth", () => {
|
142
|
-
const reporter = new MISRAReporter();
|
143
|
-
const pass = new S18_PointersArraysPass(true, [5]);
|
144
|
-
registerSourceCode(depthFiles);
|
145
|
-
|
146
|
-
it("should pass", () => {
|
147
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "gooddepth.cpp"}).first() as Joinpoint);
|
148
|
-
});
|
149
|
-
|
150
|
-
it("should fail", () => {
|
151
|
-
expectNumberOfErrors(reporter, pass, 7, Query.search(FileJp, {name: "baddepth.cpp"}).first() as Joinpoint);
|
152
|
-
});
|
153
|
-
});
|
154
|
-
|
155
|
-
describe("Pointers and arrays: variable size", () => {
|
156
|
-
const reporter = new MISRAReporter();
|
157
|
-
const pass = new S18_PointersArraysPass(true, [7,8]);
|
158
|
-
registerSourceCode(sizeFiles);
|
159
|
-
|
160
|
-
it("should pass", () => {
|
161
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "goodsizes.cpp"}).first() as Joinpoint);
|
162
|
-
});
|
163
|
-
|
164
|
-
it("should fail", () => {
|
165
|
-
expectNumberOfErrors(reporter, pass, 3, Query.search(FileJp, {name: "badsizes.cpp"}).first() as Joinpoint);
|
166
|
-
});
|
167
|
-
});
|
@@ -1,38 +0,0 @@
|
|
1
|
-
import MISRAReporter from "../MISRAReporter.js";
|
2
|
-
import S19_OverlappingStoragePass from "../passes/S19_OverlappingStoragePass.js";
|
3
|
-
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
4
|
-
import { FileJp, Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
5
|
-
import { expectNumberOfErrors, registerSourceCode, TestFile } from "./utils.js";
|
6
|
-
|
7
|
-
const passingCode = `struct a {
|
8
|
-
int a;
|
9
|
-
int b;
|
10
|
-
};
|
11
|
-
|
12
|
-
int main(int argc, char *argv[]) {
|
13
|
-
return 0;
|
14
|
-
}`;
|
15
|
-
|
16
|
-
const failingCode = `union a {
|
17
|
-
int a;
|
18
|
-
int b;
|
19
|
-
};`;
|
20
|
-
|
21
|
-
const files: TestFile[] = [
|
22
|
-
{name: "bad.cpp", code: failingCode},
|
23
|
-
{name: "good.cpp", code: passingCode}
|
24
|
-
]
|
25
|
-
|
26
|
-
describe("Expressions", () => {
|
27
|
-
const reporter = new MISRAReporter();
|
28
|
-
const pass = new S19_OverlappingStoragePass(true, [2]);
|
29
|
-
registerSourceCode(files);
|
30
|
-
|
31
|
-
it("should pass", () => {
|
32
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "good.cpp"}).first() as Joinpoint);
|
33
|
-
});
|
34
|
-
|
35
|
-
it("should fail", () => {
|
36
|
-
expectNumberOfErrors(reporter, pass, 1, Query.search(FileJp, {name: "bad.cpp"}).first() as Joinpoint);
|
37
|
-
});
|
38
|
-
});
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import MISRAReporter from "../MISRAReporter.js";
|
2
|
-
import S3_CommentPass from "../passes/S3_CommentPass.js";
|
3
|
-
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
4
|
-
import { FileJp, Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
5
|
-
import { expectNumberOfErrors, registerSourceCode, TestFile } from "./utils.js";
|
6
|
-
|
7
|
-
const passingCode = `int main(int argc, char *argv[]) {
|
8
|
-
int x, y, z;//good inline comment
|
9
|
-
//good comment
|
10
|
-
return 0;
|
11
|
-
}`;
|
12
|
-
|
13
|
-
const failingCode = `int test(int argc, char *argv[]) {
|
14
|
-
int x, y, z; //bad inl//ine comment
|
15
|
-
//bad /*comment
|
16
|
-
return 0;
|
17
|
-
}`;
|
18
|
-
|
19
|
-
const files: TestFile[] = [
|
20
|
-
{name: "bad.cpp", code: failingCode},
|
21
|
-
{name: "good.cpp", code: passingCode}
|
22
|
-
]
|
23
|
-
|
24
|
-
describe("Expressions", () => {
|
25
|
-
const reporter = new MISRAReporter();
|
26
|
-
const pass = new S3_CommentPass(true, [3]);
|
27
|
-
registerSourceCode(files);
|
28
|
-
|
29
|
-
it("should pass", () => {
|
30
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "good.cpp"}).first() as Joinpoint);
|
31
|
-
});
|
32
|
-
|
33
|
-
it("should fail", () => {
|
34
|
-
expectNumberOfErrors(reporter, pass, 2, Query.search(FileJp, {name: "bad.cpp"}).first() as Joinpoint);
|
35
|
-
});
|
36
|
-
});
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import MISRAReporter from "../MISRAReporter.js";
|
2
|
-
import S6_TypePass from "../passes/S6_TypePass.js";
|
3
|
-
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
4
|
-
import { FileJp, Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
5
|
-
import { expectNumberOfErrors, registerSourceCode, TestFile } from "./utils.js";
|
6
|
-
|
7
|
-
const passingCode = `struct good {
|
8
|
-
int a:4;
|
9
|
-
int:1;
|
10
|
-
unsigned int b:8;
|
11
|
-
};`;
|
12
|
-
|
13
|
-
const failingCode = `struct good {
|
14
|
-
int a:4;
|
15
|
-
int c:1;
|
16
|
-
unsigned int b:8;
|
17
|
-
};`;
|
18
|
-
|
19
|
-
const files: TestFile[] = [
|
20
|
-
{name: "bad.cpp", code: failingCode},
|
21
|
-
{name: "good.cpp", code: passingCode}
|
22
|
-
]
|
23
|
-
|
24
|
-
describe("Expressions", () => {
|
25
|
-
const reporter = new MISRAReporter();
|
26
|
-
const pass = new S6_TypePass(true, [2]);
|
27
|
-
registerSourceCode(files);
|
28
|
-
|
29
|
-
it("should pass", () => {
|
30
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "good.cpp"}).first() as Joinpoint);
|
31
|
-
});
|
32
|
-
|
33
|
-
it("should fail", () => {
|
34
|
-
expectNumberOfErrors(reporter, pass, 1, Query.search(FileJp, {name: "bad.cpp"}).first() as Joinpoint);
|
35
|
-
});
|
36
|
-
});
|
@@ -1,48 +0,0 @@
|
|
1
|
-
import MISRAReporter from "../MISRAReporter.js";
|
2
|
-
import S7_LiteralsConstantsPass from "../passes/S7_LiteralsConstantsPass.js";
|
3
|
-
import Query from "@specs-feup/lara/api/weaver/Query.js";
|
4
|
-
import { FileJp, Joinpoint } from "@specs-feup/clava/api/Joinpoints.js";
|
5
|
-
import { expectNumberOfErrors, registerSourceCode, TestFile } from "./utils.js";
|
6
|
-
|
7
|
-
const passingCode = `void bar(const char* s) {
|
8
|
-
return;
|
9
|
-
}
|
10
|
-
|
11
|
-
const char* foo() {
|
12
|
-
const char* s = "hello world";
|
13
|
-
int a = 12;
|
14
|
-
long b = 42L;
|
15
|
-
bar("bad call");
|
16
|
-
return "bye world";
|
17
|
-
}`;
|
18
|
-
|
19
|
-
const failingCode = `void bar(char* s) {
|
20
|
-
return;
|
21
|
-
}
|
22
|
-
|
23
|
-
char* foo() {
|
24
|
-
char* s = "hello world";
|
25
|
-
int a = 014;
|
26
|
-
long b = 42l;
|
27
|
-
bar("bad call");
|
28
|
-
return "bye world";
|
29
|
-
}`;
|
30
|
-
|
31
|
-
const files: TestFile[] = [
|
32
|
-
{name: "bad.cpp", code: failingCode},
|
33
|
-
{name: "good.cpp", code: passingCode}
|
34
|
-
]
|
35
|
-
|
36
|
-
describe("Expressions", () => {
|
37
|
-
const reporter = new MISRAReporter();
|
38
|
-
const pass = new S7_LiteralsConstantsPass(true, [1, 3, 4]);
|
39
|
-
registerSourceCode(files);
|
40
|
-
|
41
|
-
it("should pass", () => {
|
42
|
-
expectNumberOfErrors(reporter, pass, 0, Query.search(FileJp, {name: "good.cpp"}).first() as Joinpoint);
|
43
|
-
});
|
44
|
-
|
45
|
-
it("should fail", () => {
|
46
|
-
expectNumberOfErrors(reporter, pass, 5, Query.search(FileJp, {name: "bad.cpp"}).first() as Joinpoint);
|
47
|
-
});
|
48
|
-
});
|