• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

llnl / dftracer-utils / 28521653886

01 Jul 2026 01:36PM UTC coverage: 50.92% (-1.4%) from 52.278%
28521653886

Pull #83

github

web-flow
Merge 9bdedb1e9 into 2efed6649
Pull Request #83: refactor and improve code QoL

31893 of 80049 branches covered (39.84%)

Branch coverage included in aggregate %.

789 of 1613 new or added lines in 87 files covered. (48.92%)

5007 existing lines in 181 files now uncovered.

32812 of 47024 relevant lines covered (69.78%)

9905.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.03
/src/dftracer/utils/core/utils/string.cpp
1
#include <dftracer/utils/core/utils/string.h>
2

3
namespace dftracer::utils {
4
namespace {
5
inline bool is_json_ws(char c) {
14,808✔
6
    return c == ' ' || c == '\t' || c == '\n' || c == '\r';
14,808!
7
}
8

9
bool json_trim_impl(const char* data, std::size_t length, const char*& start,
7,405✔
10
                    std::size_t& trimmed_length, bool trim_trailing_comma) {
11
    start = data;
7,405✔
12
    const char* end = data + length - 1;
7,405✔
13

14
    while (start <= end && is_json_ws(*start)) {
7,405!
UNCOV
15
        start++;
×
16
    }
17
    while (end >= start && is_json_ws(*end)) {
7,405!
UNCOV
18
        end--;
×
19
    }
20

21
    // Trailing commas appear in the JSON array format.
22
    if (trim_trailing_comma && end >= start && *end == ',') {
7,405!
23
        end--;
2,028✔
24
    }
2,028✔
25

26
    trimmed_length = (end >= start) ? (end - start + 1) : 0;
7,405!
27

28
    if (trimmed_length == 0 ||
7,405!
29
        (trimmed_length == 1 &&
7,405✔
30
         (*start == '[' || *start == '{' || *start == ']' || *start == '}')) ||
174!
31
        (trimmed_length == 2 && start[0] == ']' && start[1] == '[')) {
7,231!
32
        // Invalid/incomplete JSON or file boundary artifact
33
        return false;
175✔
34
    }
35

36
    return true;
7,232✔
37
}
7,407✔
38
}  // namespace
39

40
bool json_trim_and_validate(const char* data, std::size_t length,
1,745✔
41
                            const char*& start, std::size_t& trimmed_length) {
42
    return json_trim_impl(data, length, start, trimmed_length, false);
1,745✔
43
}
44

45
bool json_trim_and_validate_with_comma(const char* data, std::size_t length,
5,659✔
46
                                       const char*& start,
47
                                       std::size_t& trimmed_length) {
48
    return json_trim_impl(data, length, start, trimmed_length, true);
5,659✔
49
}
50
}  // namespace dftracer::utils
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc