From c67f23c91373311ceca786f6b3084b318f7649b5 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Mon, 15 Feb 2021 21:30:50 -0700 Subject: [PATCH] fix clang-tidy complaints some of these are ridiculous and so have been silenced. I'm a huge fan of static code analysis but I have a hard time believing that writing "0U" is a qualitative improvement over "0u". --- .../adapters/file_source_base.cc | 36 +++++++++---------- .../signal_source/adapters/file_source_base.h | 2 +- .../adapters/signal_source_base.cc | 4 ++- src/core/receiver/gnss_block_factory.cc | 4 +-- src/core/receiver/gnss_flowgraph.cc | 6 ++-- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/algorithms/signal_source/adapters/file_source_base.cc b/src/algorithms/signal_source/adapters/file_source_base.cc index 1dd9f0df1..f93ae3098 100644 --- a/src/algorithms/signal_source/adapters/file_source_base.cc +++ b/src/algorithms/signal_source/adapters/file_source_base.cc @@ -22,6 +22,7 @@ #include #include // ceil, floor #include +#include // move using namespace std::string_literals; @@ -133,9 +134,13 @@ gr::basic_block_sptr FileSourceBase::get_left_block() gr::basic_block_sptr FileSourceBase::get_right_block() { - if (valve_) return valve_; - if (throttle_) return throttle_; + // clang-tidy wants braces around the if-conditions. clang-format wants to break the braces into + // multiple line blocks. It's much more readable this way + // clang-format off + if (valve_) { return valve_; } + if (throttle_) { return throttle_; } return source(); + // clang-format on } @@ -174,37 +179,32 @@ uint64_t FileSourceBase::samples() const } -FileSourceBase::FileSourceBase(ConfigurationInterface const* configuration, std::string role, std::string impl, +FileSourceBase::FileSourceBase(ConfigurationInterface const* configuration, std::string const& role, std::string impl, Concurrent_Queue* queue, std::string default_item_type) - : SignalSourceBase(configuration, role, impl), filename_(configuration->property(role + ".filename"s, "../data/example_capture.dat"s)), file_source_() + : SignalSourceBase(configuration, role, std::move(impl)), filename_(configuration->property(role + ".filename"s, "../data/example_capture.dat"s)), file_source_(), - , - item_type_(configuration->property(role + ".item_type"s, default_item_type)), - item_size_(0) // invalid - , - is_complex_(false) + item_type_(configuration->property(role + ".item_type"s, default_item_type)), // NOLINT + item_size_(0), + is_complex_(false), // apparently, MacOS (LLVM) finds 0UL ambiguous with bool, int64_t, uint64_t, int32_t, int16_t, uint16_t,... float, double - , header_size_(configuration->property(role + ".header_size"s, uint64_t(0))), seconds_to_skip_(configuration->property(role + ".seconds_to_skip", 0.0)), - repeat_(configuration->property(role + ".repeat"s, false)) + repeat_(configuration->property(role + ".repeat"s, false)), + - , samples_(configuration->property(role + ".samples"s, uint64_t(0))), sampling_frequency_(configuration->property(role + ".sampling_frequency"s, int64_t(0))), - valve_(), - queue_(queue) + valve_(), // NOLINT + queue_(queue), - , enable_throttle_control_(configuration->property(role + ".enable_throttle_control"s, false)), - throttle_() + throttle_(), // NOLINT - , dump_(configuration->property(role + ".dump"s, false)), dump_filename_(configuration->property(role + ".dump_filename"s, "../data/my_capture.dat"s)), - sink_() + sink_() // NOLINT { // override value with commandline flag, if present if (FLAGS_signal_source != "-") diff --git a/src/algorithms/signal_source/adapters/file_source_base.h b/src/algorithms/signal_source/adapters/file_source_base.h index f71ed4df8..88802c067 100644 --- a/src/algorithms/signal_source/adapters/file_source_base.h +++ b/src/algorithms/signal_source/adapters/file_source_base.h @@ -84,7 +84,7 @@ protected: // Subclasses may want to assert default item types that are appropriate to the specific file // type supported. Rather than require the item type to be specified in the config file, allow // sub-classes to impose their will - FileSourceBase(ConfigurationInterface const* configuration, std::string role, std::string impl, + FileSourceBase(ConfigurationInterface const* configuration, std::string const& role, std::string impl, Concurrent_Queue* queue, std::string default_item_type = "short"); diff --git a/src/algorithms/signal_source/adapters/signal_source_base.cc b/src/algorithms/signal_source/adapters/signal_source_base.cc index a998b956c..3d8c141fb 100644 --- a/src/algorithms/signal_source/adapters/signal_source_base.cc +++ b/src/algorithms/signal_source/adapters/signal_source_base.cc @@ -20,6 +20,8 @@ #include "signal_source_base.h" #include "configuration_interface.h" +#include // move + using namespace std::string_literals; @@ -39,6 +41,6 @@ size_t SignalSourceBase::getRfChannels() const } SignalSourceBase::SignalSourceBase(ConfigurationInterface const* configuration, std::string role, std::string impl) - : SignalSourceInterface(), role_(role), implementation_(impl), rfChannels_(configuration->property(role + ".RF_channels"s, 1u)) + : role_(std::move(role)), implementation_(std::move(impl)), rfChannels_(configuration->property(role + ".RF_channels"s, 1u)) { } diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index 85829c51b..84685f6c0 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -191,7 +191,7 @@ std::unique_ptr dynamic_unique_cast(std::unique_ptr&& p) return result; } -auto findRole(ConfigurationInterface const* configuration, std::string base, int ID) -> std::string +auto findRole(ConfigurationInterface const* configuration, std::string const& base, int ID) -> std::string { auto role = base + std::to_string(ID); @@ -200,7 +200,7 @@ auto findRole(ConfigurationInterface const* configuration, std::string base, int if (ID < 1) { auto stub = configuration->property(role + impl_prop, ""s); - if (stub.empty()) role = base; // legacy format + if (stub.empty()) { role = base; } // NOLINT -- legacy format } return role; }; diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 515fdbd9b..dbcf1fe5d 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -110,7 +110,7 @@ void GNSSFlowgraph::init() auto& src = sig_source_.back(); auto RF_Channels = src->getRfChannels(); std::cout << "RF Channels " << RF_Channels << '\n'; - for (auto j = 0u; j < RF_Channels; ++j) + for (auto j = 0U; j < RF_Channels; ++j) { sig_conditioner_.push_back(block_factory->GetSignalConditioner(configuration_.get(), signal_conditioner_ID)); signal_conditioner_ID++; @@ -1022,7 +1022,7 @@ int GNSSFlowgraph::connect_signal_sources_to_signal_conditioners() { auto RF_Channels = src->getRfChannels(); - for (auto j = 0u; j < RF_Channels; ++j) + for (auto j = 0U; j < RF_Channels; ++j) { // Connect the multichannel signal source to multiple signal conditioners // GNURADIO max_streams=-1 means infinite ports! @@ -1117,7 +1117,7 @@ int GNSSFlowgraph::disconnect_signal_sources_from_signal_conditioners() { auto RF_Channels = src->getRfChannels(); - for (auto j = 0u; j < RF_Channels; ++j) + for (auto j = 0U; j < RF_Channels; ++j) { if (src->get_right_block()->output_signature()->max_streams() > 1 or src->get_right_block()->output_signature()->max_streams() == -1) {