/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// Check for some basic naming mismatches which make the code harder to read // // This plugin is deliberately fairly lax, and only targets the most egregeriously faulty code, // since we have a broad range of styles in our code and we don't want to generate unnecessary // churn.
namespace {
class StylePolice : public loplugin::FilteringPlugin<StylePolice>
{ public: explicit StylePolice(InstantiationData const & data): FilteringPlugin(data) {}
bool StylePolice::VisitVarDecl(const VarDecl * varDecl)
{ if (ignoreLocation(varDecl)) { returntrue;
}
StringRef aFileName = getFilename(varDecl->getLocStart());
std::string name = varDecl->getName();
if (!varDecl->isLocalVarDecl()) { returntrue;
}
if (matchMember(name))
{ // these names appear to be taken from some scientific paper if (aFileName == SRCDIR "/scaddins/source/analysis/bessel.cxx" ) {
} // lots of places where we are storing a "method id" here elseif (aFileName.startswith(SRCDIR "/connectivity/source/drivers/jdbc") && name.compare(0,3,"mID") == 0) {
} else {
report(
DiagnosticsEngine::Warning, "this local variable follows our member field naming convention, which is confusing",
varDecl->getLocation())
<< varDecl->getType() << varDecl->getSourceRange();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.