SPeCS Packages Documentation
    Preparing search index...

    MISRA-C Rule 16.2: A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    analysisType: SINGLE_TRANSLATION_UNIT = AnalysisType.SINGLE_TRANSLATION_UNIT

    Scope of analysis

    appliesTo: Set<string> = ...

    Standards to which this rule applies to

    context: MISRAContext
    priority: 4

    A positive integer starting from 1 that indicates the rule's priority, determining the order in which rules are applied.

    Accessors

    • get dependencies(): Visit[]

      Returns Visit[]

      List of dependent visits, which is empty by default

    • get ruleID(): string

      An alias for 'name'

      Returns string

    Methods

    • Checks if the given joinpoint is a switch statement with any misplaced case labels. A case label is considered misplaced if it is not a direct child of the switch body.

      Parameters

      • $jp: Joinpoint

        Joinpoint to analyze

      • logErrors: boolean = false

        [logErrors=false] - Whether to log errors if a violation is detected

      Returns boolean

      Returns true if the joinpoint violates the rule, false otherwise

    • Rebuilds the program based on the current AST, clears stored data in the shared context, and resets all caches

      Returns void