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

graphia-app / graphia / 42502562509

08 Nov 2026 04:57PM UTC coverage: 71.457% (-0.05%) from 71.51%
42502562509

push

github

timangus
CLAUDE: Suppress cppcheck's duplInheritedMember check and drop NodePositions' second mutex

11725 of 17974 branches covered (65.23%)

Branch coverage included in aggregate %.

29934 of 40325 relevant lines covered (74.23%)

375397.35 hits per line

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

76.92
/source/shared/loading/userdatavector.cpp
1
/* Copyright © 2013-2025 Tim Angus
2
 * Copyright © 2013-2025 Tom Freeman
3
 *
4
 * This file is part of Graphia.
5
 *
6
 * Graphia is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * Graphia is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with Graphia.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19

20
#include "userdatavector.h"
21

22
#include "shared/utils/json.h"
23

24
#include <algorithm>
25
#include <iterator>
26

27
QStringList UserDataVector::toStringList() const
28
{
×
29
    QStringList list;
×
30
    list.reserve(static_cast<int>(numValues()));
×
31

32
    for(const auto& value : _values)
×
33
        list.append(value);
×
34

35
    return list;
×
36
}
×
37

38
size_t UserDataVector::numUniqueValues() const
39
{
×
40
    auto v = _values;
×
41
    std::ranges::sort(v);
×
42
    auto last = std::ranges::unique(v);
×
43
    // cppcheck-suppress mismatchingContainerExpression
44
    v.erase(last.begin(), v.end());
×
45

46
    return v.size();
×
47
}
×
48

49
bool UserDataVector::set(size_t index, const QString& value)
50
{
13,284 ✔
51
    bool changed = false;
13,284 ✔
52

53
    if(index >= _values.size())
13,284 ✔
54
    {
13,074 ✔
55
        _values.resize(index + 1);
13,074 ✔
56
        changed = true;
13,074 ✔
57
    }
13,074 ✔
58

59
    auto& previousValue = _values.at(index);
13,284 ✔
60
    changed = changed || (previousValue != value);
13,284 ✔
61
    updateType(value, previousValue);
13,284 ✔
62
    previousValue = value;
13,284 ✔
63

64
    return changed;
13,284 ✔
65
}
13,284 ✔
66

67
QString UserDataVector::get(size_t index) const
68
{
55,516 ✔
69
    if(index >= _values.size())
55,516 ✔
70
        return {};
278 ✔
71

72
    return _values.at(index);
55,238 ✔
73
}
55,516 ✔
74

75
json UserDataVector::save(const std::vector<size_t>& indexes) const
76
{
300 ✔
77
    json jsonObject;
300 ✔
78

79
    if(!indexes.empty())
300 ✔
80
    {
216 ✔
81
        json jsonValues = json::array();
216 ✔
82

83
        for(auto index : indexes)
216 ✔
84
        {
1,014 ✔
85
            if(index < _values.size())
1,014 ✔
86
                jsonValues.push_back(_values.at(index));
1,012 ✔
87
            else
2 ✔
88
                jsonValues.push_back(QString());
2 ✔
89
        }
1,014 ✔
90

91
        jsonObject["values"] = jsonValues;
216 ✔
92
    }
216 ✔
93
    else
84 ✔
94
        jsonObject["values"] = _values;
84 ✔
95

96
    return jsonObject;
300 ✔
97
}
300 ✔
98

99
bool UserDataVector::load(const QString& name, const json& jsonObject)
100
{
384 ✔
101
    _name = name;
384 ✔
102

103
    if(!jsonObject["values"].is_array())
384 !
104
        return false;
×
105

106
    _values.clear();
384 ✔
107
    std::ranges::transform(jsonObject["values"], std::back_inserter(_values),
384 ✔
108
        [](const json& value) { return value.get<QString>(); });
2,452 ✔
109

110
    updateType(_values);
384 ✔
111

112
    return true;
384 ✔
113
}
384 ✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc