`M14-6-1`: enhancement to cover types
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginne mit dem verknüpften Issue 192 und dem Abfrageentwurf M14-6-1, einschließlich NameInDependentBase, TypeUses und TemplatesPackage. Untersuche das im C++-Beispiel gezeigte Verhalten von typedef und Type-Use und ermittle anschließend, ob die Abfrage qualifizierte und nicht qualifizierte abhängige Basisklassen-typedef-Verwendungen korrekt und ohne die Performanceprobleme der alten Bibliothek abdecken kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
as noted in this issue this rule does not address the types case
the reason was that at the time of writing this query it was discovered that we dont have fully qualified typenames for typedefs:
typedef int TYPE;
template<typename T>
class B {
public:
typedef T TYPE;
};
template<typename T>
class A : B<T> {
public:
void m2(){
TYPE t = 0; // NON_COMPLIANT
::TYPE t1 = 0; //COMPLIANT
typename B<T>::TYPE t2 = 0; // COMPLIANT
}
};
void f(){
A<int> a;
a.m2();
}
example, trying to get full names of types present:
from TypedefType t
select t, t.getQualifiedName(), t.getATypeNameUse()
result:
+| test.cpp:1:13:1:16 | TYPE | TYPE | test.cpp:20:14:20:14 | definition of t |
+| test.cpp:1:13:1:16 | TYPE | TYPE | test.cpp:26:16:26:17 | definition of t1 |
and initial audit level query was written but it was imprecise and used the old lib (so also non performat). would need cleanup or rewriting
/**
* @id cpp/autosar/name-not-referred-using-a-qualified-id-or-this-type-def-type
* @name M14-6-1: In a class template with a dependent base, any typedef type name that may be found in that dependent base shall shall be referred to using a qualified-id or this->
* @description Not using a qualified-id or `this->` syntax for typedef type uses in a class
* template makes the code more difficult to understand.
* @kind problem
* @precision very-high
* @problem.severity warning
* @tags external/autosar/id/m14-6-1
* maintainability
* readability
* external/autosar/allocated-target/implementation
* external/autosar/enforcement/automated
* external/autosar/obligation/required
*/
import cpp
import codingstandards.cpp.autosar
import codingstandards.cpp.TypeUses
import NameInDependentBase
/**
* `Locatable`s exists only in some `MemberFunction`
* this class is required to speed up `TypeUses.getATypeUse`
*/
class LocatablesInChild extends Locatable {
Class child;
LocatablesInChild() { this.getEnclosingElement() = child.getAMemberFunction() }
predicate isInThisChild(Class c) { c = child }
}
/**
* `TypedefType`s that are declared in a `Class`
* that is a parent of any other `Class`
*/
class ParentTypedefType extends TypedefType {
Class parent;
Class child;
ParentTypedefType() {
this.getDeclaringType() = parent and
getParent(child) = parent
}
predicate thisIsMyChild(Class c) { c = child }
}
/**
* All pairs of `TypedefType` and `ParentTypedefType`
* with a same name
*/
predicate sameNameTypeDefPairs(TypedefType v, ParentTypedefType parentType) {
v.getName() = parentType.getName()
}
from Class c, TypedefType v, ParentTypedefType parentType, LocatablesInChild l
where
not isExcluded(l, TemplatesPackage::nameNotReferredUsingAQualifiedIdOrThisTypeDefTypeQuery()) and
l.isInThisChild(c) and
parentType.thisIsMyChild(c) and
l = getATypeUse(v) and
//two TypedefTypes with same name but one was declared in the dependent base
sameNameTypeDefPairs(v, parentType)
select l,
"Use of typedef type name that also exists in a base class that may not be fully qualified."
- Vorherrschende Sprache
- CodeQL
- Sterne
- 227
- Forks
- 82
- Ø Merge
- 6 T. 7 Std.
- Gemergte PRs (30 T.)
- 9
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus github/codeql-coding-standards
-
false positive/false negative Stardard-MISRA-C++
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
github/codeql-coding-standards#1172 ·
-
Difficulty-Low false positive/false negative false-negative Impact-Low Standard-MISRA-C
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
-
Difficulty-Medium false positive/false negative false-positive Impact-Medium Standard-CERT-C
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
github/codeql-coding-standards#1200 ·
-
`RULE-0-0-1`: "unreachable statement" false positives due to over-pruning of the control-flow graph Offenfalse positive/false negative
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
github/codeql-coding-standards#1190 ·
-
false positive/false negative
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 65/100
github/codeql-coding-standards#1175 ·
Alle Issues in github/codeql-coding-standards
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
stephrobert/dsoxlab#238 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
sublimehq/package_control#1780 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
typelevel/sbt-typelevel#929 ·
-
Update HugeIcons library Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
antfu-collective/icones#398 ·