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: Sonar fixes after detector refactor #3968

Merged

Conversation

paulgessinger
Copy link
Member

@paulgessinger paulgessinger commented Dec 7, 2024

Blocked by:

Summary by CodeRabbit

  • New Features

    • Enhanced safety in the DD4hepDetector class by using const references in loop iterations.
    • Updated sorting mechanism for several vectors to utilize modern C++ practices.
  • Bug Fixes

    • Adjusted data types in the Config struct of the AlignedDetector class for better performance and accuracy.
    • Removed obsolete member variable from the Config struct in the AlignedDetector class.

@github-actions github-actions bot added Component - Core Affects the Core module Infrastructure Changes to build tools, continous integration, ... Component - Examples Affects the Examples module Component - Documentation Affects the documentation labels Dec 7, 2024
@paulgessinger paulgessinger changed the title Chore/sonar post detector refactor chore: Sonar fixes after detector refactor Dec 7, 2024
Copy link

github-actions bot commented Dec 7, 2024

📊: Physics performance monitoring for cbf8f78

Full contents

physmon summary

@paulgessinger paulgessinger force-pushed the chore/sonar-post-detector-refactor branch from ed3e144 to cbf8f78 Compare December 9, 2024 08:12
@github-actions github-actions bot removed Component - Core Affects the Core module Infrastructure Changes to build tools, continous integration, ... Component - Documentation Affects the documentation labels Dec 9, 2024
@paulgessinger paulgessinger removed the 🛑 blocked This item is blocked by another item label Dec 9, 2024
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/Detectors/DD4hepDetector/src/DD4hepDetector.cpp (1)

121-136: Duplicate sorting logic, I see. Refactor this, we should.

Similar lambda functions, four times repeated they are. A template function or common comparator, better it would be.

+ auto compareDetElements = [](const dd4hep::DetElement& a, 
+                            const dd4hep::DetElement& b) {
+   return (a.id() < b.id());
+ };

- std::ranges::sort(
-     muon, [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) {
-       return (a.id() < b.id());
-     });
+ std::ranges::sort(muon, compareDetElements);

- std::ranges::sort(
-     eCal, [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) {
-       return (a.id() < b.id());
-     });
+ std::ranges::sort(eCal, compareDetElements);

// Apply similar changes to hCal and tracker sorting
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 341d2b0 and cbf8f78.

📒 Files selected for processing (3)
  • Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp (1 hunks)
  • Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignedDetector.hpp (1 hunks)
  • Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp (3 hunks)
🔇 Additional comments (3)
Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignedDetector.hpp (1)

25-29: Careful with platform compatibility, you must be.

Changed from std::size_t to unsigned int, these configuration parameters have. On 64-bit systems where large values you need, limitations this may bring. Consider these implications, you should:

  • On 64-bit systems, std::size_t is typically 64 bits
  • unsigned int usually 32 bits remains, regardless of platform
Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp (1)

89-90: Wisdom in const-correctness, I sense.

The Force is strong with this change. Using const auto& prevents accidental modifications and improves clarity, it does.

Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp (1)

211-211: Changed from final to override, the execute method has. Implications, this brings.

Removed the final specifier, more flexibility it provides. But careful consideration needed:

  • Derived classes may now override this method
  • Ensure documentation reflects this design change
  • Verify all derived classes maintain the contract

Copy link
Contributor

@andiwand andiwand left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link

sonarqubecloud bot commented Dec 9, 2024

@kodiakhq kodiakhq bot merged commit 47db0b9 into acts-project:main Dec 9, 2024
46 checks passed
@github-actions github-actions bot removed the automerge label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Examples Affects the Examples module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants