Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`M14-6-1`: enhancement to cover types

オープン
#221 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp
領域
devtools

調査の方向性

リンクされた issue 192 と M14-6-1 クエリのドラフトから始め、NameInDependentBase、TypeUses、TemplatesPackage を含めて確認します。C++ の例に示されている typedef と型使用の動作を調査し、そのうえで、そのクエリが修飾付きと修飾なしの依存基底クラスにおける typedef の使用を正確に、かつ古いライブラリのパフォーマンス問題なしにカバーできるかどうかを判断します。

索引モデルが issue の本文から書いたものです。

説明

Standard-AUTOSAR

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."
主要言語
CodeQL
スター
227
フォーク
82
平均マージ
6日 7時間
マージ済み PR(30日)
9

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/codeql-coding-standards のほかの issue

github/codeql-coding-standards の issue をすべて見る

似ている issue

DevTools の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。