Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Fix several minor linter errors #2476

Merged
22 changes: 11 additions & 11 deletions src/gridcoin/scraper/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void Http::Download(
ScopedFile fp(fsbridge::fopen(destination, "wb"), &fclose);
if (!fp)
throw std::runtime_error(
tfm::format("Error opening target %s: %s (%d)", destination, strerror(errno), errno));
tfm::strformat("Error opening target %s: %s (%d)", destination, strerror(errno), errno));

std::string buffer;
ScopedCurl curl = GetContext();
Expand All @@ -221,7 +221,7 @@ void Http::Download(

CURLcode res = curl_easy_perform(curl.get());
if (res > 0)
throw std::runtime_error(tfm::format("Failed to download file %s: %s", url, curl_easy_strerror(res)));
throw std::runtime_error(tfm::strformat("Failed to download file %s: %s", url, curl_easy_strerror(res)));
}

std::string Http::GetEtag(
Expand All @@ -247,7 +247,7 @@ std::string Http::GetEtag(
curl_slist_free_all(headers);

if (res > 0)
throw std::runtime_error(tfm::format("Failed to get ETag for URL %s: %s", url, curl_easy_strerror(res)));
throw std::runtime_error(tfm::strformat("Failed to get ETag for URL %s: %s", url, curl_easy_strerror(res)));

// Validate HTTP return code.
long response_code;
Expand Down Expand Up @@ -291,7 +291,7 @@ std::string Http::GetLatestVersionResponse()
CURLcode res = curl_easy_perform(curl.get());

if (res > 0)
throw std::runtime_error(tfm::format("Failed to get version response from URL %s: %s",
throw std::runtime_error(tfm::strformat("Failed to get version response from URL %s: %s",
url, curl_easy_strerror(res)));

curl_slist_free_all(headers);
Expand Down Expand Up @@ -320,7 +320,7 @@ void Http::DownloadSnapshot()
DownloadStatus.SetSnapshotDownloadFailed(true);

throw std::runtime_error(
tfm::format("Snapshot Downloader: Error opening target %s: %s (%d)",
tfm::strformat("Snapshot Downloader: Error opening target %s: %s (%d)",
destination.string(), strerror(errno), errno));
}

Expand Down Expand Up @@ -374,7 +374,7 @@ void Http::DownloadSnapshot()
{
DownloadStatus.SetSnapshotDownloadFailed(true);

throw std::runtime_error(tfm::format("Snapshot Downloader: Failed to download file %s: %s",
throw std::runtime_error(tfm::strformat("Snapshot Downloader: Failed to download file %s: %s",
url, curl_easy_strerror(res)));
}
}
Expand Down Expand Up @@ -458,13 +458,13 @@ void Http::EvaluateResponse(int code, const std::string& url)
code == 308)
return;
else if (code == 400)
throw HttpException(tfm::format("Server returned a http code of Bad Request <url=%s, code=%d>", url, code));
throw HttpException(tfm::strformat("Server returned a http code of Bad Request <url=%s, code=%d>", url, code));
else if (code == 401)
throw HttpException(tfm::format("Server returned a http code of Unauthorized <url=%s, code=%d>", url, code));
throw HttpException(tfm::strformat("Server returned a http code of Unauthorized <url=%s, code=%d>", url, code));
else if (code == 403)
throw HttpException(tfm::format("Server returned a http code of Forbidden <url=%s, code=%d>", url, code));
throw HttpException(tfm::strformat("Server returned a http code of Forbidden <url=%s, code=%d>", url, code));
else if (code == 404)
throw HttpException(tfm::format("Server returned a http code of Not Found <url=%s, code=%d>", url, code));
throw HttpException(tfm::strformat("Server returned a http code of Not Found <url=%s, code=%d>", url, code));

throw HttpException(tfm::format("Server returned a http code <url=%s, code=%d>", url, code));
throw HttpException(tfm::strformat("Server returned a http code <url=%s, code=%d>", url, code));
}
6 changes: 3 additions & 3 deletions src/gridcoin/scraper/scraper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ void _log(logattribute eType, const std::string& sCall, const std::string& sMess
return;
}

sOut = tfm::format("%s [%s] <%s> : %s", DateTimeStrFormat("%x %H:%M:%S", GetAdjustedTime()), sType, sCall, sMessage);
sOut = tfm::strformat("%s [%s] <%s> : %s", DateTimeStrFormat("%x %H:%M:%S", GetAdjustedTime()), sType, sCall, sMessage);

// This snoops the SCRAPER category setting from the main logger, and uses it as a conditional for the scraper log output.
// Logs will be posted to the scraper log when the category is set OR it is not an INFO level... (i.e. critical, warning,
Expand Down Expand Up @@ -1320,7 +1320,7 @@ void ApplyCache(const std::string& key, T& result)
}
catch (const std::exception&)
{
_log(logattribute::ERR, "ScraperApplyAppCacheEntries", tfm::format("Ignoring bad AppCache entry for %s.", key));
_log(logattribute::ERR, "ScraperApplyAppCacheEntries", tfm::strformat("Ignoring bad AppCache entry for %s.", key));
}
}

Expand Down Expand Up @@ -2384,7 +2384,7 @@ EXCLUSIVE_LOCKS_REQUIRED(cs_TeamIDMap)

if (!ParseInt64(sTeamID, &nTeamID))
{
_log(logattribute::ERR, __func__, tfm::format("Ignoring bad team id for team %s.", sTeamName));
_log(logattribute::ERR, __func__, tfm::strformat("Ignoring bad team id for team %s.", sTeamName));
continue;
}

Expand Down
7 changes: 5 additions & 2 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@
#include <QLibraryInfo>
#include <QProcess>

// This eliminates the linter false positive on double include of QtPlugin
#if (defined(BITCOIN_NEED_QT_PLUGINS) && !defined(_BITCOIN_QT_PLUGINS_INCLUDED)) || defined(QT_STATICPLUGIN)
#include <QtPlugin>
#endif

#if defined(BITCOIN_NEED_QT_PLUGINS) && !defined(_BITCOIN_QT_PLUGINS_INCLUDED)
#define _BITCOIN_QT_PLUGINS_INCLUDED
#define __INSURE__
#include <QtPlugin>
Q_IMPORT_PLUGIN(qcncodecs)
Q_IMPORT_PLUGIN(qjpcodecs)
Q_IMPORT_PLUGIN(qtwcodecs)
Expand All @@ -53,7 +57,6 @@ Q_IMPORT_PLUGIN(qtaccessiblewidgets)
#endif

#if defined(QT_STATICPLUGIN)
#include <QtPlugin>
#if defined(QT_QPA_PLATFORM_XCB)
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
#elif defined(QT_QPA_PLATFORM_WINDOWS)
Expand Down
2 changes: 1 addition & 1 deletion src/test/gridcoin/mrc_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct Setup {
};
} // Anonymous namespace

