Commit e75318f
abacus_fixer
Add post-C++11 rule (-80); expand test dirs; fix string-literal false matches
This commit extends tools/03_code_analysis/code_quality_score.py with one
new scoring rule, expands the test-file exclusion list, and fixes a
critical class of false positives for keyword-based rules.
1. New rule: post_cpp11_feature (-80, one-shot per file)
The ABACUS project keeps a C++11 baseline (see AGENTS.md § Required
Baseline rule 7). Any newer syntax is a compilation risk on older
compilers, so a one-shot -80 deduction is applied when any of the
following high-confidence, low-false-positive patterns is seen:
C++14 std::make_unique<T>(...)
digit separator in numeric literals (1'000'000)
C++17 if constexpr (...)
structured binding auto [a, b] = ...;
fold expressions (args + ...), (... + args), etc.
std::optional<T>, std::variant<T,U>, std::any
[[nodiscard]], [[maybe_unused]] attributes
C++20 concept / requires / consteval / constinit
coroutine keywords: co_await, co_yield, co_return
std::span<T>, std::ranges::*, std::format(...)
C++23 std::expected<T,E>, std::print(...), std::println(...)
Detection uses a list of (label, compiled_regex) pairs defined in
POST_CPP11_PATTERNS. A single Finding is emitted per file listing all
distinct features and their line numbers so the report is actionable.
2. Test directory exclusion: add "test_serial" to SKIP_DIRS
The exclusion set previously contained {test, tests, test_parallel,
unit_test, unittest} but missed test_serial/ under source_io and
source_base; nine files leaked into score summaries. Now skipped.
3. False-positive fix: introduce strip_strings() helper
strip_comments() erases comments but preserves string literals on
purpose (brace-matching parsers later rely on the real quote
boundaries). That meant keyword-based rules (e.g. the C++20 requires
regex) matched ordinary words inside user-facing strings such as
WARNING_QUIT("... eigensolver requires replicated ...").
The new strip_strings() function walks through content character by
character, tracks "... " and '...' modes, and replaces every
character inside quotes with a space (newlines are preserved so line
numbers stay correct). find_post_cpp11_features() now runs on
strip_strings(strip_comments(content)) — the double pass eliminates
string-literal false matches while still catching real keywords.
4. Results on source/ (1643 files, excluding test dirs):
- Avg score: 79.1 (previous scan w/ buggy version: 78.6)
- Pass rate (>=60): 1348/1643 = 82.0%
- post_cpp11_feature triggered on exactly 1 file after the fix:
source/source_hsolver/diago_pexsi.cpp -> std::make_unique (C++14)
The previous 16 files flagged as "requires (C++20)" were all
string-literal false matches and are now correctly cleared.1 parent c0b9ce7 commit e75318f
1 file changed
Lines changed: 215 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
| |||
56 | 61 | | |
57 | 62 | | |
58 | 63 | | |
59 | | - | |
| 64 | + | |
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
| |||
94 | 99 | | |
95 | 100 | | |
96 | 101 | | |
| 102 | + | |
97 | 103 | | |
98 | 104 | | |
99 | 105 | | |
| |||
166 | 172 | | |
167 | 173 | | |
168 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
169 | 272 | | |
170 | 273 | | |
171 | 274 | | |
| |||
285 | 388 | | |
286 | 389 | | |
287 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
288 | 462 | | |
289 | 463 | | |
290 | 464 | | |
| |||
644 | 818 | | |
645 | 819 | | |
646 | 820 | | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
647 | 845 | | |
648 | 846 | | |
649 | 847 | | |
| |||
907 | 1105 | | |
908 | 1106 | | |
909 | 1107 | | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
910 | 1124 | | |
911 | 1125 | | |
912 | 1126 | | |
| |||
0 commit comments