Conversation
PerThread and Shared in threaded_loop.h now longer use references as data members. This fixes some errors when compiling with C++20 as the minimum standard (due to errors in initialising the variables in the constructors) and also allows us to avoid following the rule of 5 (e.g. no need to define custom copy/move constructors and assignment operators).
| @@ -165,17 +167,20 @@ void usage() { | |||
| // clang-format on | |||
|
|
|||
| void run() { | |||
There was a problem hiding this comment.
warning: function 'run' has cognitive complexity of 193 (threshold 25) [readability-function-cognitive-complexity]
void run() {
^Additional context
cpp/cmd/connectome2tck.cpp:185: +1, including nesting penalty of 0, nesting level increased to 1
while (std::getline(stream, line)) {
^cpp/cmd/connectome2tck.cpp:187: +2, including nesting penalty of 1, nesting level increased to 2
if (line.empty())
^cpp/cmd/connectome2tck.cpp:191: +2, including nesting penalty of 1, nesting level increased to 2
while (1) {
^cpp/cmd/connectome2tck.cpp:194: +3, including nesting penalty of 2, nesting level increased to 3
if (!line_stream)
^cpp/cmd/connectome2tck.cpp:199: +2, including nesting penalty of 1, nesting level increased to 2
if (nodes.size() != 2)
^cpp/cmd/connectome2tck.cpp:205: +1, including nesting penalty of 0, nesting level increased to 1
INFO("Maximum node index in assignments file is " + str(max_node_index));
^cpp/core/exception.h:74: expanded from macro 'INFO'
if (MR::App::log_level >= 2) \
^cpp/cmd/connectome2tck.cpp:208: +1, including nesting penalty of 0, nesting level increased to 1
if (assignments_lists.size() != count)
^cpp/cmd/connectome2tck.cpp:217: +1, including nesting penalty of 0, nesting level increased to 1
if (!nonpair_found) {
^cpp/cmd/connectome2tck.cpp:218: +2, including nesting penalty of 1, nesting level increased to 2
INFO("Assignments file contains node pair for every streamline; operating accordingly");
^cpp/core/exception.h:74: expanded from macro 'INFO'
if (MR::App::log_level >= 2) \
^cpp/cmd/connectome2tck.cpp:220: +2, including nesting penalty of 1, nesting level increased to 2
for (auto i = assignments_lists.begin(); i != assignments_lists.end(); ++i)
^cpp/cmd/connectome2tck.cpp:226: +1, including nesting penalty of 0, nesting level increased to 1
const node_t first_node = get_options("keep_unassigned").empty() ? 1 : 0;
^cpp/cmd/connectome2tck.cpp:233: +1, including nesting penalty of 0, nesting level increased to 1
if (!opt.empty()) {
^cpp/cmd/connectome2tck.cpp:238: +2, including nesting penalty of 1, nesting level increased to 2
for (auto i : data) {
^cpp/cmd/connectome2tck.cpp:239: +3, including nesting penalty of 2, nesting level increased to 3
if (i > max_node_index) {
^cpp/cmd/connectome2tck.cpp:240: +4, including nesting penalty of 3, nesting level increased to 4
WARN("Node of interest " + str(i) + " is above the maximum detected node index of " + str(max_node_index));
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/connectome2tck.cpp:241: +1, nesting level increased to 3
} else {
^cpp/cmd/connectome2tck.cpp:243: +4, including nesting penalty of 3, nesting level increased to 4
if (!i)
^cpp/cmd/connectome2tck.cpp:247: +2, including nesting penalty of 1, nesting level increased to 2
if (!zero_in_list && !first_node)
^cpp/cmd/connectome2tck.cpp:247: +1
if (!zero_in_list && !first_node)
^cpp/cmd/connectome2tck.cpp:250: +1, nesting level increased to 1
} else {
^cpp/cmd/connectome2tck.cpp:251: +2, including nesting penalty of 1, nesting level increased to 2
for (node_t i = first_node; i <= max_node_index; ++i)
^cpp/cmd/connectome2tck.cpp:256: +1, including nesting penalty of 0, nesting level increased to 1
if (exclusive && !manual_node_list)
^cpp/cmd/connectome2tck.cpp:256: +1
if (exclusive && !manual_node_list)
^cpp/cmd/connectome2tck.cpp:257: +2, including nesting penalty of 1, nesting level increased to 2
WARN("List of nodes of interest not provided; -exclusive option will have no effect");
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/connectome2tck.cpp:262: +1, including nesting penalty of 0, nesting level increased to 1
if (!opt.empty()) {
^cpp/cmd/connectome2tck.cpp:264: +2, including nesting penalty of 1, nesting level increased to 2
if (keep_self)
^cpp/cmd/connectome2tck.cpp:265: +3, including nesting penalty of 2, nesting level increased to 3
WARN("Exemplars cannot be calculated for node self-connections; -keep_self option ignored");
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/connectome2tck.cpp:272: +2, including nesting penalty of 1, nesting level increased to 2
for (auto i = Loop()(image); i; ++i) {
^cpp/cmd/connectome2tck.cpp:274: +3, including nesting penalty of 2, nesting level increased to 3
if (index) {
^cpp/cmd/connectome2tck.cpp:275: +4, including nesting penalty of 3, nesting level increased to 4
while (index >= COMs.size()) {
^cpp/cmd/connectome2tck.cpp:283: +2, including nesting penalty of 1, nesting level increased to 2
if (COMs.size() > max_node_index + 1) {
^cpp/cmd/connectome2tck.cpp:284: +3, including nesting penalty of 2, nesting level increased to 3
WARN("Parcellation image \"" + exemplars_input_path.string() +
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/connectome2tck.cpp:291: +2, including nesting penalty of 1, nesting level increased to 2
for (node_t index = 1; index <= max_node_index; ++index) {
^cpp/cmd/connectome2tck.cpp:292: +3, including nesting penalty of 2, nesting level increased to 3
if (volumes[index])
^cpp/cmd/connectome2tck.cpp:295: +1, nesting level increased to 3
else
^cpp/cmd/connectome2tck.cpp:305: +2, including nesting penalty of 1, nesting level increased to 2
if (!assignments_pairs.empty()) {
^cpp/cmd/connectome2tck.cpp:306: nesting level increased to 3
auto loader = [&](Tractography::Connectome::Streamline_nodepair &out) {
^cpp/cmd/connectome2tck.cpp:307: +4, including nesting penalty of 3, nesting level increased to 4
if (!reader(out))
^cpp/cmd/connectome2tck.cpp:312: nesting level increased to 3
auto worker = [&](const Tractography::Connectome::Streamline_nodepair &in) {
^cpp/cmd/connectome2tck.cpp:320: +1, nesting level increased to 2
} else {
^cpp/cmd/connectome2tck.cpp:321: nesting level increased to 3
auto loader = [&](Tractography::Connectome::Streamline_nodelist &out) {
^cpp/cmd/connectome2tck.cpp:322: +4, including nesting penalty of 3, nesting level increased to 4
if (!reader(out))
^cpp/cmd/connectome2tck.cpp:327: nesting level increased to 3
auto worker = [&](const Tractography::Connectome::Streamline_nodelist &in) {
^cpp/cmd/connectome2tck.cpp:341: +2, including nesting penalty of 1, nesting level increased to 2
if (file_format == 0) { // One file per edge
^cpp/cmd/connectome2tck.cpp:342: +3, including nesting penalty of 2, nesting level increased to 3
if (exclusive) {
^cpp/cmd/connectome2tck.cpp:344: +4, including nesting penalty of 3, nesting level increased to 4
for (size_t i = 0; i != nodes.size(); ++i) {
^cpp/cmd/connectome2tck.cpp:346: +5, including nesting penalty of 4, nesting level increased to 5
for (size_t j = i + 1; j != nodes.size(); ++j) {
^cpp/cmd/connectome2tck.cpp:351: +6, including nesting penalty of 5, nesting level increased to 6
!weights_prefix.empty() ? (weights_prefix + str(one) + "-" + str(two) + ".csv") : "");
^cpp/cmd/connectome2tck.cpp:355: +1, nesting level increased to 3
} else {
^cpp/cmd/connectome2tck.cpp:358: +4, including nesting penalty of 3, nesting level increased to 4
for (std::vector<node_t>::const_iterator n = nodes.begin(); n != nodes.end(); ++n) {
^cpp/cmd/connectome2tck.cpp:359: +5, including nesting penalty of 4, nesting level increased to 5
for (size_t i = first_node; i != COMs.size(); ++i) {
^cpp/cmd/connectome2tck.cpp:363: +6, including nesting penalty of 5, nesting level increased to 6
!weights_prefix.empty() ? (weights_prefix + str(*n) + "-" + str(i) + ".csv") : "");
^cpp/cmd/connectome2tck.cpp:368: +1, nesting level increased to 2
} else if (file_format == 1) { // One file per node
^cpp/cmd/connectome2tck.cpp:370: +3, including nesting penalty of 2, nesting level increased to 3
for (std::vector<node_t>::const_iterator n = nodes.begin(); n != nodes.end(); ++n) {
^cpp/cmd/connectome2tck.cpp:372: +4, including nesting penalty of 3, nesting level increased to 4
*n, output_prefix + str(*n) + ".tck", !weights_prefix.empty() ? (weights_prefix + str(*n) + ".csv") : "");
^cpp/cmd/connectome2tck.cpp:375: +1, nesting level increased to 2
} else if (file_format == 2) { // Single file
^cpp/cmd/connectome2tck.cpp:377: +3, including nesting penalty of 2, nesting level increased to 3
if (path.rfind(".tck") != path.size() - 4)
^cpp/cmd/connectome2tck.cpp:380: +3, including nesting penalty of 2, nesting level increased to 3
if (!weights_prefix.empty() && weights_path.rfind(".tck") != weights_path.size() - 4)
^cpp/cmd/connectome2tck.cpp:380: +1
if (!weights_prefix.empty() && weights_path.rfind(".tck") != weights_path.size() - 4)
^cpp/cmd/connectome2tck.cpp:385: +1, nesting level increased to 1
} else { // Old behaviour ie. all tracks, rather than generating exemplars
^cpp/cmd/connectome2tck.cpp:389: +2, including nesting penalty of 1, nesting level increased to 2
switch (file_format) {
^cpp/cmd/connectome2tck.cpp:391: +3, including nesting penalty of 2, nesting level increased to 3
for (size_t i = 0; i != nodes.size(); ++i) {
^cpp/cmd/connectome2tck.cpp:393: +4, including nesting penalty of 3, nesting level increased to 4
if (exclusive) {
^cpp/cmd/connectome2tck.cpp:394: +5, including nesting penalty of 4, nesting level increased to 5
for (size_t j = i; j != nodes.size(); ++j) {
^cpp/cmd/connectome2tck.cpp:399: +6, including nesting penalty of 5, nesting level increased to 6
!weights_prefix.empty() ? (weights_prefix + str(one) + "-" + str(two) + ".csv") : "");
^cpp/cmd/connectome2tck.cpp:401: +1, nesting level increased to 4
} else {
^cpp/cmd/connectome2tck.cpp:403: +5, including nesting penalty of 4, nesting level increased to 5
for (node_t two = first_node; two <= max_node_index; ++two)
^cpp/cmd/connectome2tck.cpp:407: +6, including nesting penalty of 5, nesting level increased to 6
!weights_prefix.empty() ? (weights_prefix + str(one) + "-" + str(two) + ".csv") : "");
^cpp/cmd/connectome2tck.cpp:410: +3, including nesting penalty of 2, nesting level increased to 3
INFO("A total of " + str(writer.file_count()) + " output track files will be generated (one for each edge)");
^cpp/core/exception.h:74: expanded from macro 'INFO'
if (MR::App::log_level >= 2) \
^cpp/cmd/connectome2tck.cpp:413: +3, including nesting penalty of 2, nesting level increased to 3
for (std::vector<node_t>::const_iterator i = nodes.begin(); i != nodes.end(); ++i)
^cpp/cmd/connectome2tck.cpp:415: +4, including nesting penalty of 3, nesting level increased to 4
*i, output_prefix + str(*i) + ".tck", !weights_prefix.empty() ? (weights_prefix + str(*i) + ".csv") : "");
^cpp/cmd/connectome2tck.cpp:416: +3, including nesting penalty of 2, nesting level increased to 3
INFO("A total of " + str(writer.file_count()) + " output track files will be generated (one for each node)");
^cpp/core/exception.h:74: expanded from macro 'INFO'
if (MR::App::log_level >= 2) \
^cpp/cmd/connectome2tck.cpp:420: +3, including nesting penalty of 2, nesting level increased to 3
if (path.extension() != ".tck")
^cpp/cmd/connectome2tck.cpp:423: +3, including nesting penalty of 2, nesting level increased to 3
if (weights_path.extension() != ".csv")
^cpp/cmd/connectome2tck.cpp:430: +2, including nesting penalty of 1, nesting level increased to 2
if (assignments_pairs.empty()) {
^cpp/cmd/connectome2tck.cpp:432: +3, including nesting penalty of 2, nesting level increased to 3
while (reader(tck)) {
^cpp/cmd/connectome2tck.cpp:437: +1, nesting level increased to 2
} else {
^cpp/cmd/connectome2tck.cpp:439: +3, including nesting penalty of 2, nesting level increased to 3
while (reader(tck)) {
^| @@ -61,30 +63,34 @@ void usage() { | |||
|
|
|||
| void run() { | |||
There was a problem hiding this comment.
warning: function 'run' has cognitive complexity of 51 (threshold 25) [readability-function-cognitive-complexity]
void run() {
^Additional context
cpp/cmd/fixel2peaks.cpp:71: +1, including nesting penalty of 0, nesting level increased to 1
if (Fixel::is_index_image(input_header)) {
^cpp/cmd/fixel2peaks.cpp:74: +1, nesting level increased to 1
} else if (Fixel::is_directions_file(input_header)) {
^cpp/cmd/fixel2peaks.cpp:77: +1, nesting level increased to 1
} else if (Fixel::is_data_file(input_header)) {
^cpp/cmd/fixel2peaks.cpp:82: +1, nesting level increased to 1
} else {
^cpp/cmd/fixel2peaks.cpp:85: +1, including nesting penalty of 0, nesting level increased to 1
} catch (Exception &e_asimage) {
^cpp/cmd/fixel2peaks.cpp:87: +2, including nesting penalty of 1, nesting level increased to 2
if (!Path::is_dir(input_path))
^cpp/cmd/fixel2peaks.cpp:91: +2, including nesting penalty of 1, nesting level increased to 2
} catch (Exception &e_asdir) {
^cpp/cmd/fixel2peaks.cpp:94: +3, including nesting penalty of 2, nesting level increased to 3
for (size_t i = 0; i != e_asimage.num(); ++i)
^cpp/cmd/fixel2peaks.cpp:97: +3, including nesting penalty of 2, nesting level increased to 3
for (size_t i = 0; i != e_asdir.num(); ++i)
^cpp/cmd/fixel2peaks.cpp:106: +1, including nesting penalty of 0, nesting level increased to 1
if (data_header.valid())
^cpp/cmd/fixel2peaks.cpp:111: +1, including nesting penalty of 0, nesting level increased to 1
if (!opt.empty()) {
^cpp/cmd/fixel2peaks.cpp:113: +1, nesting level increased to 1
} else {
^cpp/cmd/fixel2peaks.cpp:114: +2, including nesting penalty of 1, nesting level increased to 2
for (auto l = Loop(index_image, 0, 3)(index_image); l; ++l)
^cpp/cmd/fixel2peaks.cpp:116: +2, including nesting penalty of 1, nesting level increased to 2
INFO("Maximum number of fixels in any given voxel: " + str(max_fixel_count));
^cpp/core/exception.h:74: expanded from macro 'INFO'
if (MR::App::log_level >= 2) \
^cpp/cmd/fixel2peaks.cpp:126: +1, including nesting penalty of 0, nesting level increased to 1
const float fill = !get_options("nan").empty() ? NaN : 0.0F;
^cpp/cmd/fixel2peaks.cpp:128: +1, including nesting penalty of 0, nesting level increased to 1
if (data_image.valid()) {
^cpp/cmd/fixel2peaks.cpp:129: +2, including nesting penalty of 1, nesting level increased to 2
for (auto l = Loop("converting fixel data file to peaks image", index_image, 0, 3)(index_image, out_image); l;
^cpp/cmd/fixel2peaks.cpp:132: +3, including nesting penalty of 2, nesting level increased to 3
for (auto f = Fixel::Loop(index_image)(directions_image, data_image); f && out_image.index(3) < out_image.size(3);
^cpp/cmd/fixel2peaks.cpp:132: +1
for (auto f = Fixel::Loop(index_image)(directions_image, data_image); f && out_image.index(3) < out_image.size(3);
^cpp/cmd/fixel2peaks.cpp:134: +4, including nesting penalty of 3, nesting level increased to 4
for (size_t axis = 0; axis != 3; ++axis) {
^cpp/cmd/fixel2peaks.cpp:140: +3, including nesting penalty of 2, nesting level increased to 3
for (; out_image.index(3) != out_image.size(3); ++out_image.index(3))
^cpp/cmd/fixel2peaks.cpp:143: +1, nesting level increased to 1
} else {
^cpp/cmd/fixel2peaks.cpp:144: +2, including nesting penalty of 1, nesting level increased to 2
for (auto l = Loop("converting fixels to peaks image", index_image, 0, 3)(index_image, out_image); l; ++l) {
^cpp/cmd/fixel2peaks.cpp:146: +3, including nesting penalty of 2, nesting level increased to 3
for (auto f = Fixel::Loop(index_image)(directions_image); f && out_image.index(3) < out_image.size(3); ++f) {
^cpp/cmd/fixel2peaks.cpp:146: +1
for (auto f = Fixel::Loop(index_image)(directions_image); f && out_image.index(3) < out_image.size(3); ++f) {
^cpp/cmd/fixel2peaks.cpp:147: +4, including nesting penalty of 3, nesting level increased to 4
for (directions_image.index(1) = 0; directions_image.index(1) != 3; ++directions_image.index(1)) {
^cpp/cmd/fixel2peaks.cpp:152: +3, including nesting penalty of 2, nesting level increased to 3
for (; out_image.index(3) != out_image.size(3); ++out_image.index(3))
^| @@ -200,7 +202,14 @@ class SubjectFixelImport : public Math::Stats::SubjectDataImportBase { | |||
| }; | |||
|
|
|||
| void run() { | |||
There was a problem hiding this comment.
warning: function 'run' has cognitive complexity of 132 (threshold 25) [readability-function-cognitive-complexity]
void run() {
^Additional context
cpp/cmd/fixelcfestats.cpp:211: +1, including nesting penalty of 0, nesting level increased to 1
if (Path::has_suffix(connectivity_matrix_path, ".tck"))
^cpp/cmd/fixelcfestats.cpp:230: +1, including nesting penalty of 0, nesting level increased to 1
CONSOLE("Number of fixels in template: " + str(num_fixels));
^cpp/core/exception.h:65: expanded from macro 'CONSOLE'
if (MR::App::log_level >= 1) \
^cpp/cmd/fixelcfestats.cpp:235: +1, including nesting penalty of 0, nesting level increased to 1
if (!opt.empty()) {
^cpp/cmd/fixelcfestats.cpp:238: +2, including nesting penalty of 1, nesting level increased to 2
if (!Fixel::fixels_match(index_header, mask))
^cpp/cmd/fixelcfestats.cpp:240: +2, including nesting penalty of 1, nesting level increased to 2
for (auto l = Loop(0)(mask); l; ++l) {
^cpp/cmd/fixelcfestats.cpp:241: +3, including nesting penalty of 2, nesting level increased to 3
if (mask.value())
^cpp/cmd/fixelcfestats.cpp:244: +2, including nesting penalty of 1, nesting level increased to 2
CONSOLE("Number of fixels in mask: " + str(mask_fixels));
^cpp/core/exception.h:65: expanded from macro 'CONSOLE'
if (MR::App::log_level >= 1) \
^cpp/cmd/fixelcfestats.cpp:245: +1, nesting level increased to 1
} else {
^cpp/cmd/fixelcfestats.cpp:249: +2, including nesting penalty of 1, nesting level increased to 2
for (auto l = Loop(0)(mask); l; ++l)
^cpp/cmd/fixelcfestats.cpp:258: +1, including nesting penalty of 0, nesting level increased to 1
for (Math::Stats::index_type i = 0; i != importer.size(); ++i) {
^cpp/cmd/fixelcfestats.cpp:259: +2, including nesting penalty of 1, nesting level increased to 2
if (!Fixel::fixels_match(index_header, dynamic_cast<SubjectFixelImport *>(importer[i].get())->header()))
^cpp/cmd/fixelcfestats.cpp:262: +1, including nesting penalty of 0, nesting level increased to 1
CONSOLE("Number of inputs: " + str(importer.size()));
^cpp/core/exception.h:65: expanded from macro 'CONSOLE'
if (MR::App::log_level >= 1) \
^cpp/cmd/fixelcfestats.cpp:266: +1, including nesting penalty of 0, nesting level increased to 1
if (size_t(design.rows()) != importer.size())
^cpp/cmd/fixelcfestats.cpp:274: +1, including nesting penalty of 0, nesting level increased to 1
for (size_t i = 0; i != opt.size(); ++i) {
^cpp/cmd/fixelcfestats.cpp:279: +2, including nesting penalty of 1, nesting level increased to 2
if (!nans_in_columns) {
^cpp/cmd/fixelcfestats.cpp:281: +3, including nesting penalty of 2, nesting level increased to 3
for (Math::Stats::index_type j = 0; j != importer.size(); ++j)
^cpp/cmd/fixelcfestats.cpp:283: +3, including nesting penalty of 2, nesting level increased to 3
if (mask_fixels == num_fixels) {
^cpp/cmd/fixelcfestats.cpp:285: +1, nesting level increased to 3
} else {
^cpp/cmd/fixelcfestats.cpp:286: +4, including nesting penalty of 3, nesting level increased to 4
for (auto l = Loop(0)(mask); l; ++l) {
^cpp/cmd/fixelcfestats.cpp:287: +5, including nesting penalty of 4, nesting level increased to 5
if (mask.value() && !column_data.col(mask.index(0)).allFinite()) {
^cpp/cmd/fixelcfestats.cpp:287: +1
if (mask.value() && !column_data.col(mask.index(0)).allFinite()) {
^cpp/cmd/fixelcfestats.cpp:296: +1, including nesting penalty of 0, nesting level increased to 1
CONSOLE("Number of factors: " + str(num_factors));
^cpp/core/exception.h:65: expanded from macro 'CONSOLE'
if (MR::App::log_level >= 1) \
^cpp/cmd/fixelcfestats.cpp:298: +1, including nesting penalty of 0, nesting level increased to 1
if (have_extra_columns) {
^cpp/cmd/fixelcfestats.cpp:299: +2, including nesting penalty of 1, nesting level increased to 2
CONSOLE("Number of element-wise design matrix columns: " + str(extra_columns.size()));
^cpp/core/exception.h:65: expanded from macro 'CONSOLE'
if (MR::App::log_level >= 1) \
^cpp/cmd/fixelcfestats.cpp:300: +2, including nesting penalty of 1, nesting level increased to 2
if (nans_in_columns)
^cpp/cmd/fixelcfestats.cpp:301: +3, including nesting penalty of 2, nesting level increased to 3
CONSOLE("Non-finite values detected in element-wise design matrix columns; "
^cpp/core/exception.h:65: expanded from macro 'CONSOLE'
if (MR::App::log_level >= 1) \
^cpp/cmd/fixelcfestats.cpp:308: +1, including nesting penalty of 0, nesting level increased to 1
const Math::Stats::index_type num_vgs = variance_groups.size() ? variance_groups.maxCoeff() + 1 : 1;
^cpp/cmd/fixelcfestats.cpp:309: +1, including nesting penalty of 0, nesting level increased to 1
if (num_vgs > 1)
^cpp/cmd/fixelcfestats.cpp:310: +2, including nesting penalty of 1, nesting level increased to 2
CONSOLE("Number of variance groups: " + str(num_vgs));
^cpp/core/exception.h:65: expanded from macro 'CONSOLE'
if (MR::App::log_level >= 1) \
^cpp/cmd/fixelcfestats.cpp:315: +1, including nesting penalty of 0, nesting level increased to 1
if (hypotheses[0].cols() != num_factors)
^cpp/cmd/fixelcfestats.cpp:318: +2, including nesting penalty of 1, nesting level increased to 2
(have_extra_columns ? " (in addition to the " + str(extra_columns.size()) + " uses of -column)" : "") +
^cpp/cmd/fixelcfestats.cpp:320: +1, including nesting penalty of 0, nesting level increased to 1
CONSOLE("Number of hypotheses: " + str(num_hypotheses));
^cpp/core/exception.h:65: expanded from macro 'CONSOLE'
if (MR::App::log_level >= 1) \
^cpp/cmd/fixelcfestats.cpp:336: +1, including nesting penalty of 0, nesting level increased to 1
for (Fixel::index_type f = 0; f != num_fixels; ++f) {
^cpp/cmd/fixelcfestats.cpp:338: +2, including nesting penalty of 1, nesting level increased to 2
if (mask.value() && !matrix.size(f))
^cpp/cmd/fixelcfestats.cpp:338: +1
if (mask.value() && !matrix.size(f))
^cpp/cmd/fixelcfestats.cpp:341: +1, including nesting penalty of 0, nesting level increased to 1
if (num_unconnected_fixels) {
^cpp/cmd/fixelcfestats.cpp:342: +2, including nesting penalty of 1, nesting level increased to 2
WARN("A total of " + str(num_unconnected_fixels) + " fixels " +
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/fixelcfestats.cpp:343: +3, including nesting penalty of 2, nesting level increased to 3
(mask_fixels == num_fixels ? "" : "in the provided mask ") +
^cpp/cmd/fixelcfestats.cpp:359: +1, including nesting penalty of 0, nesting level increased to 1
for (Math::Stats::index_type subject = 0; subject != importer.size(); subject++) {
^cpp/cmd/fixelcfestats.cpp:366: +1, including nesting penalty of 0, nesting level increased to 1
for (auto l = Loop(0)(mask); l; ++l) {
^cpp/cmd/fixelcfestats.cpp:367: +2, including nesting penalty of 1, nesting level increased to 2
if (mask.value()) {
^cpp/cmd/fixelcfestats.cpp:368: +3, including nesting penalty of 2, nesting level increased to 3
if (!data.col(mask.index(0)).allFinite())
^cpp/cmd/fixelcfestats.cpp:370: +1, nesting level increased to 2
} else {
^cpp/cmd/fixelcfestats.cpp:374: +1, including nesting penalty of 0, nesting level increased to 1
if (nans_in_data) {
^cpp/cmd/fixelcfestats.cpp:375: +2, including nesting penalty of 1, nesting level increased to 2
CONSOLE("Non-finite values present in data; rows will be removed from fixel-wise design matrices accordingly");
^cpp/core/exception.h:65: expanded from macro 'CONSOLE'
if (MR::App::log_level >= 1) \
^cpp/cmd/fixelcfestats.cpp:376: +2, including nesting penalty of 1, nesting level increased to 2
if (!have_extra_columns) {
^cpp/cmd/fixelcfestats.cpp:377: +3, including nesting penalty of 2, nesting level increased to 3
CONSOLE("(Note that this will result in slower execution than if such values were not present)");
^cpp/core/exception.h:65: expanded from macro 'CONSOLE'
if (MR::App::log_level >= 1) \
^cpp/cmd/fixelcfestats.cpp:380: +1
const bool variable_design_matrix = nans_in_data || have_extra_columns;
^cpp/cmd/fixelcfestats.cpp:383: nesting level increased to 1
auto postfix = [&](const Math::Stats::index_type i) -> std::string {
^cpp/cmd/fixelcfestats.cpp:384: +2, including nesting penalty of 1, nesting level increased to 2
return (num_hypotheses > 1) ? ("_" + hypotheses[i].name()) : "";
^cpp/cmd/fixelcfestats.cpp:398: +1, including nesting penalty of 0, nesting level increased to 1
num_factors + (2 * num_hypotheses) + num_vgs + (variable_design_matrix ? 1 : 0));
^cpp/cmd/fixelcfestats.cpp:400: +1, including nesting penalty of 0, nesting level increased to 1
for (Math::Stats::index_type i = 0; i != num_factors; ++i) {
^cpp/cmd/fixelcfestats.cpp:405: +1, including nesting penalty of 0, nesting level increased to 1
for (Math::Stats::index_type i = 0; i != num_hypotheses; ++i) {
^cpp/cmd/fixelcfestats.cpp:406: +2, including nesting penalty of 1, nesting level increased to 2
if (!hypotheses[i].is_F()) {
^cpp/cmd/fixelcfestats.cpp:412: +3, including nesting penalty of 2, nesting level increased to 3
if (num_vgs == 1)
^cpp/cmd/fixelcfestats.cpp:417: +1, nesting level increased to 2
} else {
^cpp/cmd/fixelcfestats.cpp:422: +1, including nesting penalty of 0, nesting level increased to 1
if (variable_design_matrix) {
^cpp/cmd/fixelcfestats.cpp:426: +1, including nesting penalty of 0, nesting level increased to 1
if (num_vgs == 1) {
^cpp/cmd/fixelcfestats.cpp:428: +1, nesting level increased to 1
} else {
^cpp/cmd/fixelcfestats.cpp:429: +2, including nesting penalty of 1, nesting level increased to 2
for (Math::Stats::index_type i = 0; i != num_vgs; ++i) {
^cpp/cmd/fixelcfestats.cpp:439: +1, including nesting penalty of 0, nesting level increased to 1
if (variable_design_matrix) {
^cpp/cmd/fixelcfestats.cpp:440: +2, including nesting penalty of 1, nesting level increased to 2
if (variance_groups.size())
^cpp/cmd/fixelcfestats.cpp:443: +1, nesting level increased to 2
else
^cpp/cmd/fixelcfestats.cpp:446: +1, nesting level increased to 1
} else {
^cpp/cmd/fixelcfestats.cpp:447: +2, including nesting penalty of 1, nesting level increased to 2
if (variance_groups.size())
^cpp/cmd/fixelcfestats.cpp:449: +1, nesting level increased to 2
else
^cpp/cmd/fixelcfestats.cpp:458: +1, including nesting penalty of 0, nesting level increased to 1
if (do_nonstationarity_adjustment) {
^cpp/cmd/fixelcfestats.cpp:461: +2, including nesting penalty of 1, nesting level increased to 2
for (Math::Stats::index_type i = 0; i != num_hypotheses; ++i)
^cpp/cmd/fixelcfestats.cpp:466: +1, nesting level increased to 1
} else {
^cpp/cmd/fixelcfestats.cpp:474: +1, including nesting penalty of 0, nesting level increased to 1
for (Math::Stats::index_type i = 0; i != num_hypotheses; ++i) {
^cpp/cmd/fixelcfestats.cpp:477: +2, including nesting penalty of 1, nesting level increased to 2
(hypotheses[i].is_F() ? std::string("F") : std::string("t")) + "value" + postfix(i) + ".mif"),
^cpp/cmd/fixelcfestats.cpp:488: +1, including nesting penalty of 0, nesting level increased to 1
if (get_options("notest").empty()) {
^cpp/cmd/fixelcfestats.cpp:491: +2, including nesting penalty of 1, nesting level increased to 2
if (fwe_strong && num_hypotheses == 1) {
^cpp/cmd/fixelcfestats.cpp:491: +1
if (fwe_strong && num_hypotheses == 1) {
^cpp/cmd/fixelcfestats.cpp:492: +3, including nesting penalty of 2, nesting level increased to 3
WARN("Option -strong has no effect when testing a single hypothesis only");
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/fixelcfestats.cpp:506: +2, including nesting penalty of 1, nesting level increased to 2
ProgressBar progress("Outputting final results", (fwe_strong ? 1 : num_hypotheses) + 1 + 3 * num_hypotheses);
^cpp/cmd/fixelcfestats.cpp:508: +2, including nesting penalty of 1, nesting level increased to 2
if (fwe_strong) {
^cpp/cmd/fixelcfestats.cpp:511: +1, nesting level increased to 2
} else {
^cpp/cmd/fixelcfestats.cpp:512: +3, including nesting penalty of 2, nesting level increased to 3
for (Math::Stats::index_type i = 0; i != num_hypotheses; ++i) {
^cpp/cmd/fixelcfestats.cpp:521: +2, including nesting penalty of 1, nesting level increased to 2
for (Math::Stats::index_type i = 0; i != num_hypotheses; ++i) {
^|
|
||
| // Load fixel-fixel connectivity matrix | ||
| Fixel::Matrix::Reader matrix(argument[4], mask); | ||
| Fixel::Matrix::Reader matrix(connectivity_matrix_path, mask); |
There was a problem hiding this comment.
warning: variable 'matrix' of type 'Fixel::Matrix::Reader' can be declared 'const' [misc-const-correctness]
| Fixel::Matrix::Reader matrix(connectivity_matrix_path, mask); | |
| Fixel::Matrix::Reader const matrix(connectivity_matrix_path, mask); |
| check_dimensions(subject_index, template_index); | ||
| std::string output_fixel_directory = argument[2]; | ||
| Fixel::copy_index_and_directions_file(argument[1], output_fixel_directory); | ||
| std::string output_fixel_directory = output_directory; |
There was a problem hiding this comment.
warning: variable 'output_fixel_directory' of type 'std::string' (aka 'basic_string') can be declared 'const' [misc-const-correctness]
| std::string output_fixel_directory = output_directory; | |
| std::string const output_fixel_directory = output_directory; |
| Eigen::Vector3d centre; | ||
| transform_type rigid_transform = File::Matrix::load_transform(opt[0][0], centre); | ||
| const std::filesystem::path rigid_init_matrix_path{opt[0][0]}; | ||
| transform_type rigid_transform = File::Matrix::load_transform(rigid_init_matrix_path, centre); |
There was a problem hiding this comment.
warning: variable 'rigid_transform' of type 'transform_type' (aka 'Transform<double, 3, Eigen::AffineCompact>') can be declared 'const' [misc-const-correctness]
| transform_type rigid_transform = File::Matrix::load_transform(rigid_init_matrix_path, centre); | |
| transform_type const rigid_transform = File::Matrix::load_transform(rigid_init_matrix_path, centre); |
| Eigen::Vector3d centre; | ||
| transform_type affine_transform = File::Matrix::load_transform(opt[0][0], centre); | ||
| const std::filesystem::path affine_matrix_path{opt[0][0]}; | ||
| transform_type affine_transform = File::Matrix::load_transform(affine_matrix_path, centre); |
There was a problem hiding this comment.
warning: variable 'affine_transform' of type 'transform_type' (aka 'Transform<double, 3, Eigen::AffineCompact>') can be declared 'const' [misc-const-correctness]
| transform_type affine_transform = File::Matrix::load_transform(affine_matrix_path, centre); | |
| transform_type const affine_transform = File::Matrix::load_transform(affine_matrix_path, centre); |
| #include "algo/loop.h" | ||
| #include "file/ofstream.h" | ||
|
|
||
| #include <filesystem> |
There was a problem hiding this comment.
warning: duplicate include [readability-duplicate-include]
cpp/cmd/mrstats.cpp:30:
-
- #include <filesystem>
| @@ -397,6 +398,7 @@ void execute(Image<value_type> &in, | |||
| } | |||
|
|
|||
| void run() { | |||
There was a problem hiding this comment.
warning: function 'run' has cognitive complexity of 70 (threshold 25) [readability-function-cognitive-complexity]
void run() {
^Additional context
cpp/cmd/mrthreshold.cpp:406: +1, including nesting penalty of 0, nesting level increased to 1
(std::isfinite(abs) ? 1 : 0) + (std::isfinite(percentile) ? 1 : 0) + (bottom >= 0 ? 1 : 0) + (top >= 0 ? 1 : 0);
^cpp/cmd/mrthreshold.cpp:406: +1, including nesting penalty of 0, nesting level increased to 1
(std::isfinite(abs) ? 1 : 0) + (std::isfinite(percentile) ? 1 : 0) + (bottom >= 0 ? 1 : 0) + (top >= 0 ? 1 : 0);
^cpp/cmd/mrthreshold.cpp:406: +1, including nesting penalty of 0, nesting level increased to 1
(std::isfinite(abs) ? 1 : 0) + (std::isfinite(percentile) ? 1 : 0) + (bottom >= 0 ? 1 : 0) + (top >= 0 ? 1 : 0);
^cpp/cmd/mrthreshold.cpp:406: +1, including nesting penalty of 0, nesting level increased to 1
(std::isfinite(abs) ? 1 : 0) + (std::isfinite(percentile) ? 1 : 0) + (bottom >= 0 ? 1 : 0) + (top >= 0 ? 1 : 0);
^cpp/cmd/mrthreshold.cpp:407: +1, including nesting penalty of 0, nesting level increased to 1
if (num_explicit_mechanisms > 1)
^cpp/cmd/mrthreshold.cpp:411: +1, including nesting penalty of 0, nesting level increased to 1
if (header_in.datatype().is_complex())
^cpp/cmd/mrthreshold.cpp:416: +1, including nesting penalty of 0, nesting level increased to 1
const std::filesystem::path output_path{to_cout ? std::string("") : argument[1]};
^cpp/cmd/mrthreshold.cpp:426: +1, including nesting penalty of 0, nesting level increased to 1
!opt.empty() ? operator_type(int(opt[0][0])) : (bottom >= 0 ? operator_type::LE : operator_type::GE);
^cpp/cmd/mrthreshold.cpp:426: +2, including nesting penalty of 1, nesting level increased to 2
!opt.empty() ? operator_type(int(opt[0][0])) : (bottom >= 0 ? operator_type::LE : operator_type::GE);
^cpp/cmd/mrthreshold.cpp:427: +1, including nesting penalty of 0, nesting level increased to 1
if (invert) {
^cpp/cmd/mrthreshold.cpp:428: +2, including nesting penalty of 1, nesting level increased to 2
switch (comp) {
^cpp/cmd/mrthreshold.cpp:446: +1, including nesting penalty of 0, nesting level increased to 1
if (to_cout) {
^cpp/cmd/mrthreshold.cpp:447: +2, including nesting penalty of 1, nesting level increased to 2
if (use_nan) {
^cpp/cmd/mrthreshold.cpp:448: +3, including nesting penalty of 2, nesting level increased to 3
WARN("Option -nan ignored: has no influence when no output image is specified");
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/mrthreshold.cpp:450: +2, including nesting penalty of 1, nesting level increased to 2
if (!opt.empty()) {
^cpp/cmd/mrthreshold.cpp:451: +3, including nesting penalty of 2, nesting level increased to 3
WARN("Option -comparison ignored: has no influence when no output image is specified");
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/mrthreshold.cpp:454: +2, including nesting penalty of 1, nesting level increased to 2
if (invert) {
^cpp/cmd/mrthreshold.cpp:455: +3, including nesting penalty of 2, nesting level increased to 3
WARN("Option -invert ignored: has no influence when no output image is specified");
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/mrthreshold.cpp:457: +2, including nesting penalty of 1, nesting level increased to 2
if (mask_out) {
^cpp/cmd/mrthreshold.cpp:458: +3, including nesting penalty of 2, nesting level increased to 3
WARN("Option -out_masked ignored: has no influence when no output image is specified");
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/mrthreshold.cpp:463: +1, including nesting penalty of 0, nesting level increased to 1
if (std::isfinite(abs)) {
^cpp/cmd/mrthreshold.cpp:464: +2, including nesting penalty of 1, nesting level increased to 2
if (ignore_zero) {
^cpp/cmd/mrthreshold.cpp:465: +3, including nesting penalty of 2, nesting level increased to 3
WARN("-ignorezero option has no effect if combined with -abs option");
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/mrthreshold.cpp:467: +2, including nesting penalty of 1, nesting level increased to 2
if (!get_options("mask").empty() && !mask_out) {
^cpp/cmd/mrthreshold.cpp:467: +1
if (!get_options("mask").empty() && !mask_out) {
^cpp/cmd/mrthreshold.cpp:468: +3, including nesting penalty of 2, nesting level increased to 3
WARN("-mask option has no effect if combined with -abs option and -out_masked is not used");
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/mrthreshold.cpp:470: +1, nesting level increased to 1
} else {
^cpp/cmd/mrthreshold.cpp:472: +2, including nesting penalty of 1, nesting level increased to 2
if (!mask.valid() && mask_out) {
^cpp/cmd/mrthreshold.cpp:472: +1
if (!mask.valid() && mask_out) {
^cpp/cmd/mrthreshold.cpp:473: +3, including nesting penalty of 2, nesting level increased to 3
WARN("-out_masked option ignored; no mask image provided via -mask");
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/mrthreshold.cpp:476: +2, including nesting penalty of 1, nesting level increased to 2
if (!num_explicit_mechanisms) {
^cpp/cmd/mrthreshold.cpp:477: +3, including nesting penalty of 2, nesting level increased to 3
if (ignore_zero) {
^cpp/cmd/mrthreshold.cpp:478: +4, including nesting penalty of 3, nesting level increased to 4
WARN("Option -ignorezero ignored by automatic threshold calculation");
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^cpp/cmd/mrthreshold.cpp:482: +3, including nesting penalty of 2, nesting level increased to 3
} catch (Exception &e) {
^cpp/cmd/mrthreshold.cpp:488: +1, including nesting penalty of 0, nesting level increased to 1
if (use_nan)
^cpp/cmd/mrthreshold.cpp:490: +1, nesting level increased to 1
else
^cpp/cmd/mrthreshold.cpp:493: +1, including nesting penalty of 0, nesting level increased to 1
if (issue_degeneracy_warning) {
^cpp/cmd/mrthreshold.cpp:494: +2, including nesting penalty of 1, nesting level increased to 2
WARN("Duplicate image values surrounding threshold; "
^cpp/core/exception.h:71: expanded from macro 'WARN'
if (MR::App::log_level >= 1) \
^| for (size_t n = 0; n < n_tissue_types; ++n) { | ||
| const std::filesystem::path input_path{argument[2 * n]}; | ||
| const std::filesystem::path output_path{argument[2 * n + 1]}; | ||
| write_output(input_path, output_path, output_balanced, balance_factors[n], full_field, lognorm_scale); |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'Index' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
write_output(input_path, output_path, output_balanced, balance_factors[n], full_field, lognorm_scale);
^70031c3 to
6bf4cec
Compare
Supersedes #2645.
The aim is to enforce the use of
std::filesystem::paththroughout the entire codebase and minimise the use of custom functionality for file system operations (e.g. incore/file).This is going to be a large PR and is still very much WIP.