Skip to content

Commit

Permalink
ci: Add clang-tidy check for nested namespace definitions (#3084)
Browse files Browse the repository at this point in the history
New language feature in C++17:
Nested namespace definitions, e.g., `namespace X::Y { … }` instead of `namespace X { namespace Y { … } }`

We had a good mix between them, but clang-tidy has with `modernize-concat-nested-namespaces` an option, to automatically check for them.

I stumbled over this, when reading through the cpp-standard-updates and I think this improves readability.

Hits will be reported similar to this one:
```
╭─ /builds/acts/ci-bridge/src/Tests/UnitTests/Plugins/TGeo/TGeoParserTests.cpp─╮
│ 🟡                                                                           │
│ /builds/acts/ci-bridge/src/Tests/UnitTests/Plugins/TGeo/TGeoParserTests.cpp: │
│ 27:1 WARNING [modernize-concat-nested-namespaces]                            │
│ ╭──────────────────────────────────────────────────────────────────────────╮ │
│ │ nested namespaces can be concatenated                                    │ │
│ │    27 | namespace Acts {                                                 │ │
│ │       | ^~~~~~~~~~~~~~~~                                                 │ │
│ │    28 |                                                                  │ │
│ │    29 | namespace Test {                                                 │ │
│ │       | ~~~~~~~~~~~~~~                                                   │ │
│ │       | namespace Acts::Test                                             │ │
│ │                                                                          │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│ ──────────────────────────────────────────────────────────────────────────── │
╰──────────────────────────────────────────────────────────────────────────────╯
```
  • Loading branch information
AJPfleger authored Apr 8, 2024
1 parent 1374baa commit 6883f31
Show file tree
Hide file tree
Showing 285 changed files with 572 additions and 1,258 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
Checks: '-*,readability-container-size-empty,readability-implicit-bool-cast,readability-implicit-bool-conversion,modernize-use-equals-default,modernize-use-override,modernize-use-using,readability-braces-around-statements,modernize-use-nullptr,performance-move-const-arg,cppcoreguidelines-pro-type-member-init,cppcoreguidelines-init-variables,clang-analyzer-optin.cplusplus.UninitializedObject,readability-operators-representation'
Checks: '-*,readability-container-size-empty,readability-implicit-bool-cast,readability-implicit-bool-conversion,modernize-concat-nested-namespaces,modernize-use-equals-default,modernize-use-override,modernize-use-using,readability-braces-around-statements,modernize-use-nullptr,performance-move-const-arg,cppcoreguidelines-pro-type-member-init,cppcoreguidelines-init-variables,clang-analyzer-optin.cplusplus.UninitializedObject,readability-operators-representation'
HeaderFilterRegex: '.*(?<!nlohmann\/json)\.(hpp|cpp|ipp)$'
AnalyzeTemporaryDtors: true
CheckOptions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

#include <unordered_map>

namespace ActsAlignment {
namespace detail {
namespace ActsAlignment::detail {

using namespace Acts;
///
Expand Down Expand Up @@ -299,5 +298,4 @@ TrackAlignmentState trackAlignmentState(
return alignState;
}

} // namespace detail
} // namespace ActsAlignment
} // namespace ActsAlignment::detail
6 changes: 2 additions & 4 deletions Alignment/src/Kernel/detail/AlignmentEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

#include "ActsAlignment/Kernel/detail/AlignmentEngine.hpp"

namespace ActsAlignment {
namespace detail {
namespace ActsAlignment::detail {

void resetAlignmentDerivative(Acts::AlignmentToBoundMatrix& alignToBound,
AlignmentMask mask) {
Expand All @@ -33,5 +32,4 @@ void resetAlignmentDerivative(Acts::AlignmentToBoundMatrix& alignToBound,
}
}

} // namespace detail
} // namespace ActsAlignment
} // namespace ActsAlignment::detail
1 change: 1 addition & 0 deletions CI/clang_tidy/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ limits:
"readability-braces-around-statements": 0
"readability-implicit-bool-cast": 0
"readability-implicit-bool-conversion": 0
"modernize-concat-nested-namespaces": 0
"modernize-use-using": 0
"modernize-use-override": 0
"modernize-use-equals-default" : 0
Expand Down
6 changes: 2 additions & 4 deletions Core/include/Acts/Detector/Blueprint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
#include <string>
#include <vector>

namespace Acts {
namespace Experimental {
namespace Acts::Experimental {

class IGeometryIdGenerator;
class IInternalStructureBuilder;
Expand Down Expand Up @@ -122,5 +121,4 @@ struct Node final {
};

} // namespace Blueprint
} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental
6 changes: 2 additions & 4 deletions Core/include/Acts/Detector/CuboidalContainerBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include <string>
#include <vector>

namespace Acts {
namespace Experimental {
namespace Acts::Experimental {

class IRootVolumeFinderBuilder;
class IGeometryIdGenerator;
Expand Down Expand Up @@ -106,5 +105,4 @@ class CuboidalContainerBuilder : public IDetectorComponentBuilder {
std::unique_ptr<const Logger> m_logger;
};

} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental
6 changes: 2 additions & 4 deletions Core/include/Acts/Detector/CylindricalContainerBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
#include <string>
#include <vector>

namespace Acts {
namespace Experimental {
namespace Acts::Experimental {

class IRootVolumeFinderBuilder;
class IGeometryIdGenerator;
Expand Down Expand Up @@ -109,5 +108,4 @@ class CylindricalContainerBuilder : public IDetectorComponentBuilder {
std::unique_ptr<const Logger> m_logger;
};

} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental
6 changes: 2 additions & 4 deletions Core/include/Acts/Detector/DetectorBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
#include <memory>
#include <string>

namespace Acts {
namespace Experimental {
namespace Acts::Experimental {

class IGeometryIdGenerator;

Expand Down Expand Up @@ -69,5 +68,4 @@ class DetectorBuilder final : public IDetectorBuilder {
std::unique_ptr<const Logger> m_logger;
};

} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental
6 changes: 2 additions & 4 deletions Core/include/Acts/Detector/DetectorVolumeBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include <memory>
#include <string>

namespace Acts {
namespace Experimental {
namespace Acts::Experimental {
class IExternalStructureBuilder;
class IInternalStructureBuilder;
class IGeometryIdGenerator;
Expand Down Expand Up @@ -79,5 +78,4 @@ class DetectorVolumeBuilder : public IDetectorComponentBuilder {
std::unique_ptr<const Logger> m_logger;
};

} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental
8 changes: 2 additions & 6 deletions Core/include/Acts/Detector/GeometryCompatibilityConcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
#include "Acts/Geometry/TrackingVolume.hpp"
#include "Acts/Utilities/TypeTraits.hpp"

namespace Acts {

namespace Concepts {
namespace Acts::Concepts {

// Types to check compatibility of
template <typename propagator_state_t, typename navigator_t>
Expand Down Expand Up @@ -48,6 +46,4 @@ template <typename propagator_state_t, typename navigator_t>
constexpr bool NavigationCompatibilityConcept =
NavigationCompatibilityConceptImpl<propagator_state_t, navigator_t>::value;

} // namespace Concepts

} // namespace Acts
} // namespace Acts::Concepts
6 changes: 2 additions & 4 deletions Core/include/Acts/Detector/GeometryIdMapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

#include <map>

namespace Acts {
namespace Experimental {
namespace Acts::Experimental {

/// @brief This is a mapper of geometry ids, which can be used to
/// assign predefined geometry ids to objects
Expand Down Expand Up @@ -144,5 +143,4 @@ class GeometryIdMapper final : public IGeometryIdGenerator {
std::unique_ptr<const Logger> m_logger;
};

} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental
7 changes: 2 additions & 5 deletions Core/include/Acts/Detector/IndexedRootVolumeFinderBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
#include <memory>
#include <vector>

namespace Acts {

namespace Experimental {
namespace Acts::Experimental {

class DetectorVolume;

Expand All @@ -45,5 +43,4 @@ class IndexedRootVolumeFinderBuilder final : public IRootVolumeFinderBuilder {
std::vector<Acts::BinningValue> m_casts;
};

} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental
8 changes: 2 additions & 6 deletions Core/include/Acts/Detector/KdtSurfacesProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
#include <tuple>
#include <vector>

namespace Acts {

namespace Experimental {
namespace Acts::Experimental {

/// @brief A wrapper class around a KDTree of surfaces
///
Expand Down Expand Up @@ -195,6 +193,4 @@ class KdtSurfacesProvider : public ISurfacesProvider {
Extent m_region;
};

} // namespace Experimental

} // namespace Acts
} // namespace Acts::Experimental
6 changes: 2 additions & 4 deletions Core/include/Acts/Detector/LayerStructureBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
#include <string>
#include <vector>

namespace Acts {
namespace Experimental {
namespace Acts::Experimental {

/// @brief This is a builder of layer structures to be contained
/// within a DetectorVolume, it extends the IInternalStructureBuilder
Expand Down Expand Up @@ -130,5 +129,4 @@ class LayerStructureBuilder : public IInternalStructureBuilder {
std::unique_ptr<const Logger> m_logger;
};

} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental
6 changes: 2 additions & 4 deletions Core/include/Acts/Detector/MultiWireStructureBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
#include <string>
#include <vector>

namespace Acts {
namespace Experimental {
namespace Acts::Experimental {

class MultiWireStructureBuilder {
public:
Expand Down Expand Up @@ -75,5 +74,4 @@ class MultiWireStructureBuilder {
std::unique_ptr<const Acts::Logger> mLogger;
};

} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental
7 changes: 2 additions & 5 deletions Core/include/Acts/Detector/ProtoBinning.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
#include <string>
#include <vector>

namespace Acts {

namespace Experimental {
namespace Acts::Experimental {

/// @brief Simple helper class to define a binning structure
///
Expand Down Expand Up @@ -146,5 +144,4 @@ struct BinningDescription {
}
};

} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental
7 changes: 2 additions & 5 deletions Core/include/Acts/Detector/ProtoSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#include <stdexcept>
#include <vector>

namespace Acts {

namespace Experimental {
namespace Acts::Experimental {
/// @brief Support surface building instructions
///
/// There are two ways to build a support surface:
Expand Down Expand Up @@ -78,5 +76,4 @@ struct ProtoSupport {
bool assignToAll = true;
};

} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental
6 changes: 2 additions & 4 deletions Core/include/Acts/Detector/VolumeStructureBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include <optional>
#include <string>

namespace Acts {
namespace Experimental {
namespace Acts::Experimental {

/// This class provides the external detector volume structure, configured
/// either from:
Expand Down Expand Up @@ -77,5 +76,4 @@ class VolumeStructureBuilder : public IExternalStructureBuilder {
std::unique_ptr<const Logger> m_logger;
};

} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental
12 changes: 2 additions & 10 deletions Core/include/Acts/Detector/detail/BlueprintDrawer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
#include <ostream>
#include <string>

namespace Acts {

namespace Experimental {

namespace detail {
namespace BlueprintDrawer {
namespace Acts::Experimental::detail::BlueprintDrawer {

/// @brief Nested options struct for the drawer
struct Options {
Expand Down Expand Up @@ -63,7 +58,4 @@ struct Options {
void dotStream(std::ostream& ss, const Blueprint::Node& node,
const Options& options = Options{});

} // namespace BlueprintDrawer
} // namespace detail
} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental::detail::BlueprintDrawer
12 changes: 2 additions & 10 deletions Core/include/Acts/Detector/detail/BlueprintHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
#include "Acts/Detector/Blueprint.hpp"
#include "Acts/Utilities/BinningData.hpp"

namespace Acts {

namespace Experimental {

namespace detail {
namespace BlueprintHelper {
namespace Acts::Experimental::detail::BlueprintHelper {

/// @brief Sort the nodes in the blueprint container node
///
Expand All @@ -42,7 +37,4 @@ void fillGapsCylindrical(Blueprint::Node& node, bool adjustToParent = true);
/// @param adjustToParent nodes, if nodes should be adjusted to parent
void fillGapsCuboidal(Blueprint::Node& node, bool adjustToParent = true);

} // namespace BlueprintHelper
} // namespace detail
} // namespace Experimental
} // namespace Acts
} // namespace Acts::Experimental::detail::BlueprintHelper
13 changes: 4 additions & 9 deletions Core/include/Acts/Detector/detail/CuboidalDetectorHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@
#include <memory>
#include <vector>

namespace Acts {

namespace Experimental {
namespace Acts::Experimental {

class DetectorVolume;
class Portal;

namespace detail {
namespace CuboidalDetectorHelper {
namespace detail::CuboidalDetectorHelper {

/// @brief Connect detector volumes given a binning value
///
Expand Down Expand Up @@ -81,7 +78,5 @@ std::array<std::vector<ActsScalar>, 3u> xyzBoundaries(
const std::vector<const DetectorVolume*>& volumes,
Acts::Logging::Level logLevel = Acts::Logging::INFO);

} // namespace CuboidalDetectorHelper
} // namespace detail
} // namespace Experimental
} // namespace Acts
} // namespace detail::CuboidalDetectorHelper
} // namespace Acts::Experimental
13 changes: 4 additions & 9 deletions Core/include/Acts/Detector/detail/CylindricalDetectorHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@
#include <memory>
#include <vector>

namespace Acts {

namespace Experimental {
namespace Acts::Experimental {

class DetectorVolume;
class Portal;

namespace detail {
namespace CylindricalDetectorHelper {
namespace detail::CylindricalDetectorHelper {

/// @brief Connect detector volumes in R
///
Expand Down Expand Up @@ -240,7 +237,5 @@ std::array<std::vector<ActsScalar>, 3u> rzphiBoundaries(
uniqueBoundaries[2].end())}};
}

} // namespace CylindricalDetectorHelper
} // namespace detail
} // namespace Experimental
} // namespace Acts
} // namespace detail::CylindricalDetectorHelper
} // namespace Acts::Experimental
Loading

0 comments on commit 6883f31

Please sign in to comment.