Skip to content

A2-7-3: Exclude function scope declarations #451

@lcartey

Description

@lcartey

Affected rules

  • A2-7-3

Description

Function scope declarations are, by nature, limited in scope to the single function they are declared in. We should ignore such declarations for the purpose of this rule because it typically flags a large number of declarations developers are not inclined to document.

We believe this is justified by the spirit of the rule because such function-local declarations are limited in scope. This is interpretation is supported by JSF rule AV129, on which this rule is based, which states "Comments in header files should describe the externally visible behavior of the functions or classes being documented." Declarations inside a function are not "externally visible".

Example

void f() {
  class ClassA { // COMPLIANT
  };
}

Metadata

Metadata

Assignees

Labels

Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to addressImpact-Mediumfalse positive/false negativeAn issue related to observed false positives or false negatives.user-reportIssue reported by an end user of CodeQL Coding Standards

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions