|
24 | 24 | #include <sstream> |
25 | 25 | #include <string> |
26 | 26 | #include <fstream> |
| 27 | +#include <algorithm> |
27 | 28 |
|
28 | 29 | // Cross-platform includes for process execution |
29 | 30 | #ifdef _WIN32 |
@@ -585,7 +586,7 @@ int main() { |
585 | 586 | { |
586 | 587 | hasSecurityTag = true; |
587 | 588 | } |
588 | | - else if (tagStr.find("external/cwe/cwe-") == 0) |
| 589 | + else if (tagStr.starts_with("external/cwe/cwe-")) |
589 | 590 | { |
590 | 591 | hasCweTag = true; |
591 | 592 | } |
@@ -864,7 +865,7 @@ int main() { |
864 | 865 | { |
865 | 866 | hasSecurityTag = true; |
866 | 867 | } |
867 | | - else if (tagStr.find("external/cwe/cwe-") == 0) |
| 868 | + else if (tagStr.starts_with("external/cwe/cwe-")) |
868 | 869 | { |
869 | 870 | hasCweTag = true; |
870 | 871 | foundAnyCweTag = true; |
@@ -954,14 +955,10 @@ int main() { |
954 | 955 | "variableScope" // Style |
955 | 956 | }; |
956 | 957 |
|
957 | | - int foundExpectedRules = 0; |
958 | | - for (const std::string& expectedRule : expectedRules) |
959 | | - { |
960 | | - if (ruleIds.find(expectedRule) != ruleIds.end()) |
961 | | - { |
962 | | - foundExpectedRules++; |
963 | | - } |
964 | | - } |
| 958 | + int foundExpectedRules = std::count_if(expectedRules.begin(), expectedRules.end(), |
| 959 | + [&ruleIds](const std::string& expectedRule) { |
| 960 | + return ruleIds.find(expectedRule) != ruleIds.end(); |
| 961 | + }); |
965 | 962 |
|
966 | 963 | // We should find at least half of our expected rules |
967 | 964 | ASSERT(foundExpectedRules >= static_cast<int>(expectedRules.size() / 2)); |
@@ -1074,14 +1071,9 @@ int main() { |
1074 | 1071 | if (props.find("tags") != props.end()) |
1075 | 1072 | { |
1076 | 1073 | const picojson::array& tags = props.at("tags").get<picojson::array>(); |
1077 | | - for (const auto& tag : tags) |
1078 | | - { |
1079 | | - if (tag.get<std::string>() == "security") |
1080 | | - { |
1081 | | - hasSecurityTag = true; |
1082 | | - break; |
1083 | | - } |
1084 | | - } |
| 1074 | + hasSecurityTag = std::any_of(tags.begin(), tags.end(), [](const picojson::value& tag) { |
| 1075 | + return tag.get<std::string>() == "security"; |
| 1076 | + }); |
1085 | 1077 | } |
1086 | 1078 | ASSERT(hasSecurityTag); |
1087 | 1079 | } |
|
0 commit comments