Some cppcheck fixes

master
Tomasz Golinski 2023-08-30 22:43:49 +02:00
rodzic 868b62bb2e
commit 2a2a77caf3
7 zmienionych plików z 21 dodań i 21 usunięć

Wyświetl plik

@ -172,11 +172,11 @@ void show_nested_histogram(const pCaches& fcc, std::string Cache::*ptr, std::str
if (own.first.empty()) own.first = "[unknown]";
if (i < HIST_MAX) {
std::map<std::string, int> subhistogram;
std::vector<std::pair<std::string, int>> subpairs;
for (auto el : fcc)
if (el->*ptr == own.first && !(el->*ptr2).empty()) //TODO problem with [unknown]
subhistogram[el->*ptr2]++;
if (!subhistogram.empty()) {
std::vector<std::pair<std::string, int>> subpairs;
std::cout << "<details class=\"nested\"><summary class=\"bar\" style=\"--percent: " << 100 * own.second / max << "%;\"><span class=\"text\">" << own.first << ": " << own.second << "</span></summary>\n";
std::copy(subhistogram.begin(), subhistogram.end(), std::back_inserter(subpairs));
if (sort_by_val)

Wyświetl plik

@ -12,7 +12,7 @@ using json = nlohmann::json;
// using namespace std::literals::string_literals;
OCdb::OCdb(const Service service) {
int res = 0;
int res;
switch (service) {
case ocpl:
@ -271,19 +271,19 @@ bool OCdb::update_log(const json& j) {
return 1;
sql = "INSERT INTO logs (uuid,";
for (auto& i : fields)
for (const auto& i : fields)
sql += i.first + ',';
for (auto& i : fields2)
for (const auto& i : fields2)
sql += i.first + ',';
sql.pop_back();
sql += ") VALUES ('" + uuid + "',";
for (__attribute__((unused)) auto& i : fields)
for (__attribute__((unused)) const auto& i : fields)
sql += "?,";
for (__attribute__((unused)) auto& i : fields2)
for (__attribute__((unused)) const auto& i : fields2)
sql += "?,";
sql.pop_back();
sql += ") ON CONFLICT(uuid) DO UPDATE SET ";
for (auto& i : fields)
for (const auto& i : fields)
sql += i.first + "=excluded." + i.first + ',';
sql.pop_back();
sql += ';';
@ -295,10 +295,10 @@ bool OCdb::update_log(const json& j) {
return 0;
}
int n = 1;
for (auto& i : fields) {
for (const auto& i : fields) {
sqlite3_bind_text(stmt, n++, i.second.c_str(), -1, nullptr);
}
for (auto& i : fields2) {
for (const auto& i : fields2) {
sqlite3_bind_int(stmt, n++, i.second);
}
res = sqlite3_step(stmt);

Wyświetl plik

@ -108,11 +108,11 @@ void Okapi::get_caches_json(const std::string& codes) const {
curl_post(api_service, query);
}
void Okapi::get_caches_ratings_json(const std::string& codes) const {
std::string api_service = url + OKAPI_caches;
std::string query = "consumer_key=" + key + "&cache_codes=" + codes + "&fields=code|recommendations|rating|status";
curl_post(api_service, query);
}
// void Okapi::get_caches_ratings_json(const std::string& codes) const {
// std::string api_service = url + OKAPI_caches;
// std::string query = "consumer_key=" + key + "&cache_codes=" + codes + "&fields=code|recommendations|rating|status";
// curl_post(api_service, query);
// }
// Cache Okapi::get_cache(std::string code) {
// std::string output = get_cache_json(code);
@ -355,10 +355,10 @@ std::string Okapi::get_changelog_json(int revision) const {
}
void Okapi::get_ftf(uint uid, Caches& cc) const {
std::string url = "https://opencaching.pl/UserProfile/getUserFtfsAjax/" + std::to_string(uid);
std::string ftf_url = "https://opencaching.pl/UserProfile/getUserFtfsAjax/" + std::to_string(uid);
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_URL, ftf_url.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "");
curl_output.clear();

Wyświetl plik

@ -23,7 +23,7 @@ private:
void get_user_caches_json(const std::string& uuid, int count = 0, int offset = 0) const;
// std::string get_cache_json(std::string code) const;
void get_caches_json(const std::string& codes) const;
void get_caches_ratings_json(const std::string& codes) const;
// void get_caches_ratings_json(const std::string& codes) const;
const static int MAX_LOGS = 1000;
const static int MAX_CACHES = 500;
@ -43,7 +43,7 @@ private:
constexpr static auto ocuk_url = "https://opencache.uk/okapi/";
public:
Okapi(const Service serv);
explicit Okapi(const Service serv);
~Okapi();
// Cache get_cache(std::string code);

Wyświetl plik

@ -69,7 +69,7 @@ class Caches_in_Powertrails {
public:
std::unordered_map<std::string, int> data;
Caches_in_Powertrails(const PowertrailDB& db);
explicit Caches_in_Powertrails(const PowertrailDB& db);
Caches_in_Powertrails(){};
void read_from_json(std::string file);

Wyświetl plik

@ -198,7 +198,7 @@ void User::prepare_lists_of_caches() {
}
}
void User::header() {
void User::header() const {
if (!ocpl_user.empty())
std::cout << "<img alt=\"OCpl\" src=\"" << flag_pl << "\"> <a href=\"" << ocpl_user_profile << "\">" << ocpl_user << "</a><br>\n";
if (!ocde_user.empty())

2
user.h
Wyświetl plik

@ -64,5 +64,5 @@ public:
void get_caches();
void prepare_lists_of_caches(); // Prepare sorted list of caches, excluding moving caches
void header();
void header() const;
};