{ "tokens": { "input": 12285, "cache_read": 22026, "cache_write": 66078, "output": 2982 }, "reviews": [ { "key": [ "https://ftp.debian.org/debian/pool/main/0/0ad/0ad_0.28.0.orig.tar.xz", "your 0ad-0.28.0/source/third_party/tinygettext/src/po_parser.cpp:319:9: style: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The PR now recognizes `std::string::iterator` as an iterator type. Because of that, the useStlAlgorithm check now sees the raw loop over `current_line` from `begin()` to `end()`. The loop returns false as soon as it finds a non-space character, so it can be written as `if (std::any_of(..., [](char c){ return !isspace(c); })) return false;` (or with `all_of`). Cppcheck already reports this same suggestion for loops over `std::vector::iterator`, so the new message is a valid style hint that was previously missed." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/b/blahtexml/blahtexml_1.0.orig.tar.gz", "your blahtexml-1.0/Source/BlahtexCore/LayoutTree.cpp:1300:13: style: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "The loop walks a std::wstring with a wstring::const_iterator and returns false as soon as a character is not a plain Latin letter, otherwise true. That is exactly the any_of/all_of pattern. Before this PR, wstring::const_iterator was not recognized as an iterator, so the useStlAlgorithm check skipped this loop. Now the iterator type is detected and the check fires, just as it already does for iterator loops over templated containers like std::vector::const_iterator. The suggestion is a valid style hint (std::all_of would be slightly more natural, but std::any_of also works), so this is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/d/dar/dar_2.8.5.orig.tar.gz", "your dar-2.8.5/src/dar_suite/line_tools.cpp:903:56: style: Parameter 's' can be declared as reference to const [constParameterReference]" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "The function stores `s.begin()` in a non-const `string::iterator` and returns it. If `s` were `const std::string&`, `s.begin()` would return a `const_iterator`, which cannot convert to `string::iterator`, so the code would not compile. The suggestion to make `s` a reference to const is therefore a false positive. It appears because the PR now gives `std::string::iterator` an iterator value type, but the const-parameter check does not treat taking a mutable iterator as a non-const use of the container." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/d/dar/dar_2.8.5.orig.tar.gz", "your dar-2.8.5/src/dar_suite/line_tools.cpp:913:56: style: Parameter 's' can be declared as reference to const [constParameterReference]" ], "verdict": { "verdict": "regression", "confidence": "high", "explanation": "The function returns a mutable `string::iterator` and stores `s.end()` and `s.begin()` in `string::iterator` variables. If `s` were `const std::string&`, `begin()` and `end()` would return `const_iterator`, which does not convert to `string::iterator`, so the code would not compile. The parameter cannot be made const, and the new constParameterReference warning is a false positive. It appears because the PR now gives `std::string::iterator` an iterator value type, and the constness analysis does not account for a mutable iterator being taken from the container." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/libn/libncl/libncl_2.1.21+git20210811.b1213a7.orig.tar.xz", "your libncl-2.1.21+git20210811.b1213a7/ncl/nxscharactersblock.cpp:1620:4: style: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The PR now gives std::string::const_iterator a proper iterator value type, so the useStlAlgorithm check recognises this iterator loop. The loop walks over augmentSymbols and returns false as soon as one character is not a digit. That is exactly an any_of/all_of pattern, so the style suggestion is a valid new true positive. A purist might argue that std::all_of is the more natural fit here, but suggesting any_of for this early-return pattern is the check's existing, consistent behaviour." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/libw/libwibble/libwibble_1.1.orig.tar.gz", "your libwibble-1.1/wibble/commandline/options.cpp:34:4: style: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "With the PR, `string::const_iterator` is recognised as an iterator of std::string, so the explicit iterator loop is now analysed the same way as loops over vector iterators. The loop throws as soon as any character fails `isdigit`. That is exactly an any_of (or all_of) pattern: `if (std::any_of(val.begin(), val.end(), [](char c){ return !isdigit(c); })) throw ...`. The new style suggestion is valid and is the same one Cppcheck already gives for other containers, so it is a new true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/m/mstflint/mstflint_4.33.0+1.orig.tar.gz", "your mstflint-4.33.0/flint/cmd_line_parser.cpp:329:13: style: Consider using std::count_if algorithm instead of a raw loop. [useStlAlgorithm]" ], "verdict": { "verdict": "improvement", "confidence": "high", "explanation": "The PR teaches Cppcheck that std::string::iterator is an iterator. With that, the loop over args.begin()..args.end() is recognized as an iterator loop. The loop only increments count when *it == ','. That is exactly std::count(args.begin(), args.end(), ','), so the useStlAlgorithm style suggestion is valid. Suggesting count_if instead of count is slightly imprecise, but this is the usual wording of this check. The new warning is a true positive." } }, { "key": [ "https://ftp.debian.org/debian/pool/main/s/spring/spring_106.0+dfsg.orig.tar.xz", "your spring-106.0/rts/lib/assimp/code/ColladaLoader.cpp:1551:33: style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm]" ], "verdict": { "verdict": "improvement", "confidence": "medium", "explanation": "The loop walks a std::string with a std::string::const_iterator, finds the first character where IsNumeric(*it) is true, uses that element and breaks. That is the find_if pattern: `auto it = std::find_if(s.begin(), s.end(), IsNumeric); if (it != s.end()) map = strtoul10(&*it);`. Before the PR, std::string::const_iterator was not recognized as an iterator, so this loop was skipped. The same loop over a std::vector iterator would already get this warning. The new style warning is therefore a consistent, valid suggestion (a true positive)." } } ], "started": "2026-11-17 20:06:50 UTC", "runner": "aws-testrunner-2" }