bmeaut / grainautline

GrainAutLine: image processing for geology and material sciences
GNU General Public License v3.0
0 stars 2 forks source link

RJMCMC C++ warnings #74

Closed szotsaki closed 4 years ago

szotsaki commented 9 years ago

Please, fix the following C++ coding warnings which were given by cppcheck:

[MarbleCommon/Processors/RjmcmcProcessor.cpp:41]: (warning) Redundant assignment of 'controller' to itself.
[MarbleCommon/Rjmcmc/Energy/EnergyScaler.h:14]: (warning) Member variable 'EnergyScaler::scalerFunction' is not initialized in the constructor.
[MarbleCommon/Rjmcmc/Energy/EnergyScaler.h:15]: (warning) Member variable 'EnergyScaler::scalerFunction' is not initialized in the constructor.
[MarbleCommon/Rjmcmc/Energy/EnergyScaler.h:15]: (style) Class 'EnergyScaler' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/BlobActionController.cpp:63]: (style) The scope of the variable 'fusingIndex' can be reduced.
[MarbleCommon/Rjmcmc/BlobActionController.cpp:121]: (style) The scope of the variable 'superBlob' can be reduced.
[MarbleCommon/Rjmcmc/Energy/DummyEnergyProvider.h:12]: (style) Class 'DummyEnergyProvider' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/Energy/SimpleEnergyScalerFunction.h:24]: (style) Class 'SimpleEnergyScalerFunction' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/Energy/LineFitter.h:16]: (warning) Member variable 'LineFitter::distType' is not initialized in the constructor.
[MarbleCommon/Rjmcmc/Energy/TwinCrystalEnergyProvider.h:17]: (style) Class 'TwinCrystalEnergyProvider' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/ProbabilityDecider.cpp:11]: (performance) Variable 'r_distribution' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/ProbabilityDecider.cpp:14]: (performance) Variable 'i_distribution' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/RjmcmcLogger.cpp:70]: (performance) Function parameter 'filename' should be passed by reference.
[MarbleCommon/Rjmcmc/RjmcmcLogger.cpp:83]: (performance) Function parameter 'filename' should be passed by reference.
[MarbleCommon/Rjmcmc/RjmcmcLogger.cpp:184]: (performance) Function parameter 'filename' should be passed by reference.
[MarbleCommon/Rjmcmc/RjmcmcLogger.h:39]: (performance) Function parameter 'filename' should be passed by reference.
[MarbleCommon/Rjmcmc/RjmcmcLogger.h:40]: (performance) Function parameter 'filename' should be passed by reference.
[MarbleCommon/Rjmcmc/RjmcmcLogger.h:41]: (performance) Function parameter 'filename' should be passed by reference.
[MarbleCommon/Rjmcmc/Graph.h:18]: (warning) Member variable 'Graph::blobs' is not initialized in the constructor.
[MarbleCommon/Rjmcmc/Graph.h:18]: (warning) Member variable 'Graph::isConnected' is not initialized in the constructor.
[MarbleCommon/Rjmcmc/Graph.h:71]: (style) 'Graph::operator=' should return 'Graph &'.
[MarbleCommon/Rjmcmc/Graph.h:27]: (performance) Variable 'nodeIndices' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/Graph.h:20]: (style) Class 'Graph' has a constructor with 1 argument that is not explicit.
szotsaki commented 8 years ago

Please, fix the current warnings:

[MarbleCommon/Processors/RjmcmcProcessor.h:14]: (style) Class 'RjmcmcProcessor' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/Energy/SeedPoints.cpp:62]: (style) The scope of the variable 'ok' can be reduced.
[MarbleCommon/Rjmcmc/Energy/SeedPoints.h:26]: (style) Class 'SeedPoints' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/Energy/Holes.h:27]: (style) Class 'Holes' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/Probability/ProbabilityV1.cpp:12]: (style) The scope of the variable 'trP' can be reduced.
[MarbleCommon/Rjmcmc/Probability/ProbabilityV1.h:6]: (style) The class 'ProbabilityV1' does not have a constructor.
[MarbleCommon/Rjmcmc/SuperBlobContainer.h:40]: (performance) Variable 'neighbourhoodVector' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/BlobOperation.cpp:12]: (performance) Variable 'superBlobs' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/SuperBlobContainer.h:42]: (style) Class 'NeighbourhoodContainer' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/SuperBlobContainer.h:131]: (style) Class 'SuperBlobContainer' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/SuperBlobContainer.h:133]: (style) Class 'SuperBlobContainer' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/BlobOperation.h:51]: (style) Class 'BlobOperation' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/EnergyFunction.h:21]: (style) Class 'EnergyFunction' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/RJMCMCalgorithm.cpp:75] -> [MarbleCommon/Rjmcmc/RJMCMCalgorithm.cpp:77]: (performance) Variable 'randValue' is reassigned a value before the old one has been used.
[MarbleCommon/Rjmcmc/RJMCMCalgorithm.cpp:19]: (style) The scope of the variable 'superBlobIndex' can be reduced.
[MarbleCommon/Rjmcmc/RJMCMCalgorithm.cpp:120]: (style) The scope of the variable 'transitionIndex' can be reduced.
[MarbleCommon/Rjmcmc/SuperBlobContainer.cpp:13]: (warning) Member variable 'SuperBlobContainer::lastChanged' is not initialized in the constructor.
[MarbleCommon/Rjmcmc/SuperBlobContainer.cpp:15]: (performance) Variable 'superBlobIndices' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/SuperBlobContainer.cpp:22]: (performance) Variable 'neighbourhood' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/SuperBlobContainer.cpp:28]: (performance) Variable 'neighbourhood' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/RJMCMCalgorithm.cpp:3]: (warning) Member variable 'RJMCMCalgorithm::energyDifference' is not initialized in the constructor.
[MarbleCommon/Rjmcmc/RJMCMCalgorithm.cpp:5]: (performance) Variable 'Container' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/RJMCMCalgorithm.h:80]: (style) Class 'RJMCMCalgorithm' has a constructor with 1 argument that is not explicit.
szotsaki commented 8 years ago

The following GCC warnings are present in the codebase. Please, fix them first, before cppcheck warnings.

MarbleCommon/Processors/RjmcmcProcessor.cpp:8:55: warning: unused parameter 'psd' [-Wunused-parameter]
MarbleCommon/Rjmcmc/RJMCMCalgorithm.cpp:79:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
MarbleCommon/Rjmcmc/BlobOperation.cpp:102:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
MarbleCommon/Rjmcmc/BlobOperation.cpp:105:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
MarbleCommon/Rjmcmc/BlobOperation.cpp:114:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
MarbleCommon/Rjmcmc/Energy/Convexity.cpp:3:47: warning: unused parameter 'neighbour' [-Wunused-parameter]
MarbleCommon/Rjmcmc/Energy/Convexity.cpp:3:62: warning: unused parameter 'blobIndex' [-Wunused-parameter]
MarbleCommon/Rjmcmc/Energy/Convexity.cpp:3:95: warning: unused parameter 'Step' [-Wunused-parameter]
MarbleCommon/Rjmcmc/Energy/SeedPoints.cpp:16:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
MarbleCommon/Rjmcmc/Energy/SeedPoints.cpp:34:11: warning: switch missing default case [-Wswitch-default]
MarbleCommon/Rjmcmc/Energy/SeedPoints.cpp:34:11: warning: enumeration value 'STAY' not handled in switch [-Wswitch]
MarbleCommon/Rjmcmc/Energy/SeedPoints.cpp:64:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
MarbleCommon/Rjmcmc/Energy/SeedPoints.cpp:66:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
MarbleCommon/Rjmcmc/Energy/Holes.cpp:32:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
MarbleCommon/Rjmcmc/Energy/Holes.cpp:89:11: warning: switch missing default case [-Wswitch-default]
MarbleCommon/Rjmcmc/Energy/Holes.cpp:89:11: warning: enumeration value 'STAY' not handled in switch [-Wswitch]
MarbleCommon/Rjmcmc/Probability/ProbabilityV1.cpp:14:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
MarbleCommon/Rjmcmc/Probability/ProbabilityV1.cpp:21:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
MarbleCommon/Rjmcmc/Energy/StraightLine.cpp:3:50: warning: unused parameter 'neighbour' [-Wunused-parameter]
MarbleCommon/Rjmcmc/Energy/StraightLine.cpp:3:65: warning: unused parameter 'blobIndex' [-Wunused-parameter]
MarbleCommon/Rjmcmc/Energy/StraightLine.cpp:3:98: warning: unused parameter 'Step' [-Wunused-parameter]
szotsaki commented 8 years ago

