Mlpack: PVS-Studio static code analyzer results

Created on 26 May 2017  路  6Comments  路  Source: mlpack/mlpack

The following is the output of the PVS-Studio static code analyzer, I think we can probably ignore most of the warnings like Not all members of a class are initialized inside the constructor., but there are some warnings that might be interesting. I've also tested clang's static code analyzer, no remarks at all.

  • mlpack/core/util/cli.hpp 173 warn V690
    Copy constructor is declared as private in the 'CLI' class, but the default '=' operator will still be generated by compiler. It is dangerous to use such a class.

  • mlpack/core/util/cli_impl.hpp 68 warn V688
    The 'parameters' local variable possesses the same name as one of the class members, which can result in a confusion.

  • mlpack/core/util/cli_impl.hpp 70 warn V688
    The 'aliases' local variable possesses the same name as one of the class members, which can result in a confusion.

  • mlpack/core/util/cli_impl.hpp 131 warn V688
    The 'desc' local variable possesses the same name as one of the class members, which can result in a confusion.

  • mlpack/core/dists/gaussian_distribution.hpp 45 warn V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: logDetCov.

  • mlpack/core/dists/gaussian_distribution.cpp 22 warn V730
    It is possible that not all members of a class are initialized inside the constructor. Consider inspecting: logDetCov.

  • mlpack/core/optimizers/lbfgs/test_functions.cpp 94 warn V636
    The '1 / 10' expression was implicitly cast from 'int' type to 'double' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;.

  • mlpack/methods/adaboost/adaboost_impl.hpp 56 warn V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: classes, ztProduct.

  • mlpack/core/tree/ballbound_impl.hpp 78 err V591
    Non-void function should return a value.

  • mlpack/core/tree/binary_space_tree/binary_space_tree.hpp 54 warn V690
    The 'BinarySpaceTree' class implements a copy constructor, but lacks the '=' operator. It is dangerous to use such a class.

  • mlpack/core/tree/rectangle_tree/rectangle_tree.hpp 53 warn V690
    The 'RectangleTree' class implements a copy constructor, but lacks the '=' operator. It is dangerous to use such a class.

  • mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp 971 warn V519
    The 'stillShrinking' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 962, 971.

  • mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp 1032 warn V519
    The 'stillShrinking' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 1023, 1032.

  • mlpack/core/tree/rectangle_tree/hilbert_r_tree_split_impl.hpp 79 err V547
    Expression 'firstSibling >= 0' is always true. Unsigned type value is always >= 0.

  • mlpack/core/tree/rectangle_tree/hilbert_r_tree_split_impl.hpp 144 err V547
    Expression 'firstSibling >= 0' is always true. Unsigned type value is always >= 0.

  • mlpack/core/tree/rectangle_tree/hilbert_r_tree_split_impl.hpp 206 err V547
    Expression 'firstSibling >= 0' is always true. Unsigned type value is always >= 0.

  • mlpack/core/tree/spill_tree/spill_tree.hpp 73 warn V690
    The 'SpillTree' class implements a copy constructor, but lacks the '=' operator. It is dangerous to use such a class.

  • mlpack/methods/neighbor_search/neighbor_search_impl.hpp 306 err V591
    Non-void function should return a value.

  • mlpack/methods/neighbor_search/neighbor_search_impl.hpp 359 err V591
    Non-void function should return a value.

  • mlpack/methods/neighbor_search/neighbor_search_impl.hpp 785 warn V560
    A part of conditional expression is always false.

  • mlpack/methods/neighbor_search/neighbor_search_impl.hpp 814 warn V560
    A part of conditional expression is always false.

  • mlpack/methods/neighbor_search/neighbor_search_impl.hpp 860 warn V560
    A part of conditional expression is always false.

  • mlpack/methods/neighbor_search/neighbor_search_impl.hpp 983 warn V560
    A part of conditional expression is always false.

  • mlpack/methods/amf/termination_policies/simple_tolerance_termination.hpp 60 warn V519
    The 'reverseStepCount' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 52, 60.

  • mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp 903 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: numDescendants.

  • mlpack/methods/amf/update_rules/svd_incomplete_incremental_learning.hpp 53 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: currentUserIndex.

  • mlpack/methods/amf/update_rules/svd_complete_incremental_learning.hpp 56 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: currentUserIndex, currentItemIndex.

  • mlpack/methods/amf/update_rules/svd_complete_incremental_learning.hpp 172 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: n, m, isStart.

  • mlpack/methods/amf/termination_policies/simple_residue_termination.hpp 42 warn V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: residue, iteration, normOld, nm.

  • mlpack/core/tree/cover_tree/cover_tree.hpp 99 warn V690
    The 'CoverTree' class implements a copy constructor, but lacks the '=' operator. It is dangerous to use such a class.

  • mlpack/methods/fastmks/fastmks_impl.hpp 192 err V591
    Non-void function should return a value.

  • mlpack/core/tree/cover_tree/cover_tree_impl.hpp 1552 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: distanceComps.

  • mlpack/methods/hoeffding_trees/hoeffding_tree.hpp 61 warn V690
    The 'HoeffdingTree' class implements a copy constructor, but lacks the '=' operator. It is dangerous to use such a class.

  • mlpack/methods/hoeffding_trees/hoeffding_tree_impl.hpp 781 warn V614
    Potentially uninitialized variable 'numChildren' used.

  • mlpack/methods/lars/lars.cpp 337 warn V688
    The 'activeSet' local variable possesses the same name as one of the class members, which can result in a confusion.

  • mlpack/methods/linear_regression/linear_regression.cpp 32 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: intercept.

  • mlpack/core/tree/octree/octree.hpp 25 warn V690
    The 'Octree' class implements a copy constructor, but lacks the '=' operator. It is dangerous to use such a class.

  • mlpack/methods/range_search/range_search_impl.hpp 591 warn V560
    A part of conditional expression is always false.

  • mlpack/methods/range_search/range_search_impl.hpp 616 warn V560
    A part of conditional expression is always false.

  • mlpack/methods/range_search/range_search_impl.hpp 708 warn V560
    A part of conditional expression is always false.

  • mlpack/core/tree/octree/single_tree_traverser_impl.hpp 23 warn V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: numPrunes.

  • mlpack/methods/sparse_coding/sparse_coding.cpp 110 warn V581
    The conditional expressions of the 'if' statements situated alongside each other are identical. Check lines: 105, 110.

  • mlpack/methods/decision_tree/decision_tree_impl.hpp 122 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: splitDimension.

  • mlpack/methods/det/dtree_impl.hpp 216 warn V519
    The 'left' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 215, 216.

  • mlpack/methods/emst/dtb_impl.hpp 233 warn V560
    A part of conditional expression is always false.

  • mlpack/methods/kmeans/dual_tree_kmeans_rules_impl.hpp 160 warn V519
    The 'adjustedScore' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 159, 160.

  • mlpack/methods/kmeans/dual_tree_kmeans_rules_impl.hpp 21 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: lastBaseCase.

  • mlpack/methods/lsh/lsh_search_impl.hpp 200 warn V688
    The 'referenceSet' function argument possesses the same name as one of the class members, which can result in a confusion.

  • mlpack/methods/lsh/lsh_search_impl.hpp 201 warn V688
    The 'numProj' function argument possesses the same name as one of the class members, which can result in a confusion.

  • mlpack/methods/lsh/lsh_search_impl.hpp 202 warn V688
    The 'numTables' function argument possesses the same name as one of the class members, which can result in a confusion.

  • mlpack/methods/lsh/lsh_search_impl.hpp 204 warn V688
    The 'secondHashSize' function argument possesses the same name as one of the class members, which can result in a confusion.

  • mlpack/methods/lsh/lsh_search_impl.hpp 205 warn V688
    The 'bucketSize' function argument possesses the same name as one of the class members, which can result in a confusion.

  • mlpack/methods/neighbor_search/ns_model_impl.hpp 444 warn V688
    The 'leafSize' function argument possesses the same name as one of the class members, which can result in a confusion.

  • mlpack/methods/rann/ra_search_impl.hpp 503 warn V560
    A part of conditional expression is always false.

  • mlpack/methods/rann/ra_search_impl.hpp 523 warn V560
    A part of conditional expression is always false.

  • mlpack/methods/rann/ra_search_impl.hpp 607 warn V560
    A part of conditional expression is always false.

  • mlpack/methods/rann/ra_model_impl.hpp 747 warn V688
    The 'leafSize' function argument possesses the same name as one of the class members, which can result in a confusion.

  • mlpack/methods/ann/activation_functions/rectifier_function.hpp 93 warn V601
    The bool type is implicitly cast to the double type.

  • mlpack/methods/ann/layer/reinforce_normal_impl.hpp 32 warn V747
    An odd expression inside parenthesis. It is possible that a function name is missing.

  • mlpack/methods/ann/layer/convolution_impl.hpp 136 err V603
    The object was created but it is not being used. If you wish to call constructor, 'this->Convolution::Convolution(....)' should be used.

  • mlpack/methods/ann/layer/convolution_impl.hpp 141 err V603
    The object was created but it is not being used. If you wish to call constructor, 'this->Convolution::Convolution(....)' should be used.

  • mlpack/methods/ann/layer/convolution_impl.hpp 187 err V603
    The object was created but it is not being used. If you wish to call constructor, 'this->Convolution::Convolution(....)' should be used.

  • mlpack/methods/ann/layer/convolution_impl.hpp 259 err V603
    The object was created but it is not being used. If you wish to call constructor, 'this->Convolution::Convolution(....)' should be used.

  • mlpack/methods/ann/layer/dropout_impl.hpp 23 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: deterministic.

  • mlpack/methods/ann/layer/join_impl.hpp 22 warn V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: inSizeRows, inSizeCols.

  • mlpack/methods/ann/layer/max_pooling_impl.hpp 29 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: inSize, outSize.

  • mlpack/methods/ann/layer/mean_pooling_impl.hpp 29 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: inSize, outSize.

  • mlpack/methods/ann/layer/reinforce_normal_impl.hpp 18 warn V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: reward, deterministic.

  • mlpack/methods/ann/layer/linear_impl.hpp 23 warn V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: inSize, outSize.

  • mlpack/methods/ann/layer/sequential_impl.hpp 29 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: width, height.

  • mlpack/methods/ann/layer/dropconnect_impl.hpp 31 warn V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: ratio, scale, deterministic.

  • mlpack/methods/ann/layer/dropconnect_impl.hpp 37 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: deterministic.

  • mlpack/methods/ann/layer/glimpse_impl.hpp 19 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: outputWidth, outputHeight, inputDepth, deterministic.

  • mlpack/methods/ann/layer/linear_no_bias_impl.hpp 23 warn V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: inSize, outSize.

  • mlpack/methods/ann/layer/vr_class_reward_impl.hpp 20 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: reward, deterministic.

  • mlpack/methods/ann/init_rules/random_init.hpp 58 warn V747
    An odd expression inside parenthesis. It is possible that a function name is missing.

  • mlpack/methods/ann/init_rules/random_init.hpp 58 err V562
    It's odd to compare a bool type value with a value of double type.

  • mlpack/methods/ann/ffn_impl.hpp 31 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: numFunctions, deterministic.

  • mlpack/methods/ann/rnn_impl.hpp 31 err V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: numFunctions, deterministic.

  • mlpack/tests/decision_tree_test.cpp 320 warn V636
    The 'i / 3' expression was implicitly cast from 'size_t' type to 'double' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;.

  • mlpack/tests/decision_tree_test.cpp 322 warn V636
    The 'i / 3' expression was implicitly cast from 'size_t' type to 'double' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;.

  • mlpack/tests/decision_tree_test.cpp 324 warn V636
    The 'i / 3' expression was implicitly cast from 'size_t' type to 'double' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;.

  • mlpack/tests/hmm_test.cpp 198 warn V760
    Two identical blocks of text were found. The second block begins from line 204.

  • mlpack/methods/hoeffding_trees/binary_numeric_split_info.hpp 25 warn V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: splitPoint.

  • mlpack/tests/recurrent_network_test.cpp 45 warn V747
    An odd expression inside parenthesis. It is possible that a function name is missing.

  • mlpack/tests/recurrent_network_test.cpp 45 err V562
    It's odd to compare a bool type value with a value of double type.

  • mlpack/tests/recurrent_network_test.cpp 387 warn V756
    The 'i' counter is not used inside a nested loop. Consider inspecting usage of 'j' counter.

  • mlpack/tests/recurrent_network_test.cpp 585 warn V756
    The 'i' counter is not used inside a nested loop. Consider inspecting usage of 'j' counter.

  • mlpack/methods/reinforcement_learning/environment/cart_pole.hpp 140 warn V768
    The variable 'action' is of enum type. It is odd that it is used as a variable of a Boolean-type.

  • mlpack/tests/sdp_primal_dual_test.cpp 30 warn V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: numVertices.

  • mlpack/methods/amf/termination_policies/incomplete_incremental_termination.hpp 36 warn V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: incrementalIndex, iteration.

  • mlpack/methods/amf/termination_policies/complete_incremental_termination.hpp 37 warn V730
    Not all members of a class are initialized inside the constructor. Consider inspecting: incrementalIndex, iteration.

core methods help wanted keep open stale bug report

All 6 comments

Nice results, I have always wondered what a static analyzer would dig up. I'll try to take a look at the individual issues this week.

I think one of the more interesting issues are:

  • mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp 971 warn V519
    The 'stillShrinking' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 962, 971.

  • mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp 1032 warn V519
    The 'stillShrinking' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 1023, 1032.

  • mlpack/methods/amf/termination_policies/simple_tolerance_termination.hpp 60 warn V519
    The 'reverseStepCount' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 52, 60.

  • mlpack/methods/det/dtree_impl.hpp 216 warn V519
    The 'left' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 215, 216.

  • mlpack/methods/kmeans/dual_tree_kmeans_rules_impl.hpp 160 warn V519
    The 'adjustedScore' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 159, 160.

I wonder why clang missed something like that:

// Copy the children.
left = ((obj.left == NULL) ? NULL : new DTree(*obj.left));
left = ((obj.right == NULL) ? NULL : new DTree(*obj.right));

Hey @zoq can I take this up and fix the issues highlighted in your second comment?
The open PR hasn't been worked on for a while.

I think @rcurtin is more than happy to share the work, let's see what he likes to do here.

Hi @Sayan98, please feel free to use #1022 as a starting point. I ran out of time and was not able to fully address that one. In many cases it involved implementing copy/move constructors and operators for a lot of classes, so I think there are still a few places where that needs to be done.

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions! :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

birm picture birm  路  4Comments

mrityunjay-tripathi picture mrityunjay-tripathi  路  6Comments

Manthan-R-Sheth picture Manthan-R-Sheth  路  3Comments

bisakhmondal picture bisakhmondal  路  3Comments

KimSangYeon-DGU picture KimSangYeon-DGU  路  3Comments