clang-tidy v. -Weffc++
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
Research direction
Start with clang-tidy's readability-redundant-member-init documentation and the linked mapbox/cpp#37, wagyu#69, and wagyu#70 discussions; no repository file or test is identified. Determine an agreed approach for -Weffc++, clang-tidy guidance, and detecting uninitialized members; done requires a documented recommendation and configuration.
Written by the indexing model from the issue text.
Description
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 listclang-tidywill 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 anotherclang-tidycheck?
- Dominant language
- No language data
- Stars
- 110
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mapbox/cpp
-
glossary
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
Docs on ABIs Open
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
glossary
Difficulty 2/5 1-3 hours Newbie friendliness 58/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
hemilabs/ui-monorepo#2332 ·
-
Help-Wanted Needs-Triage Package-Update
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/winget-pkgs#438662 ·
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
olcf/olcf-test-harness#278 · 1 comment ·