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

graphia-app / graphia / 42417955599

07 Nov 2026 08:33PM UTC coverage: 71.51% (+0.07%) from 71.441%
42417955599

push

github

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

11809 of 18066 branches covered (65.37%)

Branch coverage included in aggregate %.

29972 of 40361 relevant lines covered (74.26%)

591425.76 hits per line

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

77.5
/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

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

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

34
    return list;
×
35
}
×
36

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

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

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

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

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

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

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

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

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

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

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

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

95
    return jsonObject;
300 ✔
96
}
300 ✔
97

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

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

105
    _values.clear();
384 ✔
106
    for(const auto& value : jsonObject["values"])
384 ✔
107
        _values.push_back(value); // cppcheck-suppress useStlAlgorithm
2,452 ✔
108

109
    updateType(_values);
384 ✔
110

111
    return true;
384 ✔
112
}
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