Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix a few sonar issues in Cuboid portal shell #4113

Merged
merged 35 commits into from
Mar 1, 2025

Conversation

paulgessinger
Copy link
Member

@paulgessinger paulgessinger commented Feb 27, 2025

Blocked by:

--- END COMMIT MESSAGE ---

Any further description goes here, @-mentions are ok here!

  • Use a conventional commits prefix: quick summary
    • We mostly use feat, fix, refactor, docs, chore and build types.
  • A milestone will be assigned by one of the maintainers

Summary by CodeRabbit

  • New Features
    • Introduced dedicated portal shell components for cuboid and cylinder geometries, enabling enhanced management of volume boundaries and directional mappings.
  • Documentation
    • Updated geometry documentation now covers the new cuboid portal shell classes and clarifies face-to-axis mappings.
  • Tests
    • Added comprehensive unit tests for cuboid and cylinder portal shells to ensure robust and reliable functionality.

@paulgessinger paulgessinger added the 🛑 blocked This item is blocked by another item label Feb 27, 2025
@paulgessinger paulgessinger added this to the next milestone Feb 27, 2025
Copy link

coderabbitai bot commented Feb 27, 2025

Walkthrough

Changed, much has been. New abstract and concrete classes for cuboid and cylinder portal shells introduced, they have been, along with enhanced methods for setting and retrieving portals. Header files, renamed methods, and updated dependency inclusions now guide the geometry subsystem. Unit tests and documentation, they have been updated as well. Error handling, improved it is, with assertions replaced by exception throws. Overall, structure and clarity, improved they have.

Changes

File(s) Change Summary
Core/include/Acts/Geometry/CuboidPortalShell.hpp
Core/src/Geometry/CuboidPortalShell.cpp
New file and implementation added for CuboidPortalShell with derived classes SingleCuboidPortalShell and CuboidStackPortalShell. Methods for portal retrieval, assignment, volume filling, and operator overloading declared and defined.
Core/include/Acts/Geometry/CuboidVolumeBounds.hpp
Core/src/Geometry/CuboidVolumeBounds.cpp
Core/src/Geometry/CuboidVolumeStack.cpp
Tests/UnitTests/Core/Geometry/CuboidVolumeStackTests.cpp
Enum Face introduced; method fromAxisDirection renamed to boundsFromAxisDirection, and new method facesFromAxisDirection added. All calls updated accordingly in both implementation and tests.
Core/include/Acts/Geometry/CylinderPortalShell.hpp
Core/src/Geometry/CylinderPortalShell.cpp
Core/include/Acts/Geometry/CylinderContainerBlueprintNode.hpp
Core/src/Geometry/CylinderContainerBlueprintNode.cpp
Core/include/Acts/Geometry/MaterialDesignatorBlueprintNode.hpp
Core/src/Geometry/StaticBlueprintNode.cpp
Tests/UnitTests/Core/Geometry/CylinderPortalShellTests.cpp
New file and implementations added for CylinderPortalShell with derived classes SingleCylinderPortalShell and CylinderStackPortalShell. Include directives updated, replacing PortalShell.hpp with CylinderPortalShell.hpp across various nodes.
Core/include/Acts/Geometry/PortalShell.hpp Removed cylinder-related classes (CylinderPortalShell, SingleCylinderPortalShell, CylinderStackPortalShell) and their methods, reducing outdated dependencies.
Core/src/Geometry/Blueprint.cpp
Core/src/Geometry/CMakeLists.txt
Updated includes and source file lists to remove PortalShell.cpp and add CylinderPortalShell.cpp and CuboidPortalShell.cpp.
Core/src/Geometry/TrivialPortalLink.cpp Assertion in resolveVolume replaced with throw_assert for exception-based error handling; new header Acts/Utilities/ThrowAssert.hpp included.
Tests/UnitTests/Core/Geometry/CMakeLists.txt
Tests/UnitTests/Core/Geometry/CuboidPortalShellTests.cpp
Unit test configuration updated: removed generic PortalShell test; added tests for CylinderPortalShell and CuboidPortalShell including comprehensive tests for construction, portal assignment, and volume registration.
docs/core/geometry/concepts.md Documentation enhanced with new entries for Acts::CuboidPortalShell, Acts::SingleCuboidPortalShell, and Acts::CuboidStackPortalShell.

Sequence Diagram(s)

sequenceDiagram
    participant TV as TrackingVolume
    participant SCP as SingleCuboidPortalShell
    participant CSP as CuboidStackPortalShell
    participant CP as CuboidPortalShell (Interface)

    TV->>SCP: Request portal(face)
    SCP-->>TV: Return portal instance
    TV->>CSP: Pass volume for multi-shell filling
    CSP->>SCP: Delegate portal management
    SCP->>CP: Set/retrieve portal as needed
Loading
sequenceDiagram
    participant TV as TrackingVolume
    participant SCP as SingleCylinderPortalShell
    participant CST as CylinderStackPortalShell
    participant CP as CylinderPortalShell (Interface)

    TV->>SCP: Create and assign cylinder portal
    SCP-->>TV: Return portal via portal(face)
    TV->>CST: Aggregate multiple cylinder shells
    CST->>CP: Manage portal operations consistently
Loading

Possibly related PRs

Suggested labels

Component - Examples, automerge

Suggested reviewers

  • paulgessinger

Poem

In the code galaxy, a new path we pave,
Cuboid and cylinder shells, the Force they crave.
Portals set and fetched, through volume they flow,
Refactored and tested, through the code they grow.
Assert now throws, errors handled with grace,
In geometric harmony, the Force finds its place.
May the code be with you, always, in this space!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Component - Core Affects the Core module Component - Documentation Affects the documentation labels Feb 27, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (4)
Core/src/Geometry/CuboidVolumeBounds.cpp (1)

172-185: Check consistent usage of AxisDirection, hmmm.

Well-structured this function is, yes. Factor out repeated "Invalid axis direction" message, you could, to keep the code more uniform and avoid duplication, hmmm.

Core/include/Acts/Geometry/CuboidPortalShell.hpp (2)

63-98: Careful with raw pointers, you should be.

Yes, storing TrackingVolume* m_volume is convenient. If volume’s lifetime guaranteed beyond this shell it is not, risk of dangling pointer we have. Consider a std::shared_ptr<TrackingVolume> or references if lifetime is well-defined, you might.


100-153: A composite shell, you have built.

Stacking direction checked you must, yes? Validate that shells vector is not empty and that all shells share consistent geometry parameters for the stack, you should. Potential bugs avoided, they will be.

Need a helper function for the geometry consistency check, do you?

Core/include/Acts/Geometry/CylinderPortalShell.hpp (1)

63-95: A single cylinder shell, hrrm. Correct design, yes.

Yet watch for concurrency issues you must, if volumes updated or replaced concurrently. Data races, cause trouble they can. Safeguards, you might place.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c542ea3 and 0dfc145.

