diff --git a/.clang-tidy b/.clang-tidy index 72e02cb40ac..d1b047f3a76 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -15,6 +15,9 @@ Checks: > -clang-analyzer-*, -clang-diagnostic-deprecated-declarations, -clang-diagnostic-constant-conversion, + cppcoreguidelines-avoid-goto, + cppcoreguidelines-no-malloc, + cppcoreguidelines-virtual-class-destructor, google-*, -google-build-explicit-make-pair, -google-build-using-namespace, @@ -40,7 +43,6 @@ Checks: > -misc-argument-comment, -misc-non-private-member-variables-in-classes, -misc-unconventional-assign-operator, - -misc-redundant-expression, -misc-no-recursion, -misc-misplaced-const, -misc-definitions-in-headers, @@ -49,7 +51,6 @@ Checks: > -performance-noexcept-move-constructor, -performance-move-const-arg, -performance-no-int-to-ptr, - -performance-unnecessary-value-param, readability-*, -readability-avoid-const-params-in-decls, -readability-braces-around-statements, diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cd335fbfb0..060e2c77f95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - API: - FIXED: Fix inefficient osrm-routed connection handling [#6113](https://github.com/Project-OSRM/osrm-backend/pull/6113) - Build: + - CHANGED: Enable even more clang-tidy checks. [#6273](https://github.com/Project-OSRM/osrm-backend/pull/6273) - CHANGED: Configure CMake to not build flatbuffers tests and samples. [#6274](https://github.com/Project-OSRM/osrm-backend/pull/6274) - CHANGED: Enable more clang-tidy checks. [#6270](https://github.com/Project-OSRM/osrm-backend/pull/6270) - CHANGED: Configure clang-tidy job on CI. [#6261](https://github.com/Project-OSRM/osrm-backend/pull/6261) diff --git a/include/contractor/query_graph.hpp b/include/contractor/query_graph.hpp index b312a540395..c0c4b6cf55e 100644 --- a/include/contractor/query_graph.hpp +++ b/include/contractor/query_graph.hpp @@ -15,7 +15,7 @@ namespace detail { template using QueryGraph = util::StaticGraph; -} +} // namespace detail using QueryGraph = detail::QueryGraph; using QueryGraphView = detail::QueryGraph; diff --git a/include/engine/api/route_api.hpp b/include/engine/api/route_api.hpp index 4990d37c974..72244c453ac 100644 --- a/include/engine/api/route_api.hpp +++ b/include/engine/api/route_api.hpp @@ -688,7 +688,7 @@ class RouteAPI : public BaseAPI intersection.classes.begin(), intersection.classes.end(), classes.begin(), - [&fb_result](const std::string cls) { return fb_result.CreateString(cls); }); + [&fb_result](const std::string &cls) { return fb_result.CreateString(cls); }); auto classes_vector = fb_result.CreateVector(classes); auto entry_vector = fb_result.CreateVector(intersection.entry); diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index 9886783312c..e448a8f57db 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -630,7 +630,7 @@ class ContiguousInternalMemoryDataFacade public ContiguousInternalMemoryAlgorithmDataFacade { public: - ContiguousInternalMemoryDataFacade(std::shared_ptr allocator, + ContiguousInternalMemoryDataFacade(const std::shared_ptr &allocator, const std::string &metric_name, const std::size_t exclude_index) : ContiguousInternalMemoryDataFacadeBase(allocator, metric_name, exclude_index), @@ -752,7 +752,7 @@ class ContiguousInternalMemoryDataFacade final { private: public: - ContiguousInternalMemoryDataFacade(std::shared_ptr allocator, + ContiguousInternalMemoryDataFacade(const std::shared_ptr &allocator, const std::string &metric_name, const std::size_t exclude_index) : ContiguousInternalMemoryDataFacadeBase(allocator, metric_name, exclude_index), diff --git a/include/engine/plugins/plugin_base.hpp b/include/engine/plugins/plugin_base.hpp index ef664162196..abf344348af 100644 --- a/include/engine/plugins/plugin_base.hpp +++ b/include/engine/plugins/plugin_base.hpp @@ -168,7 +168,7 @@ class BasePlugin std::vector> GetPhantomNodesInRange(const datafacade::BaseDataFacade &facade, const api::BaseParameters ¶meters, - const std::vector radiuses, + const std::vector &radiuses, bool use_all_edges = false) const { std::vector> phantom_nodes( diff --git a/include/engine/routing_algorithms/routing_base.hpp b/include/engine/routing_algorithms/routing_base.hpp index ee564afe207..70b7212fae9 100644 --- a/include/engine/routing_algorithms/routing_base.hpp +++ b/include/engine/routing_algorithms/routing_base.hpp @@ -336,7 +336,7 @@ void annotatePath(const FacadeT &facade, template double getPathDistance(const DataFacade &facade, - const std::vector unpacked_path, + const std::vector &unpacked_path, const PhantomNode &source_phantom, const PhantomNode &target_phantom) { diff --git a/include/extractor/intersection_bearings_container.hpp b/include/extractor/intersection_bearings_container.hpp index 40746dcf095..7c6d025d204 100644 --- a/include/extractor/intersection_bearings_container.hpp +++ b/include/extractor/intersection_bearings_container.hpp @@ -17,7 +17,7 @@ namespace extractor namespace detail { template class IntersectionBearingsContainer; -} +} // namespace detail namespace serialization { @@ -46,9 +46,10 @@ template class IntersectionBearingsContainer IntersectionBearingsContainer &operator=(IntersectionBearingsContainer &&) = default; IntersectionBearingsContainer &operator=(const IntersectionBearingsContainer &) = default; - IntersectionBearingsContainer(std::vector node_to_class_id_, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + IntersectionBearingsContainer(std::vector node_to_class_id, const std::vector &bearing_classes) - : node_to_class_id(std::move(node_to_class_id_)) + : node_to_class_id_(std::move(node_to_class_id)) { std::vector bearing_counts(bearing_classes.size()); std::transform(bearing_classes.begin(), @@ -57,32 +58,32 @@ template class IntersectionBearingsContainer [](const auto &bearings) { return bearings.getAvailableBearings().size(); }); // NOLINTNEXTLINE(bugprone-fold-init-type) auto total_bearings = std::accumulate(bearing_counts.begin(), bearing_counts.end(), 0); - class_id_to_ranges_table = RangeTable<16>{bearing_counts}; + class_id_to_ranges_table_ = RangeTable<16>{bearing_counts}; - values.reserve(total_bearings); + values_.reserve(total_bearings); for (const auto &bearing_class : bearing_classes) { const auto &bearings = bearing_class.getAvailableBearings(); - values.insert(values.end(), bearings.begin(), bearings.end()); + values_.insert(values_.end(), bearings.begin(), bearings.end()); } } - IntersectionBearingsContainer(Vector values_, - Vector node_to_class_id_, - RangeTable<16> class_id_to_ranges_table_) - : values(std::move(values_)), node_to_class_id(std::move(node_to_class_id_)), - class_id_to_ranges_table(std::move(class_id_to_ranges_table_)) + IntersectionBearingsContainer(Vector values, + Vector node_to_class_id, + RangeTable<16> class_id_to_ranges_table) + : values_(std::move(values)), node_to_class_id_(std::move(node_to_class_id)), + class_id_to_ranges_table_(std::move(class_id_to_ranges_table)) { } // Returns the bearing class for an intersection node util::guidance::BearingClass GetBearingClass(const NodeID node) const { - auto class_id = node_to_class_id[node]; - auto range = class_id_to_ranges_table.GetRange(class_id); + auto class_id = node_to_class_id_[node]; + auto range = class_id_to_ranges_table_.GetRange(class_id); util::guidance::BearingClass result; - std::for_each(values.begin() + range.front(), - values.begin() + range.back() + 1, + std::for_each(values_.begin() + range.front(), + values_.begin() + range.back() + 1, [&](const DiscreteBearing &bearing) { result.add(bearing); }); return result; } @@ -96,9 +97,9 @@ template class IntersectionBearingsContainer const IntersectionBearingsContainer &turn_data_container); private: - Vector values; - Vector node_to_class_id; - RangeTable<16> class_id_to_ranges_table; + Vector values_; + Vector node_to_class_id_; + RangeTable<16> class_id_to_ranges_table_; }; } // namespace detail diff --git a/include/extractor/maneuver_override_relation_parser.hpp b/include/extractor/maneuver_override_relation_parser.hpp index 45b3d87ab39..31355fcb2b9 100644 --- a/include/extractor/maneuver_override_relation_parser.hpp +++ b/include/extractor/maneuver_override_relation_parser.hpp @@ -10,7 +10,7 @@ namespace osmium { class Relation; -} +} // namespace osmium namespace osrm { diff --git a/include/extractor/name_table.hpp b/include/extractor/name_table.hpp index 9bf6dc7ea29..ff0d27ae192 100644 --- a/include/extractor/name_table.hpp +++ b/include/extractor/name_table.hpp @@ -15,7 +15,7 @@ namespace extractor namespace detail { template class NameTableImpl; -} +} // namespace detail namespace serialization { diff --git a/include/extractor/node_based_edge.hpp b/include/extractor/node_based_edge.hpp index 84a03d0a09b..cafb06e12ea 100644 --- a/include/extractor/node_based_edge.hpp +++ b/include/extractor/node_based_edge.hpp @@ -192,7 +192,7 @@ inline NodeBasedEdgeWithOSM::NodeBasedEdgeWithOSM(OSMNodeID source, geometry_id, annotation_data, flags), - osm_source_id(std::move(source)), osm_target_id(std::move(target)) + osm_source_id(source), osm_target_id(target) { } diff --git a/include/extractor/node_data_container.hpp b/include/extractor/node_data_container.hpp index e39b2872743..b3825c31466 100644 --- a/include/extractor/node_data_container.hpp +++ b/include/extractor/node_data_container.hpp @@ -24,7 +24,7 @@ class EdgeBasedGraphFactory; namespace detail { template class EdgeBasedNodeDataContainerImpl; -} +} // namespace detail namespace serialization { diff --git a/include/extractor/packed_osm_ids.hpp b/include/extractor/packed_osm_ids.hpp index e920260b7eb..137c2f67a96 100644 --- a/include/extractor/packed_osm_ids.hpp +++ b/include/extractor/packed_osm_ids.hpp @@ -12,7 +12,7 @@ namespace detail { template using PackedOSMIDs = util::detail::PackedVector; -} +} // namespace detail using PackedOSMIDsView = detail::PackedOSMIDs; using PackedOSMIDs = detail::PackedOSMIDs; diff --git a/include/extractor/restriction_parser.hpp b/include/extractor/restriction_parser.hpp index bf3f264554b..33367ae149d 100644 --- a/include/extractor/restriction_parser.hpp +++ b/include/extractor/restriction_parser.hpp @@ -11,7 +11,7 @@ namespace osmium { class Relation; -} +} // namespace osmium namespace osrm { diff --git a/include/extractor/scripting_environment.hpp b/include/extractor/scripting_environment.hpp index 888a75eee91..2a11afc33d1 100644 --- a/include/extractor/scripting_environment.hpp +++ b/include/extractor/scripting_environment.hpp @@ -26,7 +26,7 @@ namespace osrm namespace util { struct Coordinate; -} +} // namespace util namespace extractor { diff --git a/include/extractor/segment_data_container.hpp b/include/extractor/segment_data_container.hpp index 580c018ed75..70045504773 100644 --- a/include/extractor/segment_data_container.hpp +++ b/include/extractor/segment_data_container.hpp @@ -27,7 +27,7 @@ class CompressedEdgeContainer; namespace detail { template class SegmentDataContainerImpl; -} +} // namespace detail namespace serialization { diff --git a/include/extractor/serialization.hpp b/include/extractor/serialization.hpp index 363dd9c168e..e0e0127b20f 100644 --- a/include/extractor/serialization.hpp +++ b/include/extractor/serialization.hpp @@ -30,11 +30,11 @@ inline void read(storage::tar::FileReader &reader, const std::string &name, detail::IntersectionBearingsContainer &intersection_bearings) { - storage::serialization::read(reader, name + "/bearing_values", intersection_bearings.values); + storage::serialization::read(reader, name + "/bearing_values", intersection_bearings.values_); storage::serialization::read( - reader, name + "/node_to_class_id", intersection_bearings.node_to_class_id); + reader, name + "/node_to_class_id", intersection_bearings.node_to_class_id_); util::serialization::read( - reader, name + "/class_id_to_ranges", intersection_bearings.class_id_to_ranges_table); + reader, name + "/class_id_to_ranges", intersection_bearings.class_id_to_ranges_table_); } template @@ -42,11 +42,11 @@ inline void write(storage::tar::FileWriter &writer, const std::string &name, const detail::IntersectionBearingsContainer &intersection_bearings) { - storage::serialization::write(writer, name + "/bearing_values", intersection_bearings.values); + storage::serialization::write(writer, name + "/bearing_values", intersection_bearings.values_); storage::serialization::write( - writer, name + "/node_to_class_id", intersection_bearings.node_to_class_id); + writer, name + "/node_to_class_id", intersection_bearings.node_to_class_id_); util::serialization::write( - writer, name + "/class_id_to_ranges", intersection_bearings.class_id_to_ranges_table); + writer, name + "/class_id_to_ranges", intersection_bearings.class_id_to_ranges_table_); } // read/write for properties file diff --git a/include/guidance/segregated_intersection_classification.hpp b/include/guidance/segregated_intersection_classification.hpp index b8cf3b09448..d60d8d12025 100644 --- a/include/guidance/segregated_intersection_classification.hpp +++ b/include/guidance/segregated_intersection_classification.hpp @@ -9,7 +9,7 @@ namespace osrm namespace extractor { class NodeBasedGraphFactory; -} +} // namespace extractor namespace guidance { diff --git a/include/guidance/turn_data_container.hpp b/include/guidance/turn_data_container.hpp index 99b893cb0b7..de52461a283 100644 --- a/include/guidance/turn_data_container.hpp +++ b/include/guidance/turn_data_container.hpp @@ -19,7 +19,7 @@ namespace guidance namespace detail { template class TurnDataContainerImpl; -} +} // namespace detail namespace serialization { diff --git a/include/guidance/turn_lane_data.hpp b/include/guidance/turn_lane_data.hpp index 9ede132aba4..49431d25ebe 100644 --- a/include/guidance/turn_lane_data.hpp +++ b/include/guidance/turn_lane_data.hpp @@ -28,7 +28,7 @@ typedef std::vector LaneDataVector; // convertes a string given in the OSM format into a TurnLaneData vector OSRM_ATTR_WARN_UNUSED -LaneDataVector laneDataFromDescription(extractor::TurnLaneDescription turn_lane_description); +LaneDataVector laneDataFromDescription(const extractor::TurnLaneDescription &turn_lane_description); // Locate A Tag in a lane data vector (if multiple tags are set, the first one found is returned) LaneDataVector::const_iterator findTag(const extractor::TurnLaneType::Mask tag, diff --git a/include/partitioner/multi_level_partition.hpp b/include/partitioner/multi_level_partition.hpp index d83f9a341aa..bbe0978d62b 100644 --- a/include/partitioner/multi_level_partition.hpp +++ b/include/partitioner/multi_level_partition.hpp @@ -27,7 +27,7 @@ namespace partitioner namespace detail { template class MultiLevelPartitionImpl; -} +} // namespace detail using MultiLevelPartition = detail::MultiLevelPartitionImpl; using MultiLevelPartitionView = detail::MultiLevelPartitionImpl; diff --git a/include/storage/block.hpp b/include/storage/block.hpp index 75358d460c9..d8ba7685920 100644 --- a/include/storage/block.hpp +++ b/include/storage/block.hpp @@ -33,6 +33,7 @@ using NamedBlock = std::tuple; template Block make_block(uint64_t num_entries) { + // NOLINTNEXTLINE(misc-redundant-expression) static_assert(sizeof(T) % alignof(T) == 0, "aligned T* can't be used as an array pointer"); return Block{num_entries, sizeof(T) * num_entries, 0}; } diff --git a/include/storage/shared_memory_ownership.hpp b/include/storage/shared_memory_ownership.hpp index 6075199f2e6..5c3074e5e69 100644 --- a/include/storage/shared_memory_ownership.hpp +++ b/include/storage/shared_memory_ownership.hpp @@ -12,7 +12,7 @@ enum class Ownership View, External }; -} +} // namespace storage } // namespace osrm #endif // SHARED_MEMORY_OWNERSHIP_HPP diff --git a/include/storage/view_factory.hpp b/include/storage/view_factory.hpp index f8fe54212f3..1153103b97c 100644 --- a/include/storage/view_factory.hpp +++ b/include/storage/view_factory.hpp @@ -100,8 +100,7 @@ inline auto make_ebn_data_view(const SharedDataIndex &index, const std::string & auto annotation_data = make_vector_view(index, name + "/annotations"); - return extractor::EdgeBasedNodeDataView(std::move(edge_based_node_data), - std::move(annotation_data)); + return extractor::EdgeBasedNodeDataView(edge_based_node_data, annotation_data); } inline auto make_turn_data_view(const SharedDataIndex &index, const std::string &name) @@ -119,11 +118,8 @@ inline auto make_turn_data_view(const SharedDataIndex &index, const std::string const auto post_turn_bearings = make_vector_view(index, name + "/post_turn_bearings"); - return guidance::TurnDataView(std::move(turn_instructions), - std::move(lane_data_ids), - std::move(entry_class_ids), - std::move(pre_turn_bearings), - std::move(post_turn_bearings)); + return guidance::TurnDataView( + turn_instructions, lane_data_ids, entry_class_ids, pre_turn_bearings, post_turn_bearings); } inline auto make_segment_data_view(const SharedDataIndex &index, const std::string &name) diff --git a/include/util/indexed_data.hpp b/include/util/indexed_data.hpp index 475c68a96ed..5ce5bd4b382 100644 --- a/include/util/indexed_data.hpp +++ b/include/util/indexed_data.hpp @@ -23,7 +23,7 @@ namespace util namespace detail { template struct IndexedDataImpl; -} +} // namespace detail namespace serialization { diff --git a/include/util/packed_vector.hpp b/include/util/packed_vector.hpp index 8874ed40cef..dfe4ef7e31f 100644 --- a/include/util/packed_vector.hpp +++ b/include/util/packed_vector.hpp @@ -24,7 +24,7 @@ namespace util namespace detail { template class PackedVector; -} +} // namespace detail namespace serialization { diff --git a/include/util/static_rtree.hpp b/include/util/static_rtree.hpp index 6fbd59738d2..333855974f1 100644 --- a/include/util/static_rtree.hpp +++ b/include/util/static_rtree.hpp @@ -461,9 +461,9 @@ class StaticRTree template > explicit StaticRTree(const boost::filesystem::path &on_disk_file_name, const Vector &coordinate_list) - : m_coordinate_list(coordinate_list.data(), coordinate_list.size()) + : m_coordinate_list(coordinate_list.data(), coordinate_list.size()), + m_objects(mmapFile(on_disk_file_name, m_objects_region)) { - m_objects = mmapFile(on_disk_file_name, m_objects_region); } /** diff --git a/include/util/timed_histogram.hpp b/include/util/timed_histogram.hpp index 1e0a8bf832e..955fe013ef9 100644 --- a/include/util/timed_histogram.hpp +++ b/include/util/timed_histogram.hpp @@ -16,7 +16,7 @@ namespace util namespace detail { extern std::atomic_uint operation; -} +} // namespace detail /** * Captures a histogram with a bin size of `IndexBinSize` every `TimeBinSize` count operations. diff --git a/include/util/viewport.hpp b/include/util/viewport.hpp index 9ff1c84c735..acd0d03c965 100644 --- a/include/util/viewport.hpp +++ b/include/util/viewport.hpp @@ -25,7 +25,7 @@ static constexpr unsigned MIN_ZOOM = 1; // this is an upper bound to current display sizes static constexpr double VIEWPORT_WIDTH = 8 * web_mercator::TILE_SIZE; static constexpr double VIEWPORT_HEIGHT = 5 * web_mercator::TILE_SIZE; -static double INV_LOG_2 = 1. / std::log(2); +static const double INV_LOG_2 = 1. / std::log(2); } // namespace detail inline unsigned getFittedZoom(util::Coordinate south_west, util::Coordinate north_east) diff --git a/src/engine/api/json_factory.cpp b/src/engine/api/json_factory.cpp index 9ab7e4734f4..a0f71e50ec8 100644 --- a/src/engine/api/json_factory.cpp +++ b/src/engine/api/json_factory.cpp @@ -192,8 +192,8 @@ util::json::Object makeRouteStep(guidance::RouteStep step, util::json::Value geo } } - route_step.values["mode"] = extractor::travelModeToString(std::move(step.mode)); - route_step.values["maneuver"] = makeStepManeuver(std::move(step.maneuver)); + route_step.values["mode"] = extractor::travelModeToString(step.mode); + route_step.values["maneuver"] = makeStepManeuver(step.maneuver); route_step.values["geometry"] = std::move(geometry); route_step.values["driving_side"] = step.is_left_hand_driving ? "left" : "right"; diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index 5c5d96a7100..d3fa345c74f 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -484,7 +484,9 @@ std:: // OSM elements Lua parser tbb::filter_t buffer_transformer( - tbb::filter::parallel, [&](const SharedBuffer buffer) { + tbb::filter::parallel, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [&](const SharedBuffer buffer) { ParsedBuffer parsed_buffer; parsed_buffer.buffer = buffer; scripting_environment.ProcessElements(*buffer, @@ -531,7 +533,9 @@ std:: }); tbb::filter_t> buffer_relation_cache( - tbb::filter::parallel, [&](const SharedBuffer buffer) { + tbb::filter::parallel, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + [&](const SharedBuffer buffer) { if (!buffer) return std::shared_ptr{}; @@ -568,6 +572,7 @@ std:: unsigned number_of_relations = 0; tbb::filter_t, void> buffer_storage_relation( tbb::filter::serial_in_order, + // NOLINTNEXTLINE(performance-unnecessary-value-param) [&](const std::shared_ptr parsed_relations) { number_of_relations += parsed_relations->GetRelationsNum(); relations.Merge(std::move(*parsed_relations)); diff --git a/src/extractor/intersection/mergable_road_detector.cpp b/src/extractor/intersection/mergable_road_detector.cpp index 0e3c1cfa4a2..29ebe25b0a5 100644 --- a/src/extractor/intersection/mergable_road_detector.cpp +++ b/src/extractor/intersection/mergable_road_detector.cpp @@ -419,10 +419,10 @@ bool MergableRoadDetector::HaveSameDirection(const NodeID intersection_node, // sampling to correctly weight longer segments in regression calculations const auto constexpr SAMPLE_INTERVAL = 5; coordinates_to_the_left = coordinate_extractor.SampleCoordinates( - std::move(coordinates_to_the_left), distance_to_extract, SAMPLE_INTERVAL); + coordinates_to_the_left, distance_to_extract, SAMPLE_INTERVAL); coordinates_to_the_right = coordinate_extractor.SampleCoordinates( - std::move(coordinates_to_the_right), distance_to_extract, SAMPLE_INTERVAL); + coordinates_to_the_right, distance_to_extract, SAMPLE_INTERVAL); /* extract the number of lanes for a road * restricts a vector to the last two thirds of the length diff --git a/src/extractor/scripting_environment_lua.cpp b/src/extractor/scripting_environment_lua.cpp index a26f5d0a9a9..182dd792915 100644 --- a/src/extractor/scripting_environment_lua.cpp +++ b/src/extractor/scripting_environment_lua.cpp @@ -891,7 +891,7 @@ void Sol2ScriptingEnvironment::ProcessElements( { local_context.ProcessNode(node, result_node, relations); } - resulting_nodes.push_back({node, std::move(result_node)}); + resulting_nodes.push_back({node, result_node}); } break; case osmium::item_type::way: diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index 496da4eebe5..6ff608d9111 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -109,8 +109,8 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa }; auto isSegregated = [&](NodeID node1, - std::vector v1, - std::vector v2, + const std::vector &v1, + const std::vector &v2, EdgeInfo const ¤t, double edge_length) { // Internal intersection edges must be short and cannot be a roundabout. diff --git a/src/guidance/turn_lane_data.cpp b/src/guidance/turn_lane_data.cpp index 409d2e61369..76503c26e53 100644 --- a/src/guidance/turn_lane_data.cpp +++ b/src/guidance/turn_lane_data.cpp @@ -64,7 +64,7 @@ bool TurnLaneData::operator<(const TurnLaneData &other) const std::find(tag_by_modifier, tag_by_modifier + 8, other.tag); } -LaneDataVector laneDataFromDescription(TurnLaneDescription turn_lane_description) +LaneDataVector laneDataFromDescription(const TurnLaneDescription &turn_lane_description) { typedef std::unordered_map> LaneMap; // TODO need to handle cases that have none-in between two identical values diff --git a/src/updater/updater.cpp b/src/updater/updater.cpp index 3e6688b17e6..38a491042e0 100644 --- a/src/updater/updater.cpp +++ b/src/updater/updater.cpp @@ -70,6 +70,7 @@ namespace template inline bool is_aligned(const void *pointer) { + // NOLINTNEXTLINE(misc-redundant-expression) static_assert(sizeof(T) % alignof(T) == 0, "pointer can not be used as an array pointer"); return reinterpret_cast(pointer) % alignof(T) == 0; } diff --git a/src/util/geojson_debug_policies.cpp b/src/util/geojson_debug_policies.cpp index c45dde8d0aa..0cd898808a1 100644 --- a/src/util/geojson_debug_policies.cpp +++ b/src/util/geojson_debug_policies.cpp @@ -55,7 +55,7 @@ util::json::Object CoordinateVectorToMultiPoint::operator()(const std::vector &input_coordinates, const boost::optional &properties) const { - const auto coordinates = makeJsonArray(input_coordinates); + auto coordinates = makeJsonArray(input_coordinates); return makeFeature("MultiPoint", std::move(coordinates), properties); } @@ -64,7 +64,7 @@ util::json::Object CoordinateVectorToLineString::operator()(const std::vector &input_coordinates, const boost::optional &properties) const { - const auto coordinates = makeJsonArray(input_coordinates); + auto coordinates = makeJsonArray(input_coordinates); return makeFeature("LineString", std::move(coordinates), properties); } diff --git a/unit_tests/extractor/restriction_graph.cpp b/unit_tests/extractor/restriction_graph.cpp index 66c6d5bf2f5..f44a25dd148 100644 --- a/unit_tests/extractor/restriction_graph.cpp +++ b/unit_tests/extractor/restriction_graph.cpp @@ -15,7 +15,7 @@ using namespace osrm::extractor; TurnRestriction makeWayRestriction(NodeID from, std::vector via, NodeID to, bool is_only) { - WayRestriction wr{from, via, to}; + WayRestriction wr{from, std::move(via), to}; return TurnRestriction(wr, is_only); } @@ -100,8 +100,8 @@ std::map checkNode(const RestrictionGraph &graph, std::vector expected_instructions, std::vector expected_edges) { - checkInstructions(graph.GetRestrictions(node_id), expected_instructions); - checkEdges(graph.GetEdges(node_id), expected_edges); + checkInstructions(graph.GetRestrictions(node_id), std::move(expected_instructions)); + checkEdges(graph.GetEdges(node_id), std::move(expected_edges)); return nextEdges(graph.GetEdges(node_id)); } @@ -117,7 +117,8 @@ validateStartRestrictionNode(RestrictionGraph &graph, BOOST_REQUIRE_GE(node_id, graph.num_via_nodes); BOOST_REQUIRE_LT(node_id, graph.nodes.size()); - return checkNode(graph, node_id, restriction_instructions, restriction_edges); + return checkNode( + graph, node_id, std::move(restriction_instructions), std::move(restriction_edges)); } std::map @@ -139,7 +140,8 @@ validateViaRestrictionNode(RestrictionGraph &graph, << to); BOOST_REQUIRE_LT(via_node_idx, graph.num_via_nodes); - return checkNode(graph, via_node_idx, restriction_instructions, restriction_edges); + return checkNode( + graph, via_node_idx, std::move(restriction_instructions), std::move(restriction_edges)); } BOOST_AUTO_TEST_CASE(empty_restrictions) diff --git a/unit_tests/util/range_table.cpp b/unit_tests/util/range_table.cpp index 4d2053538dc..d9eacc910b8 100644 --- a/unit_tests/util/range_table.cpp +++ b/unit_tests/util/range_table.cpp @@ -14,7 +14,7 @@ using namespace osrm::util; constexpr unsigned BLOCK_SIZE = 16; typedef RangeTable TestRangeTable; -void ConstructionTest(std::vector lengths, std::vector offsets) +void ConstructionTest(const std::vector &lengths, const std::vector &offsets) { BOOST_CHECK_EQUAL(lengths.size(), offsets.size() - 1);