run clang-tidy with readability-braces-around-statements (#2899)

* run clang-tidy with readability-braces-around-statements
clang-format the results
clean up all the parts that clang-tidy-8 broke

* fix problem on windows
This commit is contained in:
Greg Landrum
2020-01-25 14:19:32 +01:00
committed by GitHub
parent fb3cad523e
commit d41752d558
261 changed files with 7449 additions and 3545 deletions

View File

@@ -54,7 +54,9 @@ int *getCountFp(struct reaccs_molecule_t *molPtr, unsigned int bitFlags,
char *getFp(struct reaccs_molecule_t *molPtr, unsigned int bitFlags,
bool isQuery, unsigned int nBytes) {
PRECONDITION(molPtr, "bad molecule");
while (nBytes % 4) ++nBytes;
while (nBytes % 4) {
++nBytes;
}
char *fingerprint = TypeAlloc(nBytes, char);
SetFingerprintBits(molPtr, fingerprint, static_cast<int>(nBytes),
static_cast<int>(bitFlags), static_cast<int>(isQuery), 0);
@@ -69,7 +71,9 @@ void reaccsToFingerprint(struct reaccs_molecule_t *molPtr,
std::vector<boost::uint32_t> &res,
unsigned int bitFlags = 32767U, bool isQuery = false,
bool resetVect = true, unsigned int nBytes = 64) {
if (resetVect) res.clear();
if (resetVect) {
res.clear();
}
char *fingerprint = getFp(molPtr, bitFlags, isQuery, nBytes);
for (unsigned int i = 0; i < nBytes; i += 4) {
boost::uint32_t word;
@@ -101,7 +105,9 @@ void reaccsToFingerprint(struct reaccs_molecule_t *molPtr, ExplicitBitVect &res,
bool resetVect = true, unsigned int nBytes = 64) {
PRECONDITION(molPtr, "bad molecule");
PRECONDITION(res.getNumBits() >= nBytes * 8U, "res too small");
if (resetVect) res.clearBits();
if (resetVect) {
res.clearBits();
}
char *fingerprint = getFp(molPtr, bitFlags, isQuery, nBytes);
@@ -163,7 +169,9 @@ struct reaccs_molecule_t *stringToReaccs(const std::string &data,
} // end of anonymous namespace
std::string getCanonSmiles(ROMol &mol, int flags) {
if (flags == -1) flags = DB_STEREO | CENTER_STEREO;
if (flags == -1) {
flags = DB_STEREO | CENTER_STEREO;
}
std::string res;
if (!mol.getNumConformers()) {
std::string rdSmi = MolToSmiles(mol, true);
@@ -264,7 +272,9 @@ std::string set2DCoords(const std::string &data, bool isSmiles) {
}
std::string getCanonSmiles(const std::string &data, bool isSmiles, int flags) {
if (flags == -1) flags = DB_STEREO | CENTER_STEREO;
if (flags == -1) {
flags = DB_STEREO | CENTER_STEREO;
}
char *smiles = nullptr, *canSmiles = nullptr;
if (!isSmiles) {
struct reaccs_molecule_t *mp = stringToReaccs(data, isSmiles);
@@ -340,7 +350,9 @@ void getAvalonFP(const std::string &data, bool isSmiles,
}
int _checkMolWrapper(struct reaccs_molecule_t **mpp) {
if (!*mpp) return BAD_MOLECULE;
if (!*mpp) {
return BAD_MOLECULE;
}
int res;
struct reaccs_molecule_t *tmp = *mpp;
res = RunStruchk(mpp, nullptr);

View File

@@ -201,7 +201,7 @@ void testRDK151() {
{
std::string tSmi = "C[C@H](F)Cl";
ROMol *m = static_cast<ROMol *>(SmilesToMol(tSmi));
auto *m = static_cast<ROMol *>(SmilesToMol(tSmi));
TEST_ASSERT(m);
std::string smi = AvalonTools::getCanonSmiles(tSmi, true);
CHECK_INVARIANT(smi == tSmi, smi + "!=" + tSmi);

View File

@@ -122,7 +122,9 @@ bool compareConfs(const ROMol* m, ROMol* templ, const MatchVectType& mv,
if (alignFirst) {
double rmsd =
MolAlign::alignMol(*templ, *m, molConfId, templateConfId, &mv);
if (rmsd > rmstol) return false;
if (rmsd > rmstol) {
return false;
}
}
const Conformer& conf1 = m->getConformer(molConfId);
@@ -133,7 +135,9 @@ bool compareConfs(const ROMol* m, ROMol* templ, const MatchVectType& mv,
RDGeom::Point3D pt1i = conf1.getAtomPos(mv[i].second);
RDGeom::Point3D pt2i = conf2.getAtomPos(mv[i].first);
if ((pt1i - pt2i).length() >= postol) return false;
if ((pt1i - pt2i).length() >= postol) {
return false;
}
}
return true;
}
@@ -169,10 +173,9 @@ void test2() {
{
auto coreConf = core->getConformer();
RDGeom::INT_POINT2D_MAP coordMap;
for (unsigned int i = 0; i < mv.size(); ++i) {
coordMap[mv[i].second] =
RDGeom::Point2D(coreConf.getAtomPos(mv[i].first).x,
coreConf.getAtomPos(mv[i].first).y);
for (auto& i : mv) {
coordMap[i.second] = RDGeom::Point2D(coreConf.getAtomPos(i.first).x,
coreConf.getAtomPos(i.first).y);
}
CoordGen::CoordGenParams params;
params.coordMap = coordMap;
@@ -225,10 +228,9 @@ void test2() {
{
auto coreConf = core->getConformer();
RDGeom::INT_POINT2D_MAP coordMap;
for (unsigned int i = 0; i < mv.size(); ++i) {
coordMap[mv[i].second] =
RDGeom::Point2D(coreConf.getAtomPos(mv[i].first).x,
coreConf.getAtomPos(mv[i].first).y);
for (auto& i : mv) {
coordMap[i.second] = RDGeom::Point2D(coreConf.getAtomPos(i.first).x,
coreConf.getAtomPos(i.first).y);
}
CoordGen::CoordGenParams params;
params.coordMap = coordMap;
@@ -282,10 +284,9 @@ void test2() {
{
auto coreConf = core->getConformer();
RDGeom::INT_POINT2D_MAP coordMap;
for (unsigned int i = 0; i < mv.size(); ++i) {
coordMap[mv[i].second] =
RDGeom::Point2D(coreConf.getAtomPos(mv[i].first).x,
coreConf.getAtomPos(mv[i].first).y);
for (auto& i : mv) {
coordMap[i.second] = RDGeom::Point2D(coreConf.getAtomPos(i.first).x,
coreConf.getAtomPos(i.first).y);
}
CoordGen::CoordGenParams params;

View File

@@ -159,7 +159,9 @@ double internalCalcSASA(const ROMol &mol, const std::vector<double> &radii,
freesasa_result *res =
freesasa_calc_coord(&coords[0], &radii[0], mol.getNumAtoms(), &params);
if (!res) return 0.0;
if (!res) {
return 0.0;
}
CHECK_INVARIANT(res->n_atoms == rdcast<int>(mol.getNumAtoms()),
"freesasa didn't return the correct number of atoms");

View File

@@ -53,7 +53,9 @@ python::object classifyAtomsHelper(RDKit::ROMol &mol,
std::vector<double> radii;
python::list l;
if (FreeSASA::classifyAtoms(mol, radii, opts)) {
for (double &i : radii) l.append(i);
for (double &i : radii) {
l.append(i);
}
return l;
}
return l;

View File

@@ -36,9 +36,10 @@ namespace {
boost::python::tuple MolToInchi(const RDKit::ROMol &mol, std::string options)
{
RDKit::ExtraInchiReturnValues rv;
const char* _options = NULL;
if (options.size())
const char* _options = nullptr;
if (options.size()) {
_options = options.c_str();
}
std::string inchi = RDKit::MolToInchi(mol, rv, _options);
return boost::python::make_tuple(inchi, rv.returnCode, rv.messagePtr, rv.logPtr,
rv.auxInfoPtr);
@@ -47,9 +48,10 @@ namespace {
boost::python::tuple MolBlockToInchi(const std::string &molblock, std::string options)
{
RDKit::ExtraInchiReturnValues rv;
const char* _options = NULL;
if (options.size())
const char* _options = nullptr;
if (options.size()) {
_options = options.c_str();
}
std::string inchi = RDKit::MolBlockToInchi(molblock, rv, _options);
return boost::python::make_tuple(inchi, rv.returnCode, rv.messagePtr, rv.logPtr,
rv.auxInfoPtr);
@@ -59,10 +61,10 @@ namespace {
{
RDKit::ExtraInchiReturnValues rv;
RDKit::ROMol* mol = RDKit::InchiToMol(inchi, rv, sanitize, removeHs);
if (mol == NULL)
if (mol == nullptr) {
return boost::python::make_tuple(boost::python::object(), rv.returnCode,
rv.messagePtr, rv.logPtr);
else {
} else {
return boost::python::make_tuple(RDKit::ROMOL_SPTR(mol), rv.returnCode,
rv.messagePtr, rv.logPtr);
}

File diff suppressed because it is too large Load Diff

View File

@@ -33,7 +33,9 @@ void runblock(const std::vector<ROMol *> &mols, unsigned int count,
const std::vector<std::string> &keys) {
for (unsigned int j = 0; j < 200; j++) {
for (unsigned int i = 0; i < mols.size(); ++i) {
if (i % count != idx) continue;
if (i % count != idx) {
continue;
}
ROMol *mol = mols[i];
ExtraInchiReturnValues tmp;
std::string inchi = MolToInchi(*mol, tmp);
@@ -65,13 +67,15 @@ void testMultiThread() {
std::cerr << "reading molecules" << std::endl;
std::vector<ROMol *> mols;
while (!suppl.atEnd() && mols.size() < 100) {
ROMol *mol = 0;
ROMol *mol = nullptr;
try {
mol = suppl.next();
} catch (...) {
continue;
}
if (!mol) continue;
if (!mol) {
continue;
}
mols.push_back(mol);
}
std::cerr << "generating reference data" << std::endl;
@@ -98,7 +102,9 @@ void testMultiThread() {
fut.get();
}
for (unsigned int i = 0; i < mols.size(); ++i) delete mols[i];
for (auto &mol : mols) {
delete mol;
}
BOOST_LOG(rdErrorLog) << " done" << std::endl;
}
@@ -116,7 +122,7 @@ void testGithubIssue3() {
{
std::string fName = getenv("RDBASE");
fName += "/External/INCHI-API/test_data/github3.mol";
ROMol *m = static_cast<ROMol *>(MolFileToMol(fName));
auto *m = static_cast<ROMol *>(MolFileToMol(fName));
TEST_ASSERT(m);
std::string smi = MolToSmiles(*m, true);
TEST_ASSERT(smi == "CNC[C@H](O)[C@@H](O)[C@H](O)[C@H](O)CO");
@@ -128,7 +134,7 @@ void testGithubIssue3() {
"h4-13H,2-3H2,1H3/t4-,5+,6+,7+/m0/s1");
// blow out the stereo information with a copy:
RWMol *m2 = new RWMol(*m);
auto *m2 = new RWMol(*m);
m2->clearComputedProps();
MolOps::sanitizeMol(*m2);
@@ -151,7 +157,7 @@ void testGithubIssue8() {
{
std::string fName = getenv("RDBASE");
fName += "/External/INCHI-API/test_data/github8_extra.mol";
ROMol *m = static_cast<ROMol *>(MolFileToMol(fName, true, false));
auto *m = static_cast<ROMol *>(MolFileToMol(fName, true, false));
TEST_ASSERT(m);
ExtraInchiReturnValues tmp;
@@ -270,7 +276,7 @@ void testGithubIssue296() {
{
std::string fName = getenv("RDBASE");
fName += "/External/INCHI-API/test_data/github296.mol";
ROMol *m = static_cast<ROMol *>(MolFileToMol(fName));
auto *m = static_cast<ROMol *>(MolFileToMol(fName));
TEST_ASSERT(m);
ExtraInchiReturnValues tmp;
std::string inchi = MolToInchi(*m, tmp);

View File

@@ -95,7 +95,7 @@ bool runMol(const ROMol &mol, EHTResults &results, int confId) {
}
}
fill_atomic_parms(unit_cell->atoms, unit_cell->num_atoms, NULL,
fill_atomic_parms(unit_cell->atoms, unit_cell->num_atoms, nullptr,
const_cast<char *>(parmFilePtr));
unit_cell->num_raw_atoms = unit_cell->num_atoms;
charge_to_num_electrons(unit_cell);

View File

@@ -47,12 +47,14 @@ boost::python::object transfer_to_python(T *t) {
}
PyObject *getMatrixProp(const double *mat, unsigned int dim1, unsigned int dim2) {
if (!mat) throw_value_error("matrix has not be initialized");
if (!mat) {
throw_value_error("matrix has not be initialized");
}
npy_intp dims[2];
dims[0] = dim1;
dims[1] = dim2;
PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(2, dims, NPY_DOUBLE);
auto *res = (PyArrayObject *)PyArray_SimpleNew(2, dims, NPY_DOUBLE);
memcpy(PyArray_DATA(res), static_cast<const void *>(mat),
dim1 * dim2 * sizeof(double));
@@ -60,11 +62,13 @@ PyObject *getMatrixProp(const double *mat, unsigned int dim1, unsigned int dim2)
return PyArray_Return(res);
}
PyObject *getSymmMatrixProp(const double *mat, unsigned int sz) {
if (!mat) throw_value_error("matrix has not be initialized");
if (!mat) {
throw_value_error("matrix has not be initialized");
}
npy_intp dims[1];
dims[0] = sz * (sz + 1) / 2;
PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(1, dims, NPY_DOUBLE);
auto *res = (PyArrayObject *)PyArray_SimpleNew(1, dims, NPY_DOUBLE);
memcpy(PyArray_DATA(res), static_cast<const void *>(mat),
dims[0] * sizeof(double));
@@ -72,11 +76,13 @@ PyObject *getSymmMatrixProp(const double *mat, unsigned int sz) {
return PyArray_Return(res);
}
PyObject *getVectorProp(const double *mat, unsigned int sz) {
if (!mat) throw_value_error("vector has not be initialized");
if (!mat) {
throw_value_error("vector has not be initialized");
}
npy_intp dims[1];
dims[0] = sz;
PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(1, dims, NPY_DOUBLE);
auto *res = (PyArrayObject *)PyArray_SimpleNew(1, dims, NPY_DOUBLE);
memcpy(PyArray_DATA(res), static_cast<const void *>(mat),
sz * sizeof(double));