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

llnl / dftracer-utils / 28423703495

30 Jun 2026 05:59AM UTC coverage: 51.998% (-0.3%) from 52.278%
28423703495

Pull #83

github

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

37282 of 93303 branches covered (39.96%)

Branch coverage included in aggregate %.

801 of 1525 new or added lines in 78 files covered. (52.52%)

98 existing lines in 37 files now uncovered.

33674 of 43157 relevant lines covered (78.03%)

20306.85 hits per line

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

82.86
/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) {
29,530✔
6
    return c == ' ' || c == '\t' || c == '\n' || c == '\r';
29,530!
7
}
8

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

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

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

26
    trimmed_length = (end >= start) ? (end - start + 1) : 0;
14,787✔
27

28
    if (trimmed_length == 0 ||
14,787✔
29
        (trimmed_length == 1 &&
14,784✔
30
         (*start == '[' || *start == '{' || *start == ']' || *start == '}')) ||
348!
31
        (trimmed_length == 2 && start[0] == ']' && start[1] == '[')) {
14,436!
32
        // Invalid/incomplete JSON or file boundary artifact
33
        return false;
350✔
34
    }
35

36
    return true;
14,441✔
37
}
7,396✔
38
}  // namespace
39

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

45
bool json_trim_and_validate_with_comma(const char* data, std::size_t length,
11,256✔
46
                                       const char*& start,
47
                                       std::size_t& trimmed_length) {
48
    return json_trim_impl(data, length, start, trimmed_length, true);
11,256✔
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