Thanks for the GCC fixes. The following cppcheck warnings are still valid:

[MarbleCommon/Rjmcmc/Energy/Holes.h:27]: (style) Class 'Holes' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/Energy/SeedPoints.cpp:68]: (style) The scope of the variable 'ok' can be reduced.
[MarbleCommon/Rjmcmc/Probability/ProbabilityV1.cpp:12]: (style) The scope of the variable 'trP' can be reduced.
[MarbleCommon/Rjmcmc/SuperBlobContainer.h:40]: (performance) Variable 'neighbourhoodVector' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/BlobOperation.cpp:12]: (performance) Variable 'superBlobs' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/SuperBlobContainer.h:42]: (style) Class 'NeighbourhoodContainer' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/SuperBlobContainer.h:131]: (style) Class 'SuperBlobContainer' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/SuperBlobContainer.h:133]: (style) Class 'SuperBlobContainer' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/BlobOperation.h:51]: (style) Class 'BlobOperation' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/Probability/ProbabilityV1.h:6]: (style) The class 'ProbabilityV1' does not have a constructor.
[MarbleCommon/Rjmcmc/Energy/SeedPoints.h:26]: (style) Class 'SeedPoints' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/EnergyFunction.h:21]: (style) Class 'EnergyFunction' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/RJMCMCalgorithm.cpp:75] -> [MarbleCommon/Rjmcmc/RJMCMCalgorithm.cpp:77]: (performance) Variable 'randValue' is reassigned a value before the old one has been used.
[MarbleCommon/Rjmcmc/RJMCMCalgorithm.cpp:19]: (style) The scope of the variable 'superBlobIndex' can be reduced.
[MarbleCommon/Rjmcmc/RJMCMCalgorithm.cpp:120]: (style) The scope of the variable 'transitionIndex' can be reduced.
[MarbleCommon/Rjmcmc/SuperBlobContainer.cpp:13]: (warning) Member variable 'SuperBlobContainer::lastChanged' is not initialized in the constructor.
[MarbleCommon/Rjmcmc/RJMCMCalgorithm.cpp:3]: (warning) Member variable 'RJMCMCalgorithm::energyDifference' is not initialized in the constructor.
[MarbleCommon/Rjmcmc/RJMCMCalgorithm.cpp:5]: (performance) Variable 'Container' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/RJMCMCalgorithm.h:81]: (style) Class 'RJMCMCalgorithm' has a constructor with 1 argument that is not explicit.
[MarbleCommon/Rjmcmc/SuperBlobContainer.cpp:15]: (performance) Variable 'superBlobIndices' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/SuperBlobContainer.cpp:22]: (performance) Variable 'neighbourhood' is assigned in constructor body. Consider performing initialization in initialization list.
[MarbleCommon/Rjmcmc/SuperBlobContainer.cpp:28]: (performance) Variable 'neighbourhood' is assigned in constructor body. Consider performing initialization in initialization list.