BOOST_FIXTURE_TEST_SUITE(MRC, Setup)
BOOST_FIXTURE_TEST_SUITE(mrc_tests, Setup)

BOOST_AUTO_TEST_CASE(it_properly_records_blocks)
{
Expand Down
8 changes: 8 additions & 0 deletions src/tinyformat.h
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,14 @@ std::string format(const std::string &fmt, const Args&... args)
return oss.str();
}

// This is to make the linter happy because it the variadic script/python variadic checker does not deal with
// overloads.
template<typename... Args>
std::string strformat(const std::string &fmt, const Args&... args)
{
return format(fmt, args...);
}

} // namespace tinyformat

/** Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for details) */
Expand Down
1 change: 1 addition & 0 deletions test/lint/lint-format-strings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ FUNCTION_NAMES_AND_NUMBER_OF_LEADING_ARGUMENTS=(
"FatalError,0"
"fprintf,1"
"tfm::format,1" # Assuming tfm::::format(std::ostream&, ...
"tfm::strformat,0" # Assuming tfm::::strformat(fmt, ...
"LogConnectFailure,1"
"LogPrint,1"
"LogPrintf,0"
Expand Down
1 change: 1 addition & 0 deletions test/lint/lint-spelling.ignore-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ fo
dout
nin
inout
smoe