-
Notifications
You must be signed in to change notification settings - Fork 845
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
Dev/pvs studio cleanups2 #2877
Dev/pvs studio cleanups2 #2877
Conversation
@@ -1221,8 +1220,8 @@ O3A::O3A(int (*costFunc)(const unsigned int, const unsigned int, double, | |||
double (*weightFunc)(const unsigned int, const unsigned int, void *), | |||
double (*scoringFunc)(const unsigned int, const unsigned int, void *), | |||
void *data, ROMol &prbMol, const ROMol &refMol, const int prbCid, | |||
const int refCid, boost::dynamic_bitset<> *prbHvyAtoms, | |||
boost::dynamic_bitset<> *refHvyAtoms, const bool reflect, | |||
const int refCid, const boost::dynamic_bitset<> &prbHvyAtoms, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching these two dynamic_bitset
arguments to references ends up clearing up a bug (likely never observed in real code) when prbHvyAtoms
was null.
@@ -689,8 +690,7 @@ void addRecursiveQueries( | |||
RWMol *m = 0; | |||
try { | |||
m = SmartsToMol(maybeSmarts); | |||
if (!m) | |||
throw KeyErrorException(pval); | |||
if (!m) throw KeyErrorException(pval); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy has an option to automatically add brackets to single-line blocks. I find that I prefer the explicit brackets, not sure how others feel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If's feel naked without braces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed that they are desirable. I will look at adding that option and doing a pass to reformat everything after we get this one merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that was really an aside, sorry.
@@ -176,14 +176,14 @@ def test3MultiConf(self): | |||
cids = rdDistGeom.EmbedMultipleConfs(mol, 10, maxAttempts=30, randomSeed=100, | |||
useExpTorsionAnglePrefs=False, | |||
useBasicKnowledge=False) | |||
energies = [115.460, 105.891, 109.868, 104.415, | |||
92.944, 140.917, 139.468, 95.081, 123.528, 107.885] | |||
energies = [116.330, 106.246, 109.816, 104.890, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense that these values changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that was part of the fix that's in #2875
@@ -146,6 +145,7 @@ Conformer *ParseConfData(std::istream *inStream, unsigned int &line, RWMol *mol, | |||
boost::split(splitLine, tempStr, boost::is_any_of(" \t"), | |||
boost::token_compress_on); | |||
if (splitLine.size() < 3) { | |||
delete conf; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
@d-b-w, @bp-kelley : you guys commented, but didn't indicate whether or not you approve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there are a ton of formatting changes, this is slow going for me.
return true; | ||
} | ||
|
||
const RGROUPS &EvenSamplePairsStrategy::next() { | ||
nslack = 0; | ||
while (m_numPermutationsProcessed < rdcast<boost::uint64_t>(m_numPermutations)) { | ||
bool added = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was added dropped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, the return is the control flow here.
@@ -1600,9 +1600,6 @@ ROMol *reduceProductToSideChains(const ROMOL_SPTR &product, | |||
|
|||
if (atommapno) { | |||
Atom *at = mol->getAtomWithIdx(idx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't at be null? What is the guarantee here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Atom::getAtomWtihIdx()
does not return nullptr. It has a POSTCONDITION
on its result.
std::vector<MatchVectType> fgpMatches; | ||
std::vector<MatchVectType>::const_iterator mati; | ||
VECT_INT_VECT matches; // all matches on the molecule - list of list of atom ids | ||
VECT_INT_VECT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is odd formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. Hopefully it will get fixed when I do the full clang-tidy run
@@ -656,8 +657,8 @@ std::pair<std::string, RWMol*> MaximumCommonSubgraph::generateResultSMARTSAndQue | |||
// Generate result's SMARTS | |||
|
|||
// create molecule from MCS for MolToSmarts() | |||
RWMol *mol = new RWMol(); | |||
const RingInfo *ri = QueryMolecule->getRingInfo(); | |||
RWMol* mol = new RWMol(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to say, I'm not a fan of this formatting.
RWMol* m, mol;
Doesn't do what you might expect. The *,& qualifier is a qualifier for the variable not the type unless you use a typedef.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just double checked, and clang-format formats these lines differently:
RWMol* mol = new RWMol();
and:
RWMol *m, mol;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Odd, I'm only getting that style when I use --style=Mozilla
clang-format foo.cpp --style=Mozilla
void
f()
{
RWMol* m = new RWMol(m);
RWMol *m, mol;
}
clang-format foo.cpp --style=file (.clang-format from rdkit)
void f() {
RWMol *m = new RWMol(m);
RWMol *m, mol;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something is probably messed up with my vs-code config. I will take a look.
But, again, this will hopefully be dealt with when I re-run clang-tidy after this PR is merged
@@ -2321,6 +2321,39 @@ void testMACCS() { | |||
delete m1; | |||
delete fp1; | |||
} | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this test new?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, PVS/Studio gave some spurious warnings/errors about parts of the MACCS generation code and I wanted to add a test to make sure that they actually were incorrect
Code/SimDivPickers/LeaderPicker.h
Outdated
@@ -329,6 +330,9 @@ struct LeaderPickerState { | |||
v.resize(count); | |||
for (unsigned int i = 0; i < count; i++) v[i] = i; | |||
left = count; | |||
threshold = 0.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, but these would be better in the initializer list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
@@ -372,7 +372,7 @@ MolOps::SanitizeFlags sanitizeMol(ROMol &mol, boost::uint64_t sanitizeOps, | |||
} | |||
|
|||
RWMol *getEditable(const ROMol &mol) { | |||
RWMol *res = static_cast<RWMol *>(new ROMol(mol, false)); | |||
RWMol *res = new RWMol(mol, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, the formatting isn't consistent here for RWMol* res versus RWMol *res.
PRECONDITION(rootedAtAtom < 0 || static_cast<unsigned int>( | ||
rootedAtAtom) < mol.getNumAtoms(), | ||
"rootedAtomAtom must be less than the number of atoms"); | ||
PRECONDITION( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fairly sure this precondition is always true due to the mod (%)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
@@ -137,6 +144,8 @@ static unsigned int NMDetermineComponents(RWMol *mol, unsigned int *parts, | |||
|
|||
static std::string NMMolecularFormula(RWMol *mol, const unsigned int *parts, | |||
unsigned int part) { | |||
PRECONDITION(mol, "bad molecule"); | |||
PRECONDITION((!part || parts), "bad parts pointer"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear there is no parts[part==0] and part is 1 indexed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I will add a test to make sure the molformula hash works when the molecule has multiple fragments
+ a bit of reformatting that snuck in
@bp-kelley, @d-b-w : ok to merge this with the changes I made? |
This is like #2531: a series of fixes suggested by PVS/Studio.
Again, it's mostly warnings, but there are a couple of real bug fixes in there.
Note that one of the fixes here is redundant with #2875 (I applied a cherry pick of the relevant commit to do that PR so that we can be sure it's in the release notes).