diff --git a/.clang-tidy b/.clang-tidy index e5c1ab54..5de3ff80 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -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 } diff --git a/include/ontologenius/core/ontoGraphs/Graphs/Graph.h b/include/ontologenius/core/ontoGraphs/Graphs/Graph.h index 12223f6c..0dc68642 100644 --- a/include/ontologenius/core/ontoGraphs/Graphs/Graph.h +++ b/include/ontologenius/core/ontoGraphs/Graphs/Graph.h @@ -318,7 +318,7 @@ namespace ontologenius { template B* Graph::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; @@ -344,7 +344,7 @@ namespace ontologenius { index_t Graph::getIndex(const std::string& name) { std::shared_lock lock(mutex_); - auto branch = container_.find(name); + auto* branch = container_.find(name); if(branch != nullptr) return branch->get(); else @@ -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 tested; std::random_device rd; diff --git a/src/graphical/ontoloGUI/DarkStyle.cpp b/src/graphical/ontoloGUI/DarkStyle.cpp index 91976a37..c59eeff1 100644 --- a/src/graphical/ontoloGUI/DarkStyle.cpp +++ b/src/graphical/ontoloGUI/DarkStyle.cpp @@ -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_; } @@ -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 diff --git a/src/tests/CI/library.cpp b/src/tests/CI/library.cpp index ef87f7a8..9684ae29 100644 --- a/src/tests/CI/library.cpp +++ b/src/tests/CI/library.cpp @@ -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 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 res = onto_ptr->individuals.getUp(test_word); res_bool = res_bool && ((res.size() != 1) || (res[0] != "ERR:SERVICE_FAIL")); } @@ -32,13 +29,12 @@ TEST(library_tests, individuals_call) TEST(library_tests, objectProperties_call) { - std::vector 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 res = onto_ptr->objectProperties.getUp(test_word); res_bool = res_bool && ((res.size() != 1) || (res[0] != "ERR:SERVICE_FAIL")); } @@ -47,13 +43,12 @@ TEST(library_tests, objectProperties_call) TEST(library_tests, dataProperties_call) { - std::vector 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 res = onto_ptr->dataProperties.getUp(test_word); res_bool = res_bool && ((res.size() != 1) || (res[0] != "ERR:SERVICE_FAIL")); } diff --git a/src/tests/Performances/container_test.cpp b/src/tests/Performances/container_test.cpp index 844a71f2..c3b44f9e 100644 --- a/src/tests/Performances/container_test.cpp +++ b/src/tests/Performances/container_test.cpp @@ -3,6 +3,7 @@ #include #include /* srand, rand */ #include /* time */ +#include #include #include #include @@ -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 vect = creatTestVector(j, part_of_words); double time_span_dyn = findAllNTime(&container_dyn, vect, nb); diff --git a/src/tests/Performances/deepcopy.cpp b/src/tests/Performances/deepcopy.cpp index f5f27c9a..3b949ac9 100644 --- a/src/tests/Performances/deepcopy.cpp +++ b/src/tests/Performances/deepcopy.cpp @@ -3,8 +3,10 @@ #include /* time */ #include #include +#include #include "ontologenius/API/ontologenius/OntologiesManipulator.h" +#include "ontologenius/API/ontologenius/OntologyManipulator.h" using namespace std::chrono; diff --git a/src/tests/Performances/getNameVsFind.cpp b/src/tests/Performances/getNameVsFind.cpp index 3994be72..04865c87 100644 --- a/src/tests/Performances/getNameVsFind.cpp +++ b/src/tests/Performances/getNameVsFind.cpp @@ -4,7 +4,9 @@ #include #include /* srand, rand */ #include +#include #include +#include #include #include diff --git a/src/tests/Performances/tester.cpp b/src/tests/Performances/tester.cpp index 38f699b9..9301549a 100644 --- a/src/tests/Performances/tester.cpp +++ b/src/tests/Performances/tester.cpp @@ -1,14 +1,15 @@ #include #include /* srand, rand */ #include /* time */ +#include #include #include #include #include +#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; @@ -20,56 +21,56 @@ std::string set2string(const std::unordered_set& word_set) return result; } -std::vector generate_sequence(ontologenius::ClassGraph& onto) +std::vector generateSequence(ontologenius::ClassGraph& onto) { srand(time(nullptr)); std::vector 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 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 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(); @@ -78,9 +79,9 @@ std::vector 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; } @@ -89,7 +90,7 @@ double testOne(const std::vector& 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 out = onto.class_graph_.getUp(s); high_resolution_clock::time_point t2 = high_resolution_clock::now(); @@ -138,7 +139,7 @@ int main(int argc, char** argv) /*int epoch = 10000; - std::vector seq = generate_sequence(onto.class_graph_); + std::vector seq = generateSequence(onto.class_graph_); double total = 0; for(int i = 0; i < epoch; i++) { diff --git a/src/tests/sparql.cpp b/src/tests/sparql.cpp index d667b734..cdcb17c9 100644 --- a/src/tests/sparql.cpp +++ b/src/tests/sparql.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -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 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); @@ -65,7 +63,7 @@ void compareSolutions(const std::vector>& 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;