📒 Files selected for processing (20)
  • Core/include/Acts/Geometry/CuboidPortalShell.hpp (1 hunks)
  • Core/include/Acts/Geometry/CuboidVolumeBounds.hpp (3 hunks)
  • Core/include/Acts/Geometry/CylinderContainerBlueprintNode.hpp (1 hunks)
  • Core/include/Acts/Geometry/CylinderPortalShell.hpp (1 hunks)
  • Core/include/Acts/Geometry/MaterialDesignatorBlueprintNode.hpp (1 hunks)
  • Core/include/Acts/Geometry/PortalShell.hpp (1 hunks)
  • Core/src/Geometry/Blueprint.cpp (1 hunks)
  • Core/src/Geometry/CMakeLists.txt (1 hunks)
  • Core/src/Geometry/CuboidPortalShell.cpp (1 hunks)
  • Core/src/Geometry/CuboidVolumeBounds.cpp (2 hunks)
  • Core/src/Geometry/CuboidVolumeStack.cpp (12 hunks)
  • Core/src/Geometry/CylinderContainerBlueprintNode.cpp (1 hunks)
  • Core/src/Geometry/CylinderPortalShell.cpp (1 hunks)
  • Core/src/Geometry/StaticBlueprintNode.cpp (1 hunks)
  • Core/src/Geometry/TrivialPortalLink.cpp (2 hunks)
  • Tests/UnitTests/Core/Geometry/CMakeLists.txt (1 hunks)
  • Tests/UnitTests/Core/Geometry/CuboidPortalShellTests.cpp (1 hunks)
  • Tests/UnitTests/Core/Geometry/CuboidVolumeStackTests.cpp (5 hunks)
  • Tests/UnitTests/Core/Geometry/CylinderPortalShellTests.cpp (1 hunks)
  • docs/core/geometry/concepts.md (1 hunks)
✅ Files skipped from review due to trivial changes (6)
  • Core/src/Geometry/CylinderPortalShell.cpp
  • Core/src/Geometry/StaticBlueprintNode.cpp
  • Tests/UnitTests/Core/Geometry/CuboidVolumeStackTests.cpp
  • Core/src/Geometry/Blueprint.cpp
  • Core/src/Geometry/CylinderContainerBlueprintNode.cpp
  • Core/src/Geometry/CuboidVolumeStack.cpp
🧰 Additional context used
🧠 Learnings (1)
Core/include/Acts/Geometry/CylinderContainerBlueprintNode.hpp (1)
Learnt from: paulgessinger
PR: acts-project/acts#3869
File: Core/include/Acts/Geometry/CylinderContainerBlueprintNode.hpp:28-29
Timestamp: 2024-12-05T20:21:24.253Z
Learning: In `CylinderContainerBlueprintNode`, validation that child volumes are cylinders is enforced by `CylinderVolumeStack`.
🪛 Cppcheck (2.10-2)
Tests/UnitTests/Core/Geometry/CuboidPortalShellTests.cpp

[error] 194-194: There is an unknown macro here somewhere. Configuration is required. If BOOST_AUTO_TEST_SUITE is a macro then please configure it.

(unknownMacro)

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: merge-sentinel
  • GitHub Check: unused_files
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, clang++)
  • GitHub Check: macos
  • GitHub Check: missing_includes
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, g++)
  • GitHub Check: linux_ubuntu
  • GitHub Check: build_debug
🔇 Additional comments (24)
Core/src/Geometry/CMakeLists.txt (1)

46-47: Updated source files to use specialized portal shells, hmm.

Replaced the generic PortalShell.cpp with specialized implementations CylinderPortalShell.cpp and CuboidPortalShell.cpp. Good refactoring this is, yes! Better separation of concerns, it provides.

docs/core/geometry/concepts.md (1)

57-64: Documentation for new cuboid portal shell classes, added it has been.

Properly documented the new classes are:

  • Acts::CuboidPortalShell
  • Acts::SingleCuboidPortalShell
  • Acts::CuboidStackPortalShell

Consistent with existing documentation style, this is. Clear understanding for users, it provides.

Tests/UnitTests/Core/Geometry/CylinderPortalShellTests.cpp (1)

17-17: Updated include to use the specialized header, wise this is.

Replaced the generic PortalShell.hpp include with the specific CylinderPortalShell.hpp. More precise dependencies, this creates. Aligns with the refactoring of portal shell classes, it does.

Tests/UnitTests/Core/Geometry/CMakeLists.txt (1)

38-39: Adding new unittests, wise move it is
Broader coverage for CylinderPortalShell and CuboidPortalShell, you achieve. Verify edge cases, you must.

Core/include/Acts/Geometry/CylinderContainerBlueprintNode.hpp (1)

12-12: Include CylinderPortalShell, hmm?
Consistent with the new geometry approach this is. Confirm other references are updated, you should.

Core/src/Geometry/TrivialPortalLink.cpp (2)

13-13: ThrowAssert you include, improved error handling it yields
No longer rely solely on debug builds, you do. Flexible and safer this method is.


36-38: To throw you choose, if surface check fails
Silent misbehavior, you avoid. Clear and safe, this approach remains.

Core/include/Acts/Geometry/PortalShell.hpp (1)

11-12: Add cstddef and string includes, done you have
Needed they are, suspect I do. Harmless to keep, unless unused they become.

Core/src/Geometry/CuboidVolumeBounds.cpp (1)

187-207: Simple and effective, it appears.

Implementation aligned well with the intended face logic, yes. Merged neatly, your return of negative/positive faces and side faces is.

Core/include/Acts/Geometry/CuboidVolumeBounds.hpp (3)

12-12: Needed include, this is.

Synchronized with new face definition, it aligns.


62-72: Introduced enum Face, strong clarity it brings.

Mapped to boundary surfaces, well it is.


172-182: Method declarations consistent, they are.

Match the definitions in the source file, they do.

Tests/UnitTests/Core/Geometry/CuboidPortalShellTests.cpp (5)

55-137: ConstructionFromVolume tests thorough, yes.

Validates creation with correct and incorrect bounds, it does. Coverage strong, seeing that std::invalid_argument is thrown, good.


139-192: Portal assignment check, well done.

Verifies replacement of portals and ensures unaffected faces remain correct, yes.


194-353: Parametric testing, make sense it does.

Covers multiple directions by data-driven approach, good coverage you have.

🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 194-194: There is an unknown macro here somewhere. Configuration is required. If BOOST_AUTO_TEST_SUITE is a macro then please configure it.

(unknownMacro)


354-743: Nested stacks tested in detail, hmm.

Ensuring combined volumes align, strong verification it is. Good approach, you have.


744-781: Filling and registering volumes, tested thoroughly.

Checks internal portal linkage, nice coverage.

Core/src/Geometry/CuboidPortalShell.cpp (5)

30-39: Filling logic, yes.

Through each face we fill, ensuring volume’s portals are updated, correct.


41-66: Constructor validity check, done well.

Throws for non-cuboid bounds, consistent with design.


67-114: Portal getters and setters, hmmm.

Clean and readable, they are. Corner cases appear handled.


116-235: Stacked shell logic, quite robust.

Sorting by coordinate and merging portals in base/back faces, well done. Possibly watch for expansions if future axes appear.


236-311: Validation, transformations, labeling, complete they are.

Code cohesive and consistent with the design, it is.

Core/include/Acts/Geometry/CuboidPortalShell.hpp (1)

27-50: Design is strong, hmmm. Extend it well, you do.

A sound base class for cuboid portal shells, yes. Still, verify you must that all face accesses (e.g., portal(Face face)) handle unexpected faces or out-of-bounds usage gracefully, hmmm.

Core/include/Acts/Geometry/CylinderPortalShell.hpp (1)

24-48: A flexible base, hmmm.

Yes, CylinderPortalShell wise it seems. Ensure you do that uninitialized faces cause no runtime confusion. Enforce constraints for faces and radial bounds, best practice it is.

Copy link

github-actions bot commented Feb 27, 2025

📊: Physics performance monitoring for bd4b8af

Full contents

physmon summary

@github-actions github-actions bot removed the Component - Documentation Affects the documentation label Feb 28, 2025
@paulgessinger paulgessinger removed the 🛑 blocked This item is blocked by another item label Feb 28, 2025
Copy link
Contributor

@ssdetlab ssdetlab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, looks cleaner. Let's merge it in.

@kodiakhq kodiakhq bot merged commit a26016a into acts-project:main Mar 1, 2025
45 checks passed
@github-actions github-actions bot removed the automerge label Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Core Affects the Core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants