MCPcopy Create free account
hub / github.com/KDE/kdevelop / addCheck

Method addCheck

plugins/clangtidy/config/checkgroup.cpp:42–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40
41
42void CheckGroup::addCheck(const QString& checkName)
43{
44 const int nextSplitOffset = checkName.indexOf(QRegularExpression(QStringLiteral("[-.]")), m_prefix.length());
45
46 // 1. check if looking at last section, if so add to current group
47 if (nextSplitOffset < 0) {
48 m_checks.append(checkName);
49 m_checksEnabledStates.append(EnabledInherited);
50 return;
51 }
52
53 // 2. check if existing subgroup for prefix, if so add to that
54 // include separator into subgroup name
55 const auto subGroupName = QStringView{checkName}.first(nextSplitOffset + 1);
56 for (auto* subGroup : std::as_const(m_subGroups)) {
57 if (subGroup->prefix() == subGroupName) {
58 subGroup->addCheck(checkName);
59 return;
60 }
61 }
62
63 // 3. check if existing check with same prefix, if so create subgroup for them
64 for (int i = 0; i < m_checks.size(); ++i) {
65 const auto& listedCheckName = m_checks.at(i);
66 if (listedCheckName.startsWith(subGroupName)) {
67 auto* newSubGroup = new CheckGroup(subGroupName.toString(), this);
68 newSubGroup->addCheck(listedCheckName);
69 newSubGroup->addCheck(checkName);
70 m_subGroups.append(newSubGroup);
71 m_checks.removeAt(i);
72 m_checksEnabledStates.removeAt(i);
73 return;
74 }
75 }
76
77 // 4. add to current group
78 m_checks.append(checkName);
79 m_checksEnabledStates.append(EnabledInherited);
80}
81
82void CheckGroup::setEnabledChecks(const QStringList& rules)
83{

Callers 1

fromPlainListMethod · 0.80

Calls 8

prefixMethod · 0.80
indexOfMethod · 0.45
lengthMethod · 0.45
appendMethod · 0.45
firstMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected