[metadata]
id = "EXP19-C"
type = "recommendation"
category = "EXP"
number = 19
title = "Use braces for the body of an if, for, or while statement"
description = """
Opening and closing braces forif,for, andwhilestatements should always be used
even if the statement's body contains only a single statement. If anif,while,
orforstatement is used in a macro, the macro definition should not conclude with
a semicolon. (SeePRE11-C. Do not conclude macro definitions with a semicolon.)
Braces improve the uniformity and readability of code. More important, when
inserting an additional statement into a body containing only a single
statement, it is easy to forget to add braces because the indentation gives
strong (but misleading) guidance to the structure.
"""
severity = "Medium"
likelihood = "Probable"
priority = "P12"
level = "L1"
cert_version = "2016 Edition (Wiki)"
last_modified = "Aug 06, 2025"
[rules.cert_c.EXP19-C]
enabled = true
[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/EXP19-C.+Use+braces+for+the+body+of+an+if%2C+for%2C+or+while+statement"