kopia lustrzana https://gitlab.com/tomaszg/geostat
Trivial cppcheck fixes
rodzic
48e43613d1
commit
26d3bc56d2
|
@ -66,7 +66,7 @@ void show_histogram(const Caches& cc, std::string Cache::*ptr, const std::string
|
|||
|
||||
std::map<std::string, int> histogram;
|
||||
|
||||
for (auto el : cc)
|
||||
for (const auto& el : cc)
|
||||
histogram[el.*ptr]++;
|
||||
|
||||
show_histogram(histogram, caption, html, sort_by_val);
|
||||
|
@ -346,7 +346,7 @@ void footer_html() {
|
|||
|
||||
Position Cache::home;
|
||||
|
||||
Position::Position(std::string loc) {
|
||||
Position::Position(const std::string& loc) {
|
||||
int pos = loc.find("|");
|
||||
lat = stof(loc.substr(0, pos));
|
||||
lon = stof(loc.substr(pos + 1));
|
||||
|
|
2
common.h
2
common.h
|
@ -67,7 +67,7 @@ public:
|
|||
|
||||
Position() = default;
|
||||
Position(float y, float x) : lat(y), lon(x) {}
|
||||
explicit Position(std::string loc);
|
||||
explicit Position(const std::string& loc);
|
||||
};
|
||||
|
||||
float cache_distance(const Cache& a, const Cache& b);
|
||||
|
|
10
geostat.cpp
10
geostat.cpp
|
@ -244,7 +244,7 @@ int main(int argc, char** argv) {
|
|||
long max = 0; // maximal value for histogram
|
||||
for (int i = y_min; i <= y_max; i++)
|
||||
for (int j = 1; j <= 12; j++)
|
||||
max = std::max(max, std::count_if(user.cc.begin(), user.cc.end(), [i, j](Cache c) { return (c.date_tm.tm_year == i && c.date_tm.tm_mon == j - 1); }));
|
||||
max = std::max(max, std::count_if(user.cc.begin(), user.cc.end(), [i, j](const Cache& c) { return (c.date_tm.tm_year == i && c.date_tm.tm_mon == j - 1); }));
|
||||
|
||||
if (max > 0) {
|
||||
std::cout << "<h2>Caching timeline</h2>\n";
|
||||
|
@ -258,7 +258,7 @@ int main(int argc, char** argv) {
|
|||
for (int i = y_min; i <= y_max; i++) { // i -> years in rows
|
||||
std::cout << "<tr><th>" << i + 1900 << "</th> ";
|
||||
for (int j = 1; j <= 12; j++) { // j -> months in cols
|
||||
count = std::count_if(user.cc.begin(), user.cc.end(), [i, j](Cache c) { return (c.date_tm.tm_year == i && c.date_tm.tm_mon == j - 1); });
|
||||
count = std::count_if(user.cc.begin(), user.cc.end(), [i, j](const Cache& c) { return (c.date_tm.tm_year == i && c.date_tm.tm_mon == j - 1); });
|
||||
std::cout << "<td style=\"--percent: " << count * 100 / max << "%\"><span>" << count << "</span></td>";
|
||||
}
|
||||
std::cout << "</tr>\n";
|
||||
|
@ -280,7 +280,7 @@ int main(int argc, char** argv) {
|
|||
std::cout << "<tr><th>" << i + 1900 << "</th> ";
|
||||
for (int j = 1; j <= 12; j++) { // j -> months in cols
|
||||
std::map<int, int> days_count;
|
||||
for (auto el : user.cc) {
|
||||
for (const auto& el : user.cc) {
|
||||
if (el.date_tm.tm_mon == j - 1 && el.date_tm.tm_year == i)
|
||||
days_count[el.date_tm.tm_mday]++;
|
||||
}
|
||||
|
@ -779,7 +779,7 @@ int main(int argc, char** argv) {
|
|||
long max = 0; // maximal value for histogram
|
||||
for (int i = y_min; i <= y_max; i++)
|
||||
for (int j = 1; j <= 12; j++)
|
||||
max = std::max(max, std::count_if(user.cc.begin(), user.cc.end(), [i, j](Cache c) { return (c.date_hidden_tm.tm_year == i && c.date_hidden_tm.tm_mon == j - 1); }));
|
||||
max = std::max(max, std::count_if(user.cc.begin(), user.cc.end(), [i, j](const Cache& c) { return (c.date_hidden_tm.tm_year == i && c.date_hidden_tm.tm_mon == j - 1); }));
|
||||
|
||||
if (max > 0) {
|
||||
std::cout << "<h2>Cache creation timeline</h2>\n";
|
||||
|
@ -792,7 +792,7 @@ int main(int argc, char** argv) {
|
|||
for (int i = y_min; i <= y_max; i++) { // i -> years in rows
|
||||
std::cout << "<tr><th>" << i + 1900 << "</th> ";
|
||||
for (int j = 1; j <= 12; j++) { // j -> months in cols
|
||||
count = std::count_if(user.cc.begin(), user.cc.end(), [i, j](Cache c) { return (c.date_hidden_tm.tm_year == i && c.date_hidden_tm.tm_mon == j - 1); });
|
||||
count = std::count_if(user.cc.begin(), user.cc.end(), [i, j](const Cache& c) { return (c.date_hidden_tm.tm_year == i && c.date_hidden_tm.tm_mon == j - 1); });
|
||||
std::cout << "<td style=\"--percent: " << count * 100 / max << "%\"><span>" << count << "</span></td>";
|
||||
}
|
||||
std::cout << "</tr>\n";
|
||||
|
|
|
@ -260,7 +260,7 @@ int main(int argc, char** argv) {
|
|||
for (int i = 2; i <= 10; i++) { // i -> diff in rows
|
||||
std::cout << std::setw(5) << i / 2.0;
|
||||
for (int j = 2; j <= 10; j++) { // j -> terr in cols
|
||||
dt_table[i][j] = std::count_if(user.cc.begin(), user.cc.end(), [i, j](Cache c) { return (c.diff == i / 2.0 && c.terr == j / 2.0); });
|
||||
dt_table[i][j] = std::count_if(user.cc.begin(), user.cc.end(), [i, j](const Cache& c) { return (c.diff == i / 2.0 && c.terr == j / 2.0); });
|
||||
std::cout << std::setw(5) << dt_table[i][j];
|
||||
}
|
||||
std::cout << '\n';
|
||||
|
@ -268,7 +268,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
} else {
|
||||
if (show_list) {
|
||||
for (auto el : user.cc)
|
||||
for (const auto& el : user.cc)
|
||||
el.show();
|
||||
}
|
||||
}
|
||||
|
|
2
ocdb.cpp
2
ocdb.cpp
|
@ -485,7 +485,7 @@ std::map<std::string, int> OCdb::get_region_stats() {
|
|||
throw 0;
|
||||
}
|
||||
|
||||
for (auto reg : regions) {
|
||||
for (const auto& reg : regions) {
|
||||
sqlite3_bind_text(stmt, 1, reg.c_str(), -1, nullptr);
|
||||
res = sqlite3_step(stmt);
|
||||
if (res != SQLITE_ROW) {
|
||||
|
|
7
user.cpp
7
user.cpp
|
@ -212,3 +212,10 @@ void User::header() const {
|
|||
if (!ocuk_user.empty())
|
||||
std::cout << "<img alt=\"OCuk\" src=\"" << flag_uk << "\"> <a href=\"" << ocuk_user_profile << "\">" << ocuk_user << "</a><br>\n";
|
||||
}
|
||||
|
||||
std::string User::user_link(std::string name) const {
|
||||
if (!ocpl_user_uuid.empty())
|
||||
return "<a href=\"/cgi-bin/geofr-form.pl?nick_pl1=" + ocpl_user + "&nick_pl2=" + name + "\">" + name + "</a>";
|
||||
else
|
||||
return name;
|
||||
}
|
||||
|
|
2
user.h
2
user.h
|
@ -65,4 +65,6 @@ public:
|
|||
void prepare_lists_of_caches(); // Prepare sorted list of caches, excluding moving caches
|
||||
|
||||
void header() const;
|
||||
|
||||
std::string user_link(std::string name) const;
|
||||
};
|
||||
|
|
Ładowanie…
Reference in New Issue