mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
hookup google cpplint, and make "scons lint" run the checks we pass on now
including a few that i made pass
This commit is contained in:
parent
1c33a98ebf
commit
3a15fac7d8
72
SConstruct
72
SConstruct
@ -914,6 +914,78 @@ def doStyling( env , target , source ):
|
|||||||
env.Alias( "style" , [] , [ doStyling ] )
|
env.Alias( "style" , [] , [ doStyling ] )
|
||||||
env.AlwaysBuild( "style" )
|
env.AlwaysBuild( "style" )
|
||||||
|
|
||||||
|
# --- lint ----
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def doLint( env , target , source ):
|
||||||
|
import buildscripts.cpplint
|
||||||
|
import codecs
|
||||||
|
|
||||||
|
filters = []
|
||||||
|
|
||||||
|
# errors are as of 10/14
|
||||||
|
# idea is not to let it any new type of error
|
||||||
|
# as we knock one out, we should remove line
|
||||||
|
# note: not all of these are things we want, so please check first
|
||||||
|
|
||||||
|
filters.append( '-build/header_guard' ) # errors found: 345
|
||||||
|
filters.append( '-build/include' ) # errors found: 924
|
||||||
|
filters.append( '-build/include_order' ) # errors found: 511
|
||||||
|
filters.append( '-build/include_what_you_use' ) # errors found: 986
|
||||||
|
filters.append( '-build/namespaces' ) # errors found: 131
|
||||||
|
filters.append( '-legal/copyright' ) # errors found: 65
|
||||||
|
filters.append( '-readability/braces' ) # errors found: 880
|
||||||
|
filters.append( '-readability/casting' ) # errors found: 748
|
||||||
|
filters.append( '-readability/function' ) # errors found: 49
|
||||||
|
filters.append( '-readability/streams' ) # errors found: 72
|
||||||
|
filters.append( '-readability/todo' ) # errors found: 309
|
||||||
|
filters.append( '-runtime/arrays' ) # errors found: 5
|
||||||
|
filters.append( '-runtime/explicit' ) # errors found: 322
|
||||||
|
filters.append( '-runtime/int' ) # errors found: 1420
|
||||||
|
filters.append( '-runtime/printf' ) # errors found: 29
|
||||||
|
filters.append( '-runtime/references' ) # errors found: 1338
|
||||||
|
filters.append( '-runtime/rtti' ) # errors found: 36
|
||||||
|
filters.append( '-runtime/sizeof' ) # errors found: 57
|
||||||
|
filters.append( '-runtime/string' ) # errors found: 6
|
||||||
|
filters.append( '-runtime/threadsafe_fn' ) # errors found: 46
|
||||||
|
filters.append( '-whitespace/blank_line' ) # errors found: 2080
|
||||||
|
filters.append( '-whitespace/braces' ) # errors found: 962
|
||||||
|
filters.append( '-whitespace/comma' ) # errors found: 621
|
||||||
|
filters.append( '-whitespace/comments' ) # errors found: 2189
|
||||||
|
filters.append( '-whitespace/end_of_line' ) # errors found: 4340
|
||||||
|
filters.append( '-whitespace/indent' ) # errors found: 8
|
||||||
|
filters.append( '-whitespace/labels' ) # errors found: 58
|
||||||
|
filters.append( '-whitespace/line_length' ) # errors found: 14500
|
||||||
|
filters.append( '-whitespace/newline' ) # errors found: 1520
|
||||||
|
filters.append( '-whitespace/operators' ) # errors found: 2297
|
||||||
|
filters.append( '-whitespace/parens' ) # errors found: 49058
|
||||||
|
filters.append( '-whitespace/semicolon' ) # errors found: 121
|
||||||
|
filters.append( '-whitespace/tab' ) # errors found: 233
|
||||||
|
|
||||||
|
sourceFiles = utils.getAllSourceFiles( prefix="src/mongo/" )
|
||||||
|
sourceFiles.
|
||||||
|
args = [ "--filter=" + ",".join( filters ) , "--counting=detailed" ] + sourceFiles
|
||||||
|
filenames = buildscripts.cpplint.ParseArguments( args )
|
||||||
|
|
||||||
|
# Change stderr to write with replacement characters so we don't die
|
||||||
|
# if we try to print something containing non-ASCII characters.
|
||||||
|
sys.stderr = codecs.StreamReaderWriter(sys.stderr,
|
||||||
|
codecs.getreader('utf8'),
|
||||||
|
codecs.getwriter('utf8'),
|
||||||
|
'replace')
|
||||||
|
|
||||||
|
buildscripts.cpplint._cpplint_state.ResetErrorCounts()
|
||||||
|
for filename in filenames:
|
||||||
|
buildscripts.cpplint.ProcessFile(filename, buildscripts.cpplint._cpplint_state.verbose_level)
|
||||||
|
buildscripts.cpplint._cpplint_state.PrintErrorCounts()
|
||||||
|
|
||||||
|
if buildscripts.cpplint._cpplint_state.error_count > 0:
|
||||||
|
raise Exception( "lint errors" )
|
||||||
|
|
||||||
|
env.Alias( "lint" , [] , [ doLint ] )
|
||||||
|
env.AlwaysBuild( "lint" )
|
||||||
|
|
||||||
|
|
||||||
# ---- INSTALL -------
|
# ---- INSTALL -------
|
||||||
|
|
||||||
|
3361
buildscripts/cpplint.py
vendored
Normal file
3361
buildscripts/cpplint.py
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -148,7 +148,7 @@ namespace mongo {
|
|||||||
// the compiler would use if inside the function. the reason this is static is to avoid a malloc/free for this
|
// the compiler would use if inside the function. the reason this is static is to avoid a malloc/free for this
|
||||||
// on every logop call.
|
// on every logop call.
|
||||||
static BufBuilder logopbufbuilder(8*1024);
|
static BufBuilder logopbufbuilder(8*1024);
|
||||||
const static int OPLOG_VERSION = 2;
|
static const int OPLOG_VERSION = 2;
|
||||||
static void _logOpRS(const char *opstr, const char *ns, const char *logNS, const BSONObj& obj, BSONObj *o2, bool *bb, bool fromMigrate ) {
|
static void _logOpRS(const char *opstr, const char *ns, const char *logNS, const BSONObj& obj, BSONObj *o2, bool *bb, bool fromMigrate ) {
|
||||||
Lock::DBWrite lk1("local");
|
Lock::DBWrite lk1("local");
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ namespace mongo {
|
|||||||
DocumentSourceLimit::createFromBson},
|
DocumentSourceLimit::createFromBson},
|
||||||
{DocumentSourceMatch::matchName,
|
{DocumentSourceMatch::matchName,
|
||||||
DocumentSourceMatch::createFromBson},
|
DocumentSourceMatch::createFromBson},
|
||||||
#ifdef LATER /* https://jira.mongodb.org/browse/SERVER-3253 */
|
#ifdef LATER // https://jira.mongodb.org/browse/SERVER-3253
|
||||||
{DocumentSourceOut::outName,
|
{DocumentSourceOut::outName,
|
||||||
DocumentSourceOut::createFromBson},
|
DocumentSourceOut::createFromBson},
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,7 +46,7 @@ namespace mongo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ReplSetImpl::syncDoInitialSync() {
|
void ReplSetImpl::syncDoInitialSync() {
|
||||||
const static int maxFailedAttempts = 10;
|
static const int maxFailedAttempts = 10;
|
||||||
createOplog();
|
createOplog();
|
||||||
int failedAttempts = 0;
|
int failedAttempts = 0;
|
||||||
while ( failedAttempts < maxFailedAttempts ) {
|
while ( failedAttempts < maxFailedAttempts ) {
|
||||||
|
@ -662,7 +662,7 @@ namespace DocumentTests {
|
|||||||
intrusive_ptr<const Value> value() { return Value::createDate(0); }
|
intrusive_ptr<const Value> value() { return Value::createDate(0); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Coerce // to bool. */
|
/** Coerce js literal regex to bool. */
|
||||||
class RegexToBool : public ToBoolTrue {
|
class RegexToBool : public ToBoolTrue {
|
||||||
intrusive_ptr<const Value> value() { return fromBson( fromjson( "{''://}" ) ); }
|
intrusive_ptr<const Value> value() { return fromBson( fromjson( "{''://}" ) ); }
|
||||||
};
|
};
|
||||||
|
@ -307,8 +307,10 @@ namespace mongo {
|
|||||||
|
|
||||||
DBClientBase& Tool::conn( bool slaveIfPaired ) {
|
DBClientBase& Tool::conn( bool slaveIfPaired ) {
|
||||||
if ( slaveIfPaired && _conn->type() == ConnectionString::SET ) {
|
if ( slaveIfPaired && _conn->type() == ConnectionString::SET ) {
|
||||||
if (!_slaveConn)
|
if (!_slaveConn) {
|
||||||
_slaveConn = &((DBClientReplicaSet*)_conn)->slaveConn();
|
DBClientReplicaSet* rs = static_cast<DBClientReplicaSet*>(_conn);
|
||||||
|
_slaveConn = &rs->slaveConn();
|
||||||
|
}
|
||||||
return *_slaveConn;
|
return *_slaveConn;
|
||||||
}
|
}
|
||||||
return *_conn;
|
return *_conn;
|
||||||
|
@ -35,10 +35,7 @@ namespace mongo {
|
|||||||
int Key::hash() return > 0 always.
|
int Key::hash() return > 0 always.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <
|
template <class Key,class Type>
|
||||||
class Key,
|
|
||||||
class Type
|
|
||||||
>
|
|
||||||
class HashTable : boost::noncopyable {
|
class HashTable : boost::noncopyable {
|
||||||
public:
|
public:
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -51,12 +51,12 @@
|
|||||||
* to the MD5 library. Typical compilation:
|
* to the MD5 library. Typical compilation:
|
||||||
* gcc -o md5main -lm md5main.c md5.c
|
* gcc -o md5main -lm md5main.c md5.c
|
||||||
*/
|
*/
|
||||||
static const char *const usage = "\
|
static const char *const usage =
|
||||||
Usage:\n\
|
"Usage:\n"
|
||||||
md5main --test # run the self-test (A.5 of RFC 1321)\n\
|
" md5main --test # run the self-test (A.5 of RFC 1321)\n "
|
||||||
md5main --t-values # print the T values for the library\n\
|
" md5main --t-values # print the T values for the library\n "
|
||||||
md5main --version # print the version of the package\n\
|
" md5main --version # print the version of the package\n ";
|
||||||
";
|
|
||||||
static const char *const version = "2002-04-13";
|
static const char *const version = "2002-04-13";
|
||||||
|
|
||||||
/* modified: not static, renamed */
|
/* modified: not static, renamed */
|
||||||
|
Loading…
Reference in New Issue
Block a user