mirror of https://gitee.com/bigwinds/arangodb
cppcheck
This commit is contained in:
parent
1914fefc48
commit
deb6c14bf4
|
@ -1252,7 +1252,7 @@ unittests-authentication-parameters:
|
|||
|
||||
cppcheck:
|
||||
@rm -f cppcheck.log cppcheck.log && echo -n "" > cppcheck.tmp
|
||||
for platform in unix32 unix64; do cppcheck -j4 --std=c++11 --enable=style --force --platform=$$platform --suppress="*:lib/JsonParser/json-parser.cpp" --suppress="*:lib/V8/v8-json.cpp" --suppress="*:arangod/Aql/grammar.cpp" --suppress="*:arangod/Aql/tokens.cpp" arangod/ lib/ 1> /dev/null 2>> cppcheck.tmp; done
|
||||
for platform in unix32 unix64; do cppcheck -j4 --std=c++11 --enable=style --force --platform=$$platform --suppress="*:lib/JsonParser/json-parser.cpp" --suppress="*:lib/V8/v8-json.cpp" --suppress="*:arangod/Aql/grammar.cpp" --suppress="*:arangod/Aql/tokens.cpp" arangod/ arangosh/ lib/ 1> /dev/null 2>> cppcheck.tmp; done
|
||||
@sort cppcheck.tmp | uniq > cppcheck.log
|
||||
@rm cppcheck.tmp
|
||||
@cat cppcheck.log
|
||||
|
|
|
@ -326,10 +326,10 @@ void ArangoClient::setupServer (ProgramOptionsDescription& description) {
|
|||
|
||||
void ArangoClient::parse (ProgramOptions& options,
|
||||
ProgramOptionsDescription& description,
|
||||
string const& example,
|
||||
std::string const& example,
|
||||
int argc,
|
||||
char* argv[],
|
||||
string const& initFilename) {
|
||||
std::string const& initFilename) {
|
||||
|
||||
// if options are invalid, exit directly
|
||||
if (! options.parse(description, argc, argv)) {
|
||||
|
@ -524,7 +524,7 @@ void ArangoClient::parse (ProgramOptions& options,
|
|||
/// @brief prints a string and a newline to stderr
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ArangoClient::printErrLine (const string& s) {
|
||||
void ArangoClient::printErrLine (std::string const& s) {
|
||||
#ifdef _WIN32
|
||||
// no, we can use std::cerr as this doesn't support UTF-8 on Windows
|
||||
printLine(s);
|
||||
|
@ -537,7 +537,7 @@ void ArangoClient::printErrLine (const string& s) {
|
|||
/// @brief prints a string and a newline to stdout
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ArangoClient::_printLine (const string &s) {
|
||||
void ArangoClient::_printLine (std::string const& s) {
|
||||
#ifdef _WIN32
|
||||
LPWSTR wBuf = (LPWSTR) TRI_Allocate(TRI_CORE_MEM_ZONE, (sizeof WCHAR)* (s.size() + 1), true);
|
||||
int wLen = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, wBuf, (int) ((sizeof WCHAR) * (s.size() + 1)));
|
||||
|
@ -551,7 +551,7 @@ void ArangoClient::_printLine (const string &s) {
|
|||
pos = bufferInfo.dwCursorPosition;
|
||||
|
||||
size_t newX = static_cast<size_t>(pos.X) + s.size();
|
||||
size_t oldY = static_cast<size_t>(pos.Y);
|
||||
// size_t oldY = static_cast<size_t>(pos.Y);
|
||||
if (newX >= static_cast<size_t>(bufferInfo.dwSize.X)) {
|
||||
for (size_t i = 0; i <= newX / bufferInfo.dwSize.X; ++i) {
|
||||
// insert as many newlines as we need. this prevents running out of buffer space when printing lines
|
||||
|
@ -584,7 +584,7 @@ void ArangoClient::_printLine (const string &s) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void ArangoClient::printLine (const string& s, bool forceNewLine) {
|
||||
void ArangoClient::printLine (std::string const& s, bool forceNewLine) {
|
||||
#if _WIN32
|
||||
if (! cygwinShell) {
|
||||
// no, we cannot use std::cout as this doesn't support UTF-8 on Windows
|
||||
|
@ -612,7 +612,7 @@ void ArangoClient::printLine (const string& s, bool forceNewLine) {
|
|||
/// on Windows, we'll print the line and a newline
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ArangoClient::printContinuous (const string& s) {
|
||||
void ArangoClient::printContinuous (std::string const& s) {
|
||||
// no, we cannot use std::cout as this doesn't support UTF-8 on Windows
|
||||
#ifdef _WIN32
|
||||
// On Windows, we just print the line followed by a newline
|
||||
|
@ -627,18 +627,8 @@ void ArangoClient::printContinuous (const string& s) {
|
|||
/// @brief starts pager
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
void ArangoClient::startPager () {
|
||||
// not supported
|
||||
if (! _usePager || _usePager) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void ArangoClient::startPager () {
|
||||
#ifndef _WIN32
|
||||
if (! _usePager || _outputPager == "" || _outputPager == "stdout" || _outputPager == "-") {
|
||||
_pager = stdout;
|
||||
return;
|
||||
|
@ -651,30 +641,21 @@ void ArangoClient::startPager () {
|
|||
_pager = stdout;
|
||||
_usePager = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief stops pager
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
void ArangoClient::stopPager () {
|
||||
// not supported
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void ArangoClient::stopPager () {
|
||||
#ifndef _WIN32
|
||||
if (_pager != stdout) {
|
||||
pclose(_pager);
|
||||
_pager = stdout;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief strips binary data from string
|
||||
|
@ -711,8 +692,7 @@ static std::string StripBinary (const char* value) {
|
|||
/// @brief prints to pager
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ArangoClient::internalPrint (const string & str) {
|
||||
|
||||
void ArangoClient::internalPrint (std::string const& str) {
|
||||
if (_pager == stdout) {
|
||||
#ifdef _WIN32
|
||||
// at moment the formating is ignored in windows
|
||||
|
@ -814,9 +794,9 @@ void ArangoClient::log (const char* format,
|
|||
/// @brief logs output, with prompt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ArangoClient::log (const string& format,
|
||||
const string& prompt,
|
||||
const string& str) {
|
||||
void ArangoClient::log (std::string const& format,
|
||||
std::string const& prompt,
|
||||
std::string const& str) {
|
||||
if (_log) {
|
||||
string sanitised = StripBinary(str.c_str());
|
||||
|
||||
|
@ -838,7 +818,7 @@ void ArangoClient::flushLog () {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates an new endpoint
|
||||
/// @brief creates a new endpoint
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ArangoClient::createEndpoint () {
|
||||
|
@ -846,10 +826,10 @@ void ArangoClient::createEndpoint () {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates an new endpoint
|
||||
/// @brief creates a new endpoint
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ArangoClient::createEndpoint (string const& definition) {
|
||||
void ArangoClient::createEndpoint (std::string const& definition) {
|
||||
// close previous endpoint
|
||||
if (_endpointServer != nullptr) {
|
||||
delete _endpointServer;
|
||||
|
@ -903,7 +883,7 @@ bool ArangoClient::prettyPrint () const {
|
|||
/// @brief gets the output pager
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string const& ArangoClient::outputPager () const {
|
||||
std::string const& ArangoClient::outputPager () const {
|
||||
return _outputPager;
|
||||
}
|
||||
|
||||
|
@ -927,7 +907,7 @@ void ArangoClient::setUsePager (bool value) {
|
|||
/// @brief gets endpoint to connect to as string
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string const& ArangoClient::endpointString () const {
|
||||
std::string const& ArangoClient::endpointString () const {
|
||||
return _endpointString;
|
||||
}
|
||||
|
||||
|
@ -935,7 +915,7 @@ string const& ArangoClient::endpointString () const {
|
|||
/// @brief sets endpoint to connect to as string
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ArangoClient::setEndpointString (string const& value) {
|
||||
void ArangoClient::setEndpointString (std::string const& value) {
|
||||
_endpointString = value;
|
||||
}
|
||||
|
||||
|
@ -951,7 +931,7 @@ Endpoint* ArangoClient::endpointServer() const {
|
|||
/// @brief database name
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string const& ArangoClient::databaseName () const {
|
||||
std::string const& ArangoClient::databaseName () const {
|
||||
return _databaseName;
|
||||
}
|
||||
|
||||
|
@ -959,7 +939,7 @@ string const& ArangoClient::databaseName () const {
|
|||
/// @brief user to send to endpoint
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string const& ArangoClient::username () const {
|
||||
std::string const& ArangoClient::username () const {
|
||||
return _username;
|
||||
}
|
||||
|
||||
|
@ -967,7 +947,7 @@ string const& ArangoClient::username () const {
|
|||
/// @brief password to send to endpoint
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string const& ArangoClient::password () const {
|
||||
std::string const& ArangoClient::password () const {
|
||||
return _password;
|
||||
}
|
||||
|
||||
|
@ -975,7 +955,7 @@ string const& ArangoClient::password () const {
|
|||
/// @brief sets database name
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ArangoClient::setDatabaseName (string const& databaseName) {
|
||||
void ArangoClient::setDatabaseName (std::string const& databaseName) {
|
||||
_databaseName = databaseName;
|
||||
}
|
||||
|
||||
|
@ -983,7 +963,7 @@ void ArangoClient::setDatabaseName (string const& databaseName) {
|
|||
/// @brief sets username
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ArangoClient::setUsername (string const& username) {
|
||||
void ArangoClient::setUsername (std::string const& username) {
|
||||
_username = username;
|
||||
}
|
||||
|
||||
|
@ -991,7 +971,7 @@ void ArangoClient::setUsername (string const& username) {
|
|||
/// @brief sets password
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ArangoClient::setPassword (string const& password) {
|
||||
void ArangoClient::setPassword (std::string const& password) {
|
||||
_password = password;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#define ARANGODB_ARANGO_SHELL_ARANGO_CLIENT_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
|
||||
#include "Rest/Endpoint.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -126,7 +125,7 @@ namespace triagens {
|
|||
/// @brief constructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ArangoClient (char const* appName);
|
||||
explicit ArangoClient (char const* appName);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
|
@ -203,19 +202,19 @@ namespace triagens {
|
|||
/// @brief print a string and a newline to stderr, necessary for Windows
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void printErrLine (const std::string&);
|
||||
void printErrLine (std::string const&);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief print a string and a newline to stdout, necessary for Windows
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void printLine (const std::string&, bool forceNewLine = false);
|
||||
void printLine (std::string const&, bool forceNewLine = false);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief print a string to stdout, without a newline, necessary for Windows
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void printContinuous (const std::string&);
|
||||
void printContinuous (std::string const&);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief starts pager
|
||||
|
@ -233,7 +232,7 @@ namespace triagens {
|
|||
/// @brief print to pager
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void internalPrint (const std::string& str);
|
||||
void internalPrint (std::string const& str);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief open log
|
||||
|
@ -269,9 +268,9 @@ namespace triagens {
|
|||
/// @brief log output, with prompt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void log (const std::string& format,
|
||||
const std::string& prompt,
|
||||
const std::string& str);
|
||||
void log (std::string const& format,
|
||||
std::string const& prompt,
|
||||
std::string const& str);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief flush log
|
||||
|
@ -280,13 +279,13 @@ namespace triagens {
|
|||
void flushLog ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates an new endpoint
|
||||
/// @brief creates a new endpoint
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void createEndpoint ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates an new endpoint
|
||||
/// @brief creates a new endpoint
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void createEndpoint (std::string const&);
|
||||
|
@ -421,7 +420,7 @@ namespace triagens {
|
|||
/// @brief prints a line
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _printLine (const std::string &s);
|
||||
void _printLine (std::string const&);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private variables
|
||||
|
|
|
@ -161,6 +161,8 @@ namespace triagens {
|
|||
_numberErrors(0),
|
||||
_numberUpdated(0),
|
||||
_numberIgnored(0),
|
||||
_rowsRead(0),
|
||||
_rowOffset(0),
|
||||
_onDuplicateAction("error"),
|
||||
_collectionName(),
|
||||
_lineBuffer(TRI_UNKNOWN_MEM_ZONE),
|
||||
|
|
|
@ -534,7 +534,6 @@ static int DumpCollection (int fd,
|
|||
int res = TRI_ERROR_NO_ERROR; // just to please the compiler
|
||||
bool checkMore = false;
|
||||
bool found;
|
||||
uint64_t tick;
|
||||
|
||||
// TODO: fix hard-coded headers
|
||||
string header = response->getHeaderField("x-arango-replication-checkmore", found);
|
||||
|
@ -548,7 +547,7 @@ static int DumpCollection (int fd,
|
|||
header = response->getHeaderField("x-arango-replication-lastincluded", found);
|
||||
|
||||
if (found) {
|
||||
tick = StringUtils::uint64(header);
|
||||
uint64_t tick = StringUtils::uint64(header);
|
||||
|
||||
if (tick > fromTick) {
|
||||
fromTick = tick;
|
||||
|
@ -773,7 +772,7 @@ static int RunDump (string& errorMsg) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (restrictList.size() > 0 &&
|
||||
if (! restrictList.empty() &&
|
||||
restrictList.find(name) == restrictList.end()) {
|
||||
// collection name not in list
|
||||
continue;
|
||||
|
@ -905,7 +904,6 @@ static int DumpShard (int fd,
|
|||
int res = TRI_ERROR_NO_ERROR; // just to please the compiler
|
||||
bool checkMore = false;
|
||||
bool found;
|
||||
uint64_t tick;
|
||||
|
||||
// TODO: fix hard-coded headers
|
||||
std::string header = response->getHeaderField("x-arango-replication-checkmore", found);
|
||||
|
@ -919,7 +917,7 @@ static int DumpShard (int fd,
|
|||
header = response->getHeaderField("x-arango-replication-lastincluded", found);
|
||||
|
||||
if (found) {
|
||||
tick = StringUtils::uint64(header);
|
||||
uint64_t tick = StringUtils::uint64(header);
|
||||
|
||||
if (tick > fromTick) {
|
||||
fromTick = tick;
|
||||
|
@ -1055,7 +1053,7 @@ static int RunClusterDump (string& errorMsg) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (restrictList.size() > 0 &&
|
||||
if (! restrictList.empty() &&
|
||||
restrictList.find(name) == restrictList.end()) {
|
||||
// collection name not in list
|
||||
continue;
|
||||
|
@ -1129,7 +1127,7 @@ static int RunClusterDump (string& errorMsg) {
|
|||
}
|
||||
|
||||
map<string, string>::iterator it;
|
||||
for (it = shardTab.begin(); it != shardTab.end(); it++) {
|
||||
for (it = shardTab.begin(); it != shardTab.end(); ++it) {
|
||||
string shardName = it->first;
|
||||
string DBserver = it->second;
|
||||
if (Progress) {
|
||||
|
|
|
@ -322,8 +322,6 @@ int main (int argc, char* argv[]) {
|
|||
client.setLocationRewriter(nullptr, &RewriteLocation);
|
||||
client.setUserNamePassword("/", BaseClient.username(), BaseClient.password());
|
||||
|
||||
std::string const versionString = client.getServerVersion();
|
||||
|
||||
if (! connection->isConnected()) {
|
||||
cerr << "Could not connect to endpoint '" << BaseClient.endpointString()
|
||||
<< "', database: '" << BaseClient.databaseName() << "', username: '" << BaseClient.username() << "'" << endl;
|
||||
|
@ -456,7 +454,7 @@ int main (int argc, char* argv[]) {
|
|||
cout << "updated/replaced: " << ih.getNumberUpdated() << endl;
|
||||
cout << "ignored: " << ih.getNumberIgnored() << endl;
|
||||
|
||||
if (TypeImport == "csv" || TypeImport == "csv") {
|
||||
if (TypeImport == "csv" || TypeImport == "tsv") {
|
||||
cout << "lines read: " << ih.getReadLines() << endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -684,7 +684,6 @@ static int ProcessInputDirectory (std::string& errorMsg) {
|
|||
TRI_json_t const* parameters = JsonHelper::getObjectElement(json, "parameters");
|
||||
TRI_json_t const* indexes = JsonHelper::getObjectElement(json, "indexes");
|
||||
std::string const cname = JsonHelper::getStringValue(parameters, "name", "");
|
||||
std::string const cid = JsonHelper::getStringValue(parameters, "cid", "");
|
||||
|
||||
int type = JsonHelper::getNumericValue<int>(parameters, "type", 2);
|
||||
std::string const collectionType(type == 2 ? "document" : "edge");
|
||||
|
|
|
@ -1210,8 +1210,8 @@ static void ClientConnection_httpSendFile (const v8::FunctionCallbackInfo<v8::Va
|
|||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, body);
|
||||
|
||||
if (tryCatch.HasCaught()) {
|
||||
string exception = TRI_StringifyV8Exception(isolate, &tryCatch);
|
||||
isolate->ThrowException(tryCatch.Exception());
|
||||
//string exception = TRI_StringifyV8Exception(isolate, &tryCatch);
|
||||
isolate->ThrowException(tryCatch.Exception());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1929,7 +1929,9 @@ static void LocalExitFunction (int exitCode, void* data) {
|
|||
|
||||
#endif
|
||||
|
||||
static bool printHelo (bool useServer, bool promptError) {
|
||||
static bool PrintHelo (bool useServer) {
|
||||
bool promptError = false;
|
||||
|
||||
// .............................................................................
|
||||
// banner
|
||||
// .............................................................................
|
||||
|
@ -2063,6 +2065,7 @@ static bool printHelo (bool useServer, bool promptError) {
|
|||
BaseClient.printLine("", true);
|
||||
}
|
||||
}
|
||||
|
||||
return promptError;
|
||||
}
|
||||
|
||||
|
@ -2284,8 +2287,6 @@ class BufferAllocator : public v8::ArrayBuffer::Allocator {
|
|||
int main (int argc, char* args[]) {
|
||||
int ret = EXIT_SUCCESS;
|
||||
eRunMode runMode = eInteractive;
|
||||
// reset the prompt error flag (will determine prompt colors)
|
||||
bool promptError = false;
|
||||
#if _WIN32
|
||||
extern bool cygwinShell;
|
||||
if (getenv("SHELL") != nullptr) {
|
||||
|
@ -2368,7 +2369,7 @@ int main (int argc, char* args[]) {
|
|||
}
|
||||
|
||||
#ifdef TRI_FORCE_ARMV6
|
||||
const string forceARMv6 = "--noenable-armv7";
|
||||
std::string const forceARMv6 = "--noenable-armv7";
|
||||
v8::V8::SetFlagsFromString(forceARMv6.c_str(), (int) forceARMv6.size());
|
||||
#endif
|
||||
|
||||
|
@ -2407,7 +2408,8 @@ int main (int argc, char* args[]) {
|
|||
|
||||
InitCallbacks(isolate, useServer, runMode);
|
||||
|
||||
promptError = printHelo(useServer, promptError);
|
||||
// reset the prompt error flag (will determine prompt colors)
|
||||
bool promptError = PrintHelo(useServer);
|
||||
|
||||
ret = WarmupEnvironment(isolate, positionals, runMode);
|
||||
|
||||
|
|
Loading…
Reference in New Issue