Skip to content

Commit

Permalink
[clang-tidy] fix for ROS1
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthou committed Jun 11, 2024
1 parent 832fe21 commit 56a8fc5
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 52 deletions.
3 changes: 1 addition & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ Checks: >
readability-simplify-subscript-expr,
readability-string-compare,
readability-use-std-min-max
WarningsAsErrors: "*"
HeaderFilterRegex: 'include/*'
HeaderFilterRegex: 'ontologenius/include/ontologenius/*'
CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
Expand Down
6 changes: 3 additions & 3 deletions include/ontologenius/core/ontoGraphs/Graphs/Graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ namespace ontologenius {
template<typename B>
B* Graph<B>::newDefaultBranch(const std::string& name)
{
auto branch = new B(name);
auto* branch = new B(name);
all_branchs_.push_back(branch);
container_.insert(branch);
return branch;
Expand All @@ -344,7 +344,7 @@ namespace ontologenius {
index_t Graph<B>::getIndex(const std::string& name)
{
std::shared_lock<std::shared_timed_mutex> lock(mutex_);
auto branch = container_.find(name);
auto* branch = container_.find(name);
if(branch != nullptr)
return branch->get();
else
Expand Down Expand Up @@ -442,7 +442,7 @@ namespace ontologenius {
{
if(branch->dictionary_.spoken_.find(language_) != branch->dictionary_.spoken_.end())
{
if(branch->dictionary_.spoken_[language_].size())
if(branch->dictionary_.spoken_[language_].empty() == false)
{
std::unordered_set<size_t> tested;
std::random_device rd;
Expand Down
4 changes: 2 additions & 2 deletions src/graphical/ontoloGUI/DarkStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ DarkStyle::DarkStyle(QStyle* style) : QProxyStyle(style)

QStyle* DarkStyle::styleBase(QStyle* style) const
{
static QStyle* base_ = (style == nullptr) ? QStyleFactory::create(QStringLiteral("Fusion")) : style;
static QStyle* base_ = (style == nullptr) ? QStyleFactory::create(QStringLiteral("Fusion")) : style; // NOLINT
return base_;
}

Expand Down Expand Up @@ -81,7 +81,7 @@ void DarkStyle::polish(QApplication* app)
QApplication::setFont(default_font);

// loadstylesheet
QFile qf_darkstyle(QStringLiteral(":/darkstyle/darkstyle.qss"));
QFile qf_darkstyle(QStringLiteral(":/darkstyle/darkstyle.qss")); // NOLINT
if(qf_darkstyle.open(QIODevice::ReadOnly | QIODevice::Text))
{
// set stylesheet
Expand Down
13 changes: 4 additions & 9 deletions src/tests/CI/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,18 @@ onto::OntologyManipulator* onto_ptr;

TEST(library_tests, close_call)
{
bool res_bool;

res_bool = onto_ptr->close();
bool res_bool = onto_ptr->close();
EXPECT_TRUE(res_bool);
}

TEST(library_tests, individuals_call)
{
std::vector<std::string> res;
std::string test_word = "test";
bool res_bool = true;

for(size_t i = 0; i < 10; i++)
{
res = onto_ptr->individuals.getUp(test_word);
std::vector<std::string> res = onto_ptr->individuals.getUp(test_word);
res_bool = res_bool && ((res.size() != 1) || (res[0] != "ERR:SERVICE_FAIL"));
}

Expand All @@ -32,13 +29,12 @@ TEST(library_tests, individuals_call)

TEST(library_tests, objectProperties_call)
{
std::vector<std::string> res;
std::string test_word = "test";
bool res_bool = true;

for(size_t i = 0; i < 10; i++)
{
res = onto_ptr->objectProperties.getUp(test_word);
std::vector<std::string> res = onto_ptr->objectProperties.getUp(test_word);
res_bool = res_bool && ((res.size() != 1) || (res[0] != "ERR:SERVICE_FAIL"));
}

Expand All @@ -47,13 +43,12 @@ TEST(library_tests, objectProperties_call)

TEST(library_tests, dataProperties_call)
{
std::vector<std::string> res;
std::string test_word = "test";
bool res_bool = true;

for(size_t i = 0; i < 10; i++)
{
res = onto_ptr->dataProperties.getUp(test_word);
std::vector<std::string> res = onto_ptr->dataProperties.getUp(test_word);
res_bool = res_bool && ((res.size() != 1) || (res[0] != "ERR:SERVICE_FAIL"));
}

Expand Down
3 changes: 2 additions & 1 deletion src/tests/Performances/container_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cstdio>
#include <cstdlib> /* srand, rand */
#include <ctime> /* time */
#include <iostream>
#include <ros/ros.h>
#include <string>
#include <vector>
Expand Down Expand Up @@ -167,7 +168,7 @@ int main(int argc, char** argv)
container_dyn.load(part_of_words);
container_map.load(part_of_words);

for(float j = 0.1; j <= 2; j = j + 0.1)
for(float j = 0.1f; j <= 2; j = j + 0.1f)
{
std::vector<ontologenius::ValuedNode*> vect = creatTestVector(j, part_of_words);
double time_span_dyn = findAllNTime(&container_dyn, vect, nb);
Expand Down
2 changes: 2 additions & 0 deletions src/tests/Performances/deepcopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#include <ctime> /* time */
#include <iostream>
#include <ros/ros.h>
#include <string>

#include "ontologenius/API/ontologenius/OntologiesManipulator.h"
#include "ontologenius/API/ontologenius/OntologyManipulator.h"

using namespace std::chrono;

Expand Down
2 changes: 2 additions & 0 deletions src/tests/Performances/getNameVsFind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include <cstdio>
#include <cstdlib> /* srand, rand */
#include <ctime>
#include <iostream>
#include <ros/ros.h>
#include <string>
#include <thread>
#include <unordered_set>

Expand Down
61 changes: 31 additions & 30 deletions src/tests/Performances/tester.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include <chrono>
#include <cstdlib> /* srand, rand */
#include <ctime> /* time */
#include <iostream>
#include <ros/ros.h>
#include <string>
#include <unordered_set>
#include <vector>

#include "ontologenius/core/ontoGraphs/Branchs/ClassBranch.h"
#include "ontologenius/core/ontoGraphs/Ontology.h"
#include "ontologenius/core/reasoner/Reasoners.h"
#include "ontologenius/core/ontoGraphs/Branchs/ClassBranch.h"

using namespace std::chrono;

Expand All @@ -20,56 +21,56 @@ std::string set2string(const std::unordered_set<std::string>& word_set)
return result;
}

std::vector<std::string> generate_sequence(ontologenius::ClassGraph& onto)
std::vector<std::string> generateSequence(ontologenius::ClassGraph& onto)
{
srand(time(nullptr));

std::vector<ontologenius::ClassBranch*> base = onto.get();
size_t max_index = base.size();

std::string _1_10_1 = base[rand() % max_index]->value();
std::string _1_10_2 = base[rand() % max_index]->value();
std::string seq_1_10_1 = base[rand() % max_index]->value();
std::string seq_1_10_2 = base[rand() % max_index]->value();

std::string _1_20_1 = base[rand() % max_index]->value();
std::string _1_20_2 = base[rand() % max_index]->value();
std::string seq_1_20_1 = base[rand() % max_index]->value();
std::string seq_1_20_2 = base[rand() % max_index]->value();

std::string _1_25_1 = base[rand() % max_index]->value();
std::string _1_25_2 = base[rand() % max_index]->value();
std::string _1_25_3 = base[rand() % max_index]->value();
std::string seq_1_25_1 = base[rand() % max_index]->value();
std::string seq_1_25_2 = base[rand() % max_index]->value();
std::string seq_1_25_3 = base[rand() % max_index]->value();

std::string _1_50_1 = base[rand() % max_index]->value();
std::string _1_50_2 = base[rand() % max_index]->value();
std::string _1_50_3 = base[rand() % max_index]->value();
std::string _1_50_4 = base[rand() % max_index]->value();
std::string _1_50_5 = base[rand() % max_index]->value();
std::string seq_1_50_1 = base[rand() % max_index]->value();
std::string seq_1_50_2 = base[rand() % max_index]->value();
std::string seq_1_50_3 = base[rand() % max_index]->value();
std::string seq_1_50_4 = base[rand() % max_index]->value();
std::string seq_1_50_5 = base[rand() % max_index]->value();

std::vector<std::string> vect20;
vect20.resize(10);
vect20[0] = _1_10_1;
vect20[1] = _1_10_2;
vect20[0] = seq_1_10_1;
vect20[1] = seq_1_10_2;
vect20.insert(vect20.end(), vect20.begin(), vect20.end()); // 20
vect20[2] = _1_20_1;
vect20[12] = _1_20_2;
vect20[2] = seq_1_20_1;
vect20[12] = seq_1_20_2;
std::vector<std::string> vect100 = vect20;
vect100.insert(vect100.end(), vect20.begin(), vect20.end()); // 40
vect100.insert(vect100.end(), vect20.begin(), vect20.end()); // 60
vect100.insert(vect100.end(), vect20.begin(), vect20.end()); // 80
vect100.insert(vect100.end(), vect20.begin(), vect20.end()); // 100
for(int i = 3; i < 100; i += 25)
vect100[i] = _1_25_1;
vect100[i] = seq_1_25_1;
for(int i = 13; i < 100; i += 25)
vect100[i] = _1_25_2;
vect100[i] = seq_1_25_2;
for(int i = 23; i < 100; i += 25)
vect100[i] = _1_25_3;
vect100[i] = seq_1_25_3;

for(int i = 33; i < 100; i += 50)
vect100[i] = _1_50_1;
vect100[i] = seq_1_50_1;
for(int i = 43; i < 100; i += 50)
vect100[i] = _1_50_2;
vect100[i] = seq_1_50_2;
for(int i = 4; i < 100; i += 50)
vect100[i] = _1_50_3;
vect100[i] = seq_1_50_3;
for(int i = 14; i < 100; i += 50)
vect100[i] = _1_50_4;
vect100[i] = seq_1_50_4;

vect100[24] = base[rand() % max_index]->value();
vect100[34] = base[rand() % max_index]->value();
Expand All @@ -78,9 +79,9 @@ std::vector<std::string> generate_sequence(ontologenius::ClassGraph& onto)
for(int i = 0; i < 100; i++)
vect10000.insert(vect10000.end(), vect100.begin(), vect100.end());

for(size_t i = 0; i < vect10000.size(); i++)
if(vect10000[i].empty())
vect10000[i] = base[rand() % max_index]->value();
for(auto& vect : vect10000)
if(vect.empty())
vect = base[rand() % max_index]->value();

return vect10000;
}
Expand All @@ -89,7 +90,7 @@ double testOne(const std::vector<std::string>& seq, ontologenius::Ontology& onto
{
high_resolution_clock::time_point t1 = high_resolution_clock::now();

for(auto& s : seq)
for(const auto& s : seq)
std::unordered_set<std::string> out = onto.class_graph_.getUp(s);

high_resolution_clock::time_point t2 = high_resolution_clock::now();
Expand Down Expand Up @@ -138,7 +139,7 @@ int main(int argc, char** argv)

/*int epoch = 10000;
std::vector<std::string> seq = generate_sequence(onto.class_graph_);
std::vector<std::string> seq = generateSequence(onto.class_graph_);
double total = 0;
for(int i = 0; i < epoch; i++)
{
Expand Down
8 changes: 3 additions & 5 deletions src/tests/sparql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <execinfo.h>
#include <iostream>
#include <string>
Expand All @@ -17,16 +18,13 @@
#include "ontologenius/core/ontoGraphs/Ontology.h"
#include "ontologenius/core/ontologyOperators/SparqlSolver.h"
#include "ontologenius/interface/RosInterface.h"
#include "time.h"

using namespace std::chrono;

void handler(int sig)
{
std::array<void*, 10> array;
size_t size;

size = backtrace(array.data(), 10);
size_t size = backtrace(array.data(), 10);

fprintf(stderr, "Error: signal %d:\n", sig);
backtrace_symbols_fd(array.data(), size, STDERR_FILENO);
Expand Down Expand Up @@ -65,7 +63,7 @@ void compareSolutions(const std::vector<std::map<std::string, std::string>>& sol
nb_diff++;
}

if(nb_diff)
if(nb_diff != 0)
std::cout << "[ERROR] " << nb_diff << " solutions where not identicals" << std::endl;
else
std::cout << "[SUCCESS]" << std::endl;
Expand Down

0 comments on commit 56a8fc5

Please sign in to comment.