Enable more clang-tidy checks. (#6270)

* Enable more clang-tidy checks
This commit is contained in:
Siarhei Fedartsou
2022-06-30 15:32:12 +02:00
committed by GitHub
parent 59953172e8
commit 3d2db20777
35 changed files with 69 additions and 79 deletions
@@ -18,7 +18,7 @@ inline auto contractFullGraph(ContractorGraph contractor_graph,
std::vector<EdgeWeight> node_weights)
{
auto num_nodes = contractor_graph.GetNumberOfNodes();
contractGraph(contractor_graph, node_weights);
contractGraph(contractor_graph, std::move(node_weights));
auto edges = toEdges<QueryEdge>(std::move(contractor_graph));
std::vector<bool> edge_filter(edges.size(), true);
+1 -1
View File
@@ -65,7 +65,7 @@ template <template <typename A> class FacadeT, typename AlgorithmT> class DataFa
for (const auto &exclude_prefix : exclude_prefixes)
{
auto index_begin = exclude_prefix.find_last_of("/");
auto index_begin = exclude_prefix.find_last_of('/');
BOOST_ASSERT_MSG(index_begin != std::string::npos,
"The exclude prefix needs to be a valid data path.");
std::size_t index =
-1
View File
@@ -18,7 +18,6 @@
#include <iterator>
#include <string>
#include <unordered_map>
using namespace std;
namespace osrm
{
+1 -1
View File
@@ -186,7 +186,7 @@ struct TurnRestriction
}
// construction for WayRestrictions
explicit TurnRestriction(WayRestriction way_restriction, bool is_only = false)
explicit TurnRestriction(const WayRestriction &way_restriction, bool is_only = false)
: node_or_way(way_restriction), is_only(is_only)
{
}
+1 -4
View File
@@ -9,15 +9,12 @@ namespace osrm
{
namespace guidance
{
namespace
{
const double bearing_scale = 360.0 / 256.0;
}
#pragma pack(push, 1)
class TurnBearing
{
public:
static constexpr double bearing_scale = 360.0 / 256.0;
// discretizes a bearing into distinct units of 1.4 degrees
TurnBearing(const double value = 0) : bearing(value / bearing_scale)
{
-12
View File
@@ -52,15 +52,6 @@ typedef enum TurnLaneScenario
NUM_SCENARIOS
} TurnLaneScenario;
const constexpr char *scenario_names[] = {"Simple",
"Partition Local",
"Simple Previous",
"Partition Previous",
"Sliproad",
"Merge",
"None",
"Invalid",
"Unknown"};
} // namespace
class TurnLaneHandler
@@ -150,9 +141,6 @@ class TurnLaneHandler
LaneDataVector &lane_data) const;
};
static_assert(sizeof(scenario_names) / sizeof(*scenario_names) == TurnLaneScenario::NUM_SCENARIOS,
"Number of scenarios needs to match the number of scenario names.");
} // namespace lanes
} // namespace guidance
} // namespace osrm
+1 -1
View File
@@ -77,7 +77,7 @@ class Server
boost::bind(&boost::asio::io_context::run, &io_context));
threads.push_back(thread);
}
for (auto thread : threads)
for (const auto &thread : threads)
{
thread->join();
}
+4 -3
View File
@@ -18,8 +18,9 @@ struct IOConfig
IOConfig(std::vector<boost::filesystem::path> required_input_files_,
std::vector<boost::filesystem::path> optional_input_files_,
std::vector<boost::filesystem::path> output_files_)
: required_input_files(required_input_files_), optional_input_files(optional_input_files_),
output_files(output_files_)
: required_input_files(std::move(required_input_files_)),
optional_input_files(std::move(optional_input_files_)),
output_files(std::move(output_files_))
{
}
@@ -47,7 +48,7 @@ struct IOConfig
std::array<std::string, 6> known_extensions{
{".osm.bz2", ".osm.pbf", ".osm.xml", ".pbf", ".osm", ".osrm"}};
for (auto ext : known_extensions)
for (const auto &ext : known_extensions)
{
const auto pos = path.find(ext);
if (pos != std::string::npos)
+1 -1
View File
@@ -36,7 +36,7 @@ inline std::string trimName(const std::string &name_prefix, const std::string &n
// list directory and
if (!name_prefix.empty() && name_prefix.back() == '/')
{
auto directory_position = name.find_first_of("/", name_prefix.length());
auto directory_position = name.find_first_of('/', name_prefix.length());
// this is a "file" in the directory of name_prefix
if (directory_position == std::string::npos)
{
+14 -13
View File
@@ -47,7 +47,7 @@ class exception : public std::exception
public:
explicit exception(const char *message) : message(message) {}
explicit exception(std::string message) : message(std::move(message)) {}
explicit exception(boost::format message) : message(message.str()) {}
explicit exception(const boost::format &message) : message(message.str()) {}
const char *what() const noexcept override { return message.c_str(); }
private:
@@ -65,18 +65,19 @@ class exception : public std::exception
*/
constexpr const std::array<const char *, 11> ErrorDescriptions = {{
"", // Dummy - ErrorCode values start at 2
"", // Dummy - ErrorCode values start at 2
"Fingerprint did not match the expected value", // InvalidFingerprint
"File is incompatible with this version of OSRM", // IncompatibleFileVersion
"Problem opening file", // FileOpenError
"Problem reading from file", // FileReadError
"Problem writing to file", // FileWriteError
"I/O error occurred", // FileIOError
"Unexpected end of file", // UnexpectedEndOfFile
"The dataset you are trying to load is not " // IncompatibleDataset
"compatible with the routing algorithm you want to use." // ...continued...
"Incompatible algorithm" // IncompatibleAlgorithm
"", // Dummy - ErrorCode values start at 2
"", // Dummy - ErrorCode values start at 2
"Fingerprint did not match the expected value", // InvalidFingerprint
"File is incompatible with this version of OSRM", // IncompatibleFileVersion
"Problem opening file", // FileOpenError
"Problem reading from file", // FileReadError
"Problem writing to file", // FileWriteError
"I/O error occurred", // FileIOError
"Unexpected end of file", // UnexpectedEndOfFile
// NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
"The dataset you are trying to load is not " // IncompatibleDataset
"compatible with the routing algorithm you want to use.", // ...continued...
"Incompatible algorithm" // IncompatibleAlgorithm
}};
#ifndef NDEBUG
+1 -1
View File
@@ -10,6 +10,6 @@
#define OSRM_SOURCE_FILE_ PROJECT_RELATIVE_PATH_(__FILE__)
// This is the macro to use
#define SOURCE_REF OSRM_SOURCE_FILE_ + ":" + std::to_string(__LINE__)
#define SOURCE_REF (OSRM_SOURCE_FILE_ + ":" + std::to_string(__LINE__))
#endif // SOURCE_MACROS_HPP
+2 -2
View File
@@ -71,12 +71,12 @@ template <typename StringView> inline auto decompose(const StringView &lhs, cons
// we compare suffixes based on this value, it might break UTF chars, but as long as we are
// consistent in handling, we do not create bad results
std::string str = boost::to_lower_copy(view.to_string());
auto front = str.find_first_not_of(" ");
auto front = str.find_first_not_of(' ');
if (front == std::string::npos)
return str;
auto back = str.find_last_not_of(" ");
auto back = str.find_last_not_of(' ');
return str.substr(front, back - front + 1);
};
+6
View File
@@ -83,19 +83,25 @@ template <unsigned BLOCK_SIZE, storage::Ownership Ownership> class RangeTable
unsigned block_idx = 0;
unsigned block_counter = 0;
BlockT block;
#ifndef BOOST_ASSERT_IS_VOID
unsigned block_sum = 0;
#endif
for (const unsigned l : lengths)
{
// first entry of a block: encode absolute offset
if (block_idx == 0)
{
block_offsets.push_back(lengths_prefix_sum);
#ifndef BOOST_ASSERT_IS_VOID
block_sum = 0;
#endif
}
else
{
block[block_idx - 1] = last_length;
#ifndef BOOST_ASSERT_IS_VOID
block_sum += last_length;
#endif
}
BOOST_ASSERT((block_idx == 0 && block_offsets[block_counter] == lengths_prefix_sum) ||