mapbox / mapbox/cpp

clang-tidy v. -Weffc++

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

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

主要言語
言語のデータがありません
スター
110
フォーク
17
PR マージ指標
30日以内にマージされた PR はありません

説明

Context

Recent versions of clang-tidy added readability-redundant-member-init: https://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-member-init.html

This is handy! When a class member has a default initializer it is redundent to initialize it in the member list.

But, because some types don't have default initializers, forgetting to initialize them in the member list (or using c++11 initialization in the class definition) can lead to serious trouble like mapbox/wagyu#69 - refs mapbox/wagyu#70.

So, this is the reason, at https://github.com/mapbox/cpp/issues/37#issuecomment-336200744, that we recommend using g++ and the -Weffc++ flag because it can catch this (note, clang++ plus -Weffc++ cannot):

-Weffc++ - useful when building with g++ (does not do much with clang++). With g++ it can catch uninitialized class members and prevent crashes like mapbox/wagyu#69 - refs mapbox/wagyu#70

Problem

  • -Weffc++ will warn on all class members not explicitly initialized in the initializer list
  • clang-tidy will automatically remove variables from the initializer list that have default constructors

So, the two will fight: causing each other warnings. For this reason I think we should likely:

  • let clang-tidy win
  • recommend no longer using g++ with -Weffc++
  • figure out what alternative way we can catch when members, without default initializers, are uninitialized (without needing to use -Weffc++). Maybe another clang-tidy check?

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

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

はじめの一歩

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

調査の方向性

clang-tidy's readability-redundant-member-init のドキュメントと、リンクされている mapbox/cpp#37、wagyu#69、wagyu#70 の議論から始めてください。リポジトリのファイルやテストは特定されていません。-Weffc++、clang-tidy のガイダンス、および未初期化メンバーの検出について、合意されたアプローチを決定してください。完了条件は、文書化された推奨事項と設定があることです。

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

評価

技術スタック
cpp
領域
tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
30/100

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

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