Skip to content

Commit

Permalink
Fixed some cppcheck issues in code
Browse files Browse the repository at this point in the history
  • Loading branch information
Gareth Aneurin Tribello authored and Gareth Aneurin Tribello committed Mar 6, 2025
1 parent bea8632 commit a5bf885
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 17 deletions.
9 changes: 0 additions & 9 deletions src/secondarystructure/SecondaryStructureBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,3 @@
along with plumed. If not, see <http://www.gnu.org/licenses/>.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#include "SecondaryStructureBase.h"

//+PLUMEDOC MCOLVAR SECONDARY_STRUCTURE_RMSD
/*
Calclulate the distance between segments of a protein and a reference structure of interest
\par Examples
*/
//+ENDPLUMEDOC
13 changes: 11 additions & 2 deletions src/secondarystructure/SecondaryStructureDRMSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
#include "core/ActionRegister.h"
#include "tools/Matrix.h"

//+PLUMEDOC MCOLVAR SECONDARY_STRUCTURE_DRMSD
/*
Calclulate the distance between segments of a protein and a reference structure of interest
\par Examples
*/
//+ENDPLUMEDOC

namespace PLMD {
namespace secondarystructure {

Expand All @@ -41,7 +50,7 @@ class SecondaryStructureDRMSDInput {
/// The atoms involved in each of the secondary structure segments
Matrix<unsigned> colvar_atoms;
static void calculateDistance( unsigned n, bool noderiv, const SecondaryStructureDRMSDInput& actiondata, const std::vector<Vector>& pos, ColvarOutput& output );
void setReferenceStructure( std::string type, double bondlength, std::vector<Vector>& structure );
void setReferenceStructure( const std::string& type, double bondlength, std::vector<Vector>& structure );
SecondaryStructureDRMSDInput& operator=( const SecondaryStructureDRMSDInput& m ) {

Check warning

Code scanning / CodeQL

Inconsistent definition of copy constructor and assignment ('Rule of Two') Warning

No matching copy constructor in class SecondaryStructureDRMSDInput. It is good practice to match a copy assignment operator with a copy constructor.
natoms = m.natoms;
nstructures = m.nstructures;
Expand All @@ -62,7 +71,7 @@ class SecondaryStructureDRMSDInput {
typedef SecondaryStructureBase<SecondaryStructureDRMSDInput> colv;
PLUMED_REGISTER_ACTION(colv,"SECONDARY_STRUCTURE_DRMSD");

void SecondaryStructureDRMSDInput::setReferenceStructure( std::string type, double bondlength, std::vector<Vector>& structure ) {
void SecondaryStructureDRMSDInput::setReferenceStructure( const std::string& type, double bondlength, std::vector<Vector>& structure ) {
std::map<std::pair<unsigned,unsigned>, double> targets;
for(unsigned i=0; i<structure.size()-1; ++i) {
for(unsigned j=i+1; j<structure.size(); ++j) {
Expand Down
13 changes: 11 additions & 2 deletions src/secondarystructure/SecondaryStructureRMSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
#include "core/ActionRegister.h"
#include "tools/RMSD.h"

//+PLUMEDOC MCOLVAR SECONDARY_STRUCTURE_RMSD
/*
Calclulate the distance between segments of a protein and a reference structure of interest
\par Examples
*/
//+ENDPLUMEDOC

namespace PLMD {
namespace secondarystructure {

Expand All @@ -41,7 +50,7 @@ class SecondaryStructureRMSDInput {
/// The atoms involved in each of the secondary structure segments
Matrix<unsigned> colvar_atoms;
static void calculateDistance( unsigned n, bool noderiv, const SecondaryStructureRMSDInput& actiondata, const std::vector<Vector>& pos, ColvarOutput& output );
void setReferenceStructure( std::string type, double bondlength, std::vector<Vector>& structure );
void setReferenceStructure( const std::string& type, double bondlength, std::vector<Vector>& structure );
SecondaryStructureRMSDInput& operator=( const SecondaryStructureRMSDInput& m ) {

Check warning

Code scanning / CodeQL

Inconsistent definition of copy constructor and assignment ('Rule of Two') Warning

No matching copy constructor in class SecondaryStructureRMSDInput. It is good practice to match a copy assignment operator with a copy constructor.
natoms = m.natoms;
nstructures = m.nstructures;
Expand All @@ -59,7 +68,7 @@ class SecondaryStructureRMSDInput {
typedef SecondaryStructureBase<SecondaryStructureRMSDInput> colv;
PLUMED_REGISTER_ACTION(colv,"SECONDARY_STRUCTURE_RMSD");

void SecondaryStructureRMSDInput::setReferenceStructure( std::string type, double bondlength, std::vector<Vector>& structure ) {
void SecondaryStructureRMSDInput::setReferenceStructure( const std::string& type, double bondlength, std::vector<Vector>& structure ) {
Vector center;
std::vector<double> align( structure.size(), 1.0 ), displace( structure.size(), 1.0 );
for(unsigned i=0; i<structure.size(); ++i) {
Expand Down
2 changes: 2 additions & 0 deletions src/volumes/VolumeBetweenContours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class VolumeInEnvelope {
std::string errors;
sfunc.set(sfunc_str, errors);
switchingFunction.set("GAUSSIAN R_0=1.0 NOSTRETCH", errors );
natoms_in_list = m.natoms_in_list;
natoms_per_list = m.natoms_per_list;
return *this;
}
static void calculateNumberInside( const VolumeInput& input, const VolumeInEnvelope& actioninput, VolumeOutput& output );
Expand Down
8 changes: 6 additions & 2 deletions src/volumes/VolumeCavity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,22 @@ class VolumeCavity {
std::vector<Vector> dlbi, dlcross, dlperp;
std::vector<Tensor> dbi, dcross, dperp;
static void registerKeywords( Keywords& keys );
VolumeCavity() : dlbi(4), dlcross(4), dlperp(4), dbi(3), dcross(3), dperp(3) {}
VolumeCavity() : jacob_det(0), len_bi(0), len_cross(0), len_perp(0), sigma(0), dlbi(4), dlcross(4), dlperp(4), dbi(3), dcross(3), dperp(3) {}
void setupRegions( ActionVolume<VolumeCavity>* action, const Pbc& pbc, const std::vector<Vector>& positions );
void parseInput( ActionVolume<VolumeCavity>* action );
static void parseAtoms( ActionVolume<VolumeCavity>* action, std::vector<AtomNumber>& atoms );
VolumeCavity& operator=( const VolumeCavity& m ) {
jacob_det=m.jacob_det;
len_bi=m.len_bi;
len_cross=m.len_cross;
len_perp=m.len_perp;
sigma=m.sigma;
dlbi.resize(4);
dlcross.resize(4);
dlperp.resize(4);
dbi.resize(3);
dcross.resize(3);
dperp.resize(3);
sigma = m.sigma;
kerneltype=m.kerneltype;
return *this;
}
Expand Down
8 changes: 6 additions & 2 deletions src/volumes/VolumeTetrapore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,22 @@ class VolumeTetrapore {
std::vector<Vector> dlbi, dlcross, dlperp;
std::vector<Tensor> dbi, dcross, dperp;
static void registerKeywords( Keywords& keys );
VolumeTetrapore() : dlbi(4), dlcross(4), dlperp(4), dbi(3), dcross(3), dperp(3) {}
VolumeTetrapore() : jacob_det(0), len_bi(0), len_cross(0), len_perp(0), sigma(0), dlbi(4), dlcross(4), dlperp(4), dbi(3), dcross(3), dperp(3) {}
void setupRegions( ActionVolume<VolumeTetrapore>* action, const Pbc& pbc, const std::vector<Vector>& positions );
void parseInput( ActionVolume<VolumeTetrapore>* action );
static void parseAtoms( ActionVolume<VolumeTetrapore>* action, std::vector<AtomNumber>& atoms );
VolumeTetrapore& operator=( const VolumeTetrapore& m ) {
jacob_det=m.jacob_det;
len_bi=m.len_bi;
len_cross=m.len_cross;
len_perp=m.len_perp;
sigma=m.sigma;
dlbi.resize(4);
dlcross.resize(4);
dlperp.resize(4);
dbi.resize(3);
dcross.resize(3);
dperp.resize(3);
sigma = m.sigma;
kerneltype=m.kerneltype;
return *this;
}
Expand Down

1 comment on commit a5bf885

@PlumedBot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found broken examples in automatic/ANGLES.tmp
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/CAVITY.tmp
Found broken examples in automatic/CLASSICAL_MDS.tmp
Found broken examples in automatic/CLUSTER_DIAMETER.tmp
Found broken examples in automatic/CLUSTER_DISTRIBUTION.tmp
Found broken examples in automatic/CLUSTER_PROPERTIES.tmp
Found broken examples in automatic/CONSTANT.tmp
Found broken examples in automatic/CONTACT_MATRIX.tmp
Found broken examples in automatic/CONTACT_MATRIX_PROPER.tmp
Found broken examples in automatic/CONVERT_TO_FES.tmp
Found broken examples in automatic/COORDINATIONNUMBER.tmp
Found broken examples in automatic/DFSCLUSTERING.tmp
Found broken examples in automatic/DISTANCE_FROM_CONTOUR.tmp
Found broken examples in automatic/DUMPCUBE.tmp
Found broken examples in automatic/DUMPGRID.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/ENVIRONMENTSIMILARITY.tmp
Found broken examples in automatic/FIND_CONTOUR.tmp
Found broken examples in automatic/FIND_CONTOUR_SURFACE.tmp
Found broken examples in automatic/FIND_SPHERICAL_CONTOUR.tmp
Found broken examples in automatic/FOURIER_TRANSFORM.tmp
Found broken examples in automatic/FUNCPATHGENERAL.tmp
Found broken examples in automatic/FUNCPATHMSD.tmp
Found broken examples in automatic/FUNNEL.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/GHBFIX.tmp
Found broken examples in automatic/GPROPERTYMAP.tmp
Found broken examples in automatic/HBOND_MATRIX.tmp
Found broken examples in automatic/HISTOGRAM.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/INCYLINDER.tmp
Found broken examples in automatic/INENVELOPE.tmp
Found broken examples in automatic/INTERPOLATE_GRID.tmp
Found broken examples in automatic/LOCAL_AVERAGE.tmp
Found broken examples in automatic/MAZE_OPTIMIZER_BIAS.tmp
Found broken examples in automatic/MAZE_RANDOM_ACCELERATION_MD.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/METATENSOR.tmp
Found broken examples in automatic/MULTICOLVARDENS.tmp
Found broken examples in automatic/OUTPUT_CLUSTER.tmp
Found broken examples in automatic/PAMM.tmp
Found broken examples in automatic/PCA.tmp
Found broken examples in automatic/PCAVARS.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in automatic/Q3.tmp
Found broken examples in automatic/Q4.tmp
Found broken examples in automatic/Q6.tmp
Found broken examples in automatic/QUATERNION.tmp
Found broken examples in automatic/REWEIGHT_BIAS.tmp
Found broken examples in automatic/REWEIGHT_METAD.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_LINEAR_PROJ.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_MAHA_DIST.tmp
Found broken examples in automatic/SPRINT.tmp
Found broken examples in automatic/TETRAHEDRALPORE.tmp
Found broken examples in automatic/TORSIONS.tmp
Found broken examples in automatic/WHAM_HISTOGRAM.tmp
Found broken examples in automatic/WHAM_WEIGHTS.tmp
Found broken examples in AnalysisPP.md
Found broken examples in CollectiveVariablesPP.md
Found broken examples in MiscelaneousPP.md

Please sign in to comment.