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

refactor: brace-enclosed initializers for pair/tuple returns #3931

Merged
merged 5 commits into from
Dec 5, 2024

Conversation

AJPfleger
Copy link
Contributor

@AJPfleger AJPfleger commented Dec 2, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced readability in multiple methods by adopting brace initialization for return statements, simplifying the syntax without changing functionality.
  • Bug Fixes

    • Improved error handling in various functions to ensure robustness against invalid inputs.
  • Documentation

    • Updated comments for clarity and corrected minor typographical errors in method descriptions.
  • Tests

    • Simplified return statements in test cases, ensuring consistency in coding style while maintaining existing tests and their assertions.

@AJPfleger AJPfleger added this to the next milestone Dec 2, 2024
Copy link

coderabbitai bot commented Dec 2, 2024

Walkthrough

Many changes made, focus they do on simplifying return statements across various classes and methods. Replaced std::make_pair and std::make_tuple with brace initialization syntax, enhancing readability without altering functionality. Constructors and methods retain their logic, ensuring type safety and control flow remain intact. Preserved are error handling mechanisms, with some minor enhancements. Modernize the codebase, these changes aim, while maintaining existing behaviors.

Changes

File Path Change Summary
Core/include/Acts/EventData/MultiComponentTrackParameters.hpp Updated operator[] and constructor to use brace initialization for return types.
Core/include/Acts/Seeding/BinnedGroupIterator.ipp Simplified operator*() return statement using brace initialization.
Core/include/Acts/Seeding/SeedFinder.ipp Modified retrieveRadiusRangeForMiddle return statement to use brace initialization.
Core/include/Acts/TrackFitting/detail/KalmanGlobalCovariance.hpp Changed globalTrackParametersCovariance return statement to brace initialization.
Core/include/Acts/Utilities/GridBinFinder.ipp Updated getSizePerAxis return statements to brace initialization; added check for empty vectors.
Core/include/Acts/Utilities/TrackHelpers.hpp Replaced std::make_pair with brace initialization in multiple functions.
Core/src/Propagator/detail/CovarianceEngine.cpp Simplified curvilinearState return statement using brace initialization.
Core/src/Propagator/detail/SympyCovarianceEngine.cpp Modified curvilinearState return statement to use brace initialization.
Core/src/Surfaces/detail/AlignmentHelper.cpp Changed rotationToLocalAxesDerivative return statement to brace initialization.
Core/src/Surfaces/detail/AnnulusBoundsHelper.cpp Updated create method return statement to brace initialization.
Core/src/Utilities/SpacePointUtility.cpp Simplified globalCoords return statement using brace initialization.
Core/src/Vertexing/AdaptiveGridTrackDensity.cpp Modified getMaxZTPosition return statement to use brace initialization.
Core/src/Vertexing/ImpactPointEstimator.cpp Updated return statements in getDistanceAndMomentumImpl and getDistanceAndMomentum to brace initialization; enhanced error handling in performNewtonOptimization.
Core/src/Vertexing/Vertex.cpp Changed fitQuality return statement to brace initialization.
Examples/Detectors/ContextualDetector/src/AlignedDetector.cpp Updated finalize return statement to brace initialization.
Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp Modified finalize method return statement to brace initialization; second overload unchanged.
Examples/Detectors/GenericDetector/src/GenericDetector.cpp Simplified finalize return statement using brace initialization.
Examples/Detectors/TGeoDetector/src/TGeoDetector.cpp Changed finalize return statement to brace initialization; updated configuration reading process.
Examples/Detectors/TelescopeDetector/src/TelescopeDetector.cpp Updated finalize return statement to brace initialization.
Examples/Framework/src/EventData/ScalingCalibrator.cpp Modified parseMapKey for error handling and simplified return statement.
Examples/Framework/src/Utilities/Paths.cpp Simplified return statements in determineEventFilesRange to brace initialization.
Examples/Io/Root/include/ActsExamples/Io/Root/RootMaterialDecorator.hpp Changed materialMaps return statement to brace initialization.
Examples/Io/Root/src/RootNuclearInteractionParametersWriter.cpp Simplified return statements in histogram building functions to brace initialization.
Examples/Io/Root/src/RootTrackStatesWriter.cpp Updated return statements in getTrackParams lambda to brace initialization.
Examples/Io/Root/src/detail/NuclearInteractionParametrisation.cpp Simplified return statements in multiple functions to brace initialization.
Examples/Scripts/compareRootFiles.hpp Changed create method return statement to brace initialization.
Fatras/include/ActsFatras/Physics/ElectroMagnetic/PhotonConversion.hpp Updated generatePathLimits return statement to brace initialization.
Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp Simplified return statements in generatePathLimits and sampleKinematics to brace initialization.
Fatras/src/Physics/NuclearInteraction/NuclearInteraction.cpp Updated globalAngle return statement to brace initialization; other methods unchanged.
Plugins/DD4hep/src/DD4hepBlueprintFactory.cpp Simplified return statements in extractExternals and extractInternals to brace initialization.
Plugins/Geant4/src/Geant4Converters.cpp Updated return statements in multiple methods to brace initialization.
Plugins/GeoModel/src/GeoModelBlueprintCreater.cpp Simplified return statements in createInternalStructureBuilder and parseBounds to brace initialization.
Plugins/GeoModel/src/detail/GeoModelExtentHelper.cpp Corrected spelling and simplified return statement in extentFromTable to brace initialization.
Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp Simplified return statement in makeBarrelStagger to brace initialization.
Tests/UnitTests/Core/Geometry/SurfaceArrayCreatorTests.cpp Updated return statement in makeBarrelStagger to brace initialization; tests remain unchanged.
Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp Simplified return statement in stripEnds to brace initialization.
Tests/UnitTests/Core/Vertexing/VertexingDataHelper.hpp Changed return statement in readTracksAndVertexCSV to brace initialization.
Tests/UnitTests/Plugins/Cuda/Seeding/SeedFinderCudaTest.cpp Simplified return statement in covariance calculation lambda to brace initialization.
Tests/UnitTests/Plugins/Cuda/Seeding2/main.cpp Updated return statement in covariance calculation lambda to brace initialization.
Tests/UnitTests/Plugins/Geant4/Geant4SurfaceProviderTests.cpp Changed return statement in ConstructGeant4World to brace initialization.

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • paulgessinger

"In code we trust, with syntax so bright,
Brace initialization brings clarity and light.
From pairs to tuples, we simplify the way,
Enhancing our functions, come what may!
With Yoda's wisdom, we code with delight,
In this galaxy of logic, our future is bright!" 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d1d2286 and 29d2979.

📒 Files selected for processing (2)
  • Core/include/Acts/Utilities/TrackHelpers.hpp (6 hunks)
  • Core/src/Vertexing/AdaptiveGridTrackDensity.cpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • Core/src/Vertexing/AdaptiveGridTrackDensity.cpp
  • Core/include/Acts/Utilities/TrackHelpers.hpp

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 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 - Fatras Affects the Fatras module Component - Examples Affects the Examples module Component - Plugins Affects one or more Plugins Event Data Model SP formation Vertexing Seeding Track Fitting labels Dec 2, 2024
Copy link

github-actions bot commented Dec 2, 2024

📊: Physics performance monitoring for 29d2979

Full contents

physmon summary

@AJPfleger AJPfleger marked this pull request as ready for review December 2, 2024 21:01
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: 0

🧹 Outside diff range and nitpick comments (1)
Examples/Framework/src/EventData/ScalingCalibrator.cpp (1)

55-57: Strong with the Force, this error handling is! Hmmmm.

Fail fast, your code now does. Wisdom in checking validity before proceeding, there is. Clear and early error messages, the path to maintainable code are.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 797c3c3 and d1d2286.

📒 Files selected for processing (40)
  • Core/include/Acts/EventData/MultiComponentTrackParameters.hpp (1 hunks)
  • Core/include/Acts/Seeding/BinnedGroupIterator.ipp (1 hunks)
  • Core/include/Acts/Seeding/SeedFinder.ipp (2 hunks)
  • Core/include/Acts/TrackFitting/detail/KalmanGlobalCovariance.hpp (1 hunks)
  • Core/include/Acts/Utilities/GridBinFinder.ipp (1 hunks)
  • Core/include/Acts/Utilities/TrackHelpers.hpp (6 hunks)
  • Core/src/Propagator/detail/CovarianceEngine.cpp (1 hunks)
  • Core/src/Propagator/detail/SympyCovarianceEngine.cpp (1 hunks)
  • Core/src/Surfaces/detail/AlignmentHelper.cpp (1 hunks)
  • Core/src/Surfaces/detail/AnnulusBoundsHelper.cpp (1 hunks)
  • Core/src/Utilities/SpacePointUtility.cpp (1 hunks)
  • Core/src/Vertexing/AdaptiveGridTrackDensity.cpp (1 hunks)
  • Core/src/Vertexing/ImpactPointEstimator.cpp (2 hunks)
  • Core/src/Vertexing/Vertex.cpp (1 hunks)
  • Examples/Detectors/ContextualDetector/src/AlignedDetector.cpp (1 hunks)
  • Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp (1 hunks)
  • Examples/Detectors/GenericDetector/src/GenericDetector.cpp (1 hunks)
  • Examples/Detectors/TGeoDetector/src/TGeoDetector.cpp (1 hunks)
  • Examples/Detectors/TelescopeDetector/src/TelescopeDetector.cpp (1 hunks)
  • Examples/Framework/src/EventData/ScalingCalibrator.cpp (1 hunks)
  • Examples/Framework/src/Utilities/Paths.cpp (1 hunks)
  • Examples/Io/Root/include/ActsExamples/Io/Root/RootMaterialDecorator.hpp (1 hunks)
  • Examples/Io/Root/src/RootNuclearInteractionParametersWriter.cpp (6 hunks)
  • Examples/Io/Root/src/RootTrackStatesWriter.cpp (1 hunks)
  • Examples/Io/Root/src/detail/NuclearInteractionParametrisation.cpp (5 hunks)
  • Examples/Scripts/compareRootFiles.hpp (1 hunks)
  • Fatras/include/ActsFatras/Physics/ElectroMagnetic/PhotonConversion.hpp (2 hunks)
  • Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp (3 hunks)
  • Fatras/src/Physics/NuclearInteraction/NuclearInteraction.cpp (1 hunks)
  • Plugins/DD4hep/src/DD4hepBlueprintFactory.cpp (2 hunks)
  • Plugins/Geant4/src/Geant4Converters.cpp (4 hunks)
  • Plugins/GeoModel/src/GeoModelBlueprintCreater.cpp (3 hunks)
  • Plugins/GeoModel/src/detail/GeoModelExtentHelper.cpp (2 hunks)
  • Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp (1 hunks)
  • Tests/UnitTests/Core/Geometry/SurfaceArrayCreatorTests.cpp (1 hunks)
  • Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp (1 hunks)
  • Tests/UnitTests/Core/Vertexing/VertexingDataHelper.hpp (1 hunks)
  • Tests/UnitTests/Plugins/Cuda/Seeding/SeedFinderCudaTest.cpp (1 hunks)
  • Tests/UnitTests/Plugins/Cuda/Seeding2/main.cpp (1 hunks)
  • Tests/UnitTests/Plugins/Geant4/Geant4SurfaceProviderTests.cpp (1 hunks)
✅ Files skipped from review due to trivial changes (22)
  • Tests/UnitTests/Plugins/Cuda/Seeding2/main.cpp
  • Core/include/Acts/TrackFitting/detail/KalmanGlobalCovariance.hpp
  • Tests/UnitTests/Core/Vertexing/VertexingDataHelper.hpp
  • Examples/Detectors/ContextualDetector/src/AlignedDetector.cpp
  • Core/src/Surfaces/detail/AlignmentHelper.cpp
  • Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp
  • Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp
  • Core/src/Surfaces/detail/AnnulusBoundsHelper.cpp
  • Examples/Detectors/TelescopeDetector/src/TelescopeDetector.cpp
  • Core/src/Vertexing/AdaptiveGridTrackDensity.cpp
  • Core/src/Utilities/SpacePointUtility.cpp
  • Tests/UnitTests/Plugins/Geant4/Geant4SurfaceProviderTests.cpp
  • Examples/Io/Root/include/ActsExamples/Io/Root/RootMaterialDecorator.hpp
  • Examples/Scripts/compareRootFiles.hpp
  • Tests/UnitTests/Plugins/Cuda/Seeding/SeedFinderCudaTest.cpp
  • Fatras/include/ActsFatras/Physics/ElectroMagnetic/PhotonConversion.hpp
  • Plugins/Geant4/src/Geant4Converters.cpp
  • Core/src/Vertexing/Vertex.cpp
  • Core/include/Acts/Seeding/SeedFinder.ipp
  • Plugins/DD4hep/src/DD4hepBlueprintFactory.cpp
  • Core/include/Acts/Seeding/BinnedGroupIterator.ipp
  • Fatras/src/Physics/NuclearInteraction/NuclearInteraction.cpp
👮 Files not reviewed due to content moderation or server errors (3)
  • Examples/Io/Root/src/RootNuclearInteractionParametersWriter.cpp
  • Core/src/Vertexing/ImpactPointEstimator.cpp
  • Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp
🔇 Additional comments (20)
Examples/Detectors/GenericDetector/src/GenericDetector.cpp (1)

30-30: Approve this change, I do!

Simplified the return statement has become, hmm. Cleaner and more modern the code now is, while maintaining the same functionality it does.

Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp (1)

45-45: Wisdom in simplicity, there is!

The Force strong with this change it is. Brace initialization, a more elegant weapon for a more civilized age, it has become.

Core/include/Acts/Utilities/GridBinFinder.ipp (1)

48-50: Approve these changes too, I must!

Two pairs of braces, like twin suns of Tatooine, they are. Simplified the code has become, while its power remains unchanged, hmm.

Examples/Framework/src/Utilities/Paths.cpp (1)

113-115: Approve these changes, I do! Hmmmm.

More elegant and modern, the brace initialization is. Simplified the return statements without changing their behavior, you have.

Plugins/GeoModel/src/detail/GeoModelExtentHelper.cpp (1)

160-160: Wise choice, this change is! Hmmmm.

Maintained the safety of the bounds checking, you have, while embracing the modern ways of the C++ force. Type safety preserved, it remains.

Examples/Framework/src/EventData/ScalingCalibrator.cpp (1)

63-70: Clean and modern, your return statement has become.

After validation, the GeometryIdentifier construction occurs. Safe and elegant, this approach is. Brace initialization, a path to cleaner code it is.

Core/src/Propagator/detail/SympyCovarianceEngine.cpp (1)

89-89: Approve this change, I do!

Simplified the return statement has become, hmm. Modern C++ practices this follows, while maintaining the same functionality it does. Efficient the move semantics remain, yes.

Core/src/Propagator/detail/CovarianceEngine.cpp (1)

100-100: Consistent with the Force, this change is!

Mirror the changes in SympyCovarianceEngine.cpp, this does. Harmony in the codebase, it brings. Move semantics preserved, they are.

Core/include/Acts/EventData/MultiComponentTrackParameters.hpp (1)

132-136: Clear as the waters of Dagobah, this code has become!

Multi-line formatting, wisdom it shows. Readable the code is, while type safety it maintains. With other changes in the codebase, harmony it creates, hmm.

Examples/Io/Root/src/detail/NuclearInteractionParametrisation.cpp (2)

90-90: Approve this change, I do!

Simplified the return statement is, yet maintains its functionality it does. More readable and modern, the code becomes.


125-125: Approve this change as well, I must!

Clear and concise, the return statement becomes. Modern C++ practices, it follows.

Examples/Detectors/TGeoDetector/src/TGeoDetector.cpp (1)

378-378: Wise this change is, approve it I do!

Moved properly, both elements are. Efficient and clear, the code becomes. Performance maintained, while readability improved is.

Plugins/GeoModel/src/GeoModelBlueprintCreater.cpp (4)

323-323: Approve this early return, I do!

Simple and clear, the empty return becomes. Proper handling of the null case, it maintains.


396-399: Approve this builder return, I must!

Well structured the return statement is. Layer structure builder and extent, properly initialized they are.


407-407: Approve this fallback return, I shall!

Consistent with other returns, this fallback case is. Proper null handling, it maintains.


437-437: Strong with the Force, this change is!

Clean and readable, the multi-value return becomes. Type safety and initialization, properly maintained they are.

Core/include/Acts/Utilities/TrackHelpers.hpp (2)

212-212: Approve the modernization of pair construction, I do!

Replaced std::make_pair with brace initialization, you have. Cleaner and more modern the code becomes. Consistent with modern C++ practices, this change is.

Also applies to: 232-232, 259-259, 265-265


533-533: Hmmmm, consistent in your changes, you are!

In the calculate*Residual functions, the same modernization pattern you follow. Approve of this consistency, I do. More readable the code becomes.

Also applies to: 569-569, 605-605

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

231-231: In the test code too, maintain consistency you do!

In makeBarrelStagger function, the same modernization pattern you apply. Harmony in the codebase, this brings. The Force is strong with this change.

Examples/Io/Root/src/RootTrackStatesWriter.cpp (1)

474-474: In the lambda function, follow the same path you do!

In getTrackParams lambda, embrace modern syntax you do. Consistent with other changes this is. Approve of this unified approach, I do.

Also applies to: 477-477, 480-480

Copy link

sonarcloud bot commented Dec 5, 2024

@kodiakhq kodiakhq bot merged commit 0d5586e into acts-project:main Dec 5, 2024
49 checks passed
@github-actions github-actions bot removed the automerge label Dec 5, 2024
@AJPfleger AJPfleger deleted the return branch December 5, 2024 22:56
@paulgessinger paulgessinger modified the milestones: next, v38.1.0 Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants