Skip to content

Prepare MISRA C:2025 development with end-to-end examples - #1216

Open
mbaluda wants to merge 4 commits into
mainfrom
misra-c-2025-development
Open

mbaluda wants to merge 4 commits into
mainfrom
misra-c-2025-development

Conversation

@mbaluda

@mbaluda mbaluda commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This PR updates the project to support the development of MISRA C:2025 queries while retaining support for older editions.

Seven different categories of guideline changes are identified. For each category, this PR provides one complete end-to-end implementation with tests.
The remaining guideline work is tracked in rules-misra-c-2025.csv.

Implemented Examples By Category

Category Implemented Guidelines End-to-End Example
Renumber Rule1.2→Dir1.2 Rule21.1→Rule20.15 Rule21.2→Rule5.10 Reuse existing detectors, preserve legacy query IDs and select the appropriate identities in current/older suites. Existing product tests are reused through testref files.
Disapply Rule 15.5 Make the 2025 query Disapplied by default and support reactivation through recategorization, while preserving the legacy Advisory identity and reusing its detector/product coverage.
Clarification Rule 21.8 Extend Rule 21.8 to detect enabled assertions that call non-returning handlers such as __assert_fail, using the standard-library model. Add tests for enabled assertions, NDEBUG-disabled assertions, and unrelated non-returning calls. Existing banned-function checks remain unchanged.
Merge Rules 17.5 and 17.6 Retain Rule 17.5 array-size contract checks and remove the separate Rule 17.6 static-parameter prohibition from current suites. Older suites retain the legacy prohibition.
Expand Rule 17.3 Cover implicit declarations accepted as compiler extensions in C99 and C11. The existing detector already handles these cases.
Refine Dir 4.6 Provide the integer-only 2025 variant while retaining the legacy numerical-type query. Floating-point declarations and aliases are excluded by the 2025 variant.
New Rule 8.18 Implement detection of tentative file-scope definitions in headers, with declaration-level filtering and compliant/noncompliant cases for initializers, extern declarations, static objects, redeclarations, macros, and source-file/local controls.

The supporting changes update the rule inventory, schema, generators, suites, documentation, release metadata handling, and validation scripts. Unchanged queries keep their existing standard metadata; only new or modified variants use MISRA-C-2025.

Change Request Type

  • Release or process automation (GitHub workflows, internal scripts)
  • Internal documentation
  • External documentation
  • Query files (.ql, .qll, .qls or unit tests)
  • External scripts (analysis report or other code shipped as part of a release)

Rules With Added Or Modified Queries

  • No rules added
  • Queries have been added for:
    • DIR-1-2
    • DIR-4-6
    • RULE-5-10
    • RULE-8-18
    • RULE-15-5
    • RULE-20-15

Release change checklist

A change note (development_handbook.md#change-notes) is required for any pull request which modifies:

  • The structure or layout of the release artifacts.
  • The evaluation performance (memory, execution time) of an existing query.
  • The results of an existing query in any circumstance.

If you are only adding new rule queries, a change note is not required.

Author: Is a change note required?

  • Yes
  • No

🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.

  • Confirmed

Reviewer: Confirm that either a change note is not required or the change note is required and has been added.

  • Confirmed

Query development review checklist

For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:

Author

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

Reviewer

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

Copilot AI dynamic review requested due to automatic review settings November 3, 2026 17:33

This comment was marked as resolved.

mbaluda and others added 3 commits November 3, 2026 19:08
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

if (-not (Test-Path -LiteralPath $expectedFile -PathType Leaf)) {
throw "Referenced test has no expected results: $expectedFile"
}
return (Resolve-Path -LiteralPath $testFile).Path
}

return Join-Path (Join-Path (Join-Path (Join-Path $Language $standardString) "test") "rules") $ruleDir
return Split-Path -Path (Get-TestFile -RuleObject $RuleObject -Language $Language) -Parent
Comment on lines +40 to +41
$referenceFile = Join-Path $testDirectory "$queryName.testref"
if (Test-Path -LiteralPath $referenceFile -PathType Leaf) {
# 'AUTOSAR' and MISRA-C-2012, MISRA-C++-2023 and CERT-C
[Parameter(Mandatory, ParameterSetName = 'Suite')]
[ValidateSet("CERT-C++", "AUTOSAR", "MISRA-C-2012", "CERT-C", "MISRA-C++-2023")]
[ValidateSet("CERT-C++", "AUTOSAR", "MISRA-C-2012", "MISRA-C-2025", "CERT-C", "MISRA-C++-2023")]
@@ -0,0 +1,116 @@
import csv
Comment on lines +1 to +2
- Default MISRA C suites now target MISRA C:2025; support remains incomplete.
Explicit 2023 and 2012 suites retain their guideline sets and query IDs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants