Skip to content

A16-2-2: Consider excluding redundant includes #453

Closed
@lcartey

Description

@lcartey

Affected rules

  • A16-2-2

Description

The query currently reports redundant includes - e.g. includes which provide used symbols which are provided by earlier includes. I don't believe redundant includes are intended to be flagged by this rule per the justification.

Note: this doesn't occur if a declaration is used in the directly included file. In that case we assume the redundancy is intended. However, if a library is structured so that the public header forwards to an internal header, we can get "spurious" redundancy results.

Example

source.c

#include "a.h"
#include "lib.h" // Seen as useless

void test() {
  f();
  g();
}

a.h

#include "lib.h"

void g() {
  f();
}

lib.h

#include "lib_internal.h"

lib_internal.h

void f();

Metadata

Metadata

Assignees

Labels

Difficulty-HighA false positive or false negative report which is expected to take 1+ week 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