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: Add google-explicit-constructor to clang-tidy config #3972

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

paulgessinger
Copy link
Member

@paulgessinger paulgessinger commented Dec 10, 2024

Needs a few prerequisite changes:

--- 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

Summary by CodeRabbit

  • New Features
    • Added a new static analysis check: google-explicit-constructor to enhance code quality.
  • Chores
    • Updated configuration for clang-tidy checks to include the new rule.
    • Modified linting configuration to enforce explicit constructors.

Copy link

coderabbitai bot commented Dec 10, 2024

Walkthrough

Additions made to .clang-tidy configuration, yes. New check google-explicit-constructor included, it is. CMake configuration modified too, for clang-tidy checks, yes. Existing checks remain unchanged, the structure intact it is. Informative messages preserved, they are.

Changes

File Change Summary
.clang-tidy Added new check: google-explicit-constructor to enabled checks.
cmake/ActsStaticAnalysis.cmake Modified CMake configuration to include google-explicit-constructor in clang-tidy checks.
CI/clang_tidy/limits.yml Added rule: "google-explicit-constructor": 0 to control enforcement of explicit constructors.

Possibly related PRs

  • ci: Lint updates #3958: The addition of the google-explicit-constructor check in the main PR is directly related to the changes in the CMake configuration for clang-tidy checks in PR ci: Lint updates #3958, which also includes this check in its modifications.

Suggested labels

automerge

Suggested reviewers

  • AJPfleger

In the code, a check appears,
google-explicit-constructor, it cheers!
With clang-tidy now more bright,
Static analysis takes flight.
Master Yoda, proud, I say,
Enhancements made, hip-hip-hooray! 🌟


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. (Experiment)
  • @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 this to the next milestone Dec 10, 2024
@github-actions github-actions bot added the Infrastructure Changes to build tools, continous integration, ... label Dec 10, 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)
cmake/ActsStaticAnalysis.cmake (1)

18-18: Words of wisdom, share I must!

Help developers understand the way of explicit constructors, we should. Consider these actions, you must:

  • Document in coding guidelines, the requirement for explicit constructors
  • Share examples of proper usage, wisdom brings
  • Prepare the team for CI feedback, patience they will need

Strong in the ways of static analysis, this project becomes!

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between bd88be8 and fbdac63.

📒 Files selected for processing (2)
  • .clang-tidy (1 hunks)
  • cmake/ActsStaticAnalysis.cmake (1 hunks)
🔇 Additional comments (2)
.clang-tidy (1)

7-7: Hmmmm, good this addition is!

Properly placed among the Google checks, the explicit constructor check is. Prevent accidental implicit conversions, it will. A wise decision, this is!

Run this script to check impact on codebase, we must:

✅ Verification successful

The Force guides us to a more specific search, it does! Regular expressions, we shall use, as AST parsing proved challenging, hmm.


Hmm, constructors in the codebase, I have found!

Many C++ files with constructors, there are. But explicit constructors already in use throughout the codebase, I see. A good practice this is, preventing accidental conversions it does. The addition of google-explicit-constructor check, wise it is!

Examples of existing explicit constructors in the codebase, I found:

  • In Acts/Utilities/Logger.hpp
  • In Acts/Material/Material.hpp
  • In Acts/EventData/SourceLink.hpp
  • In many other core components

The Force is strong with this change. Maintain consistency with existing codebase practices, it will.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for potential implicit constructors that might be affected

# Look for single-parameter constructors that might need explicit keyword
ast-grep --pattern 'class $_ {
  $$$
  $_($_) {
    $$$
  }
  $$$
}'

Length of output: 70


Script:

#!/bin/bash
# Search for potential constructors in C++ files
fd -e cpp -e h -e hpp --exec rg -l "^\s*[A-Za-z_][A-Za-z0-9_]*\s*\([^)]+\)\s*(?::\s*\w+\s*\([^)]*\)\s*)*\s*\{" {}

# Also search for explicit keyword usage to understand current practices
fd -e cpp -e h -e hpp --exec rg -l "explicit\s+[A-Za-z_][A-Za-z0-9_]*\s*\([^)]+\)" {}

Length of output: 65397

cmake/ActsStaticAnalysis.cmake (1)

18-18: In harmony with .clang-tidy, this change is!

Consistent with the force of .clang-tidy configuration, this addition remains. Properly appended to the list of checks, it is. Balance to the static analysis, it brings!

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)
cmake/ActsStaticAnalysis.cmake (1)

Line range hint 1-50: Additional wisdom to share, I have!

Consider documenting the purpose of clang-tidy checks in comments, we should. Help future Padawans understand our ways, it will.

Add this comment before the check configuration:

 if(ACTS_RUN_CLANG_TIDY)
+    # Configure clang-tidy checks
+    # - google-explicit-constructor: Warns on implicit conversions through constructors
+    # Add similar documentation for other checks
     find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between bd88be8 and fbdac63.

📒 Files selected for processing (2)
  • .clang-tidy (1 hunks)
  • cmake/ActsStaticAnalysis.cmake (1 hunks)
🔇 Additional comments (2)
.clang-tidy (1)

7-7: Approve this change, I do! Wisdom in explicit constructors, there is.

Correctly placed and formatted, the new check is. Prevent accidental implicit conversions, it will. Documentation for this check, we shall verify.

✅ Verification successful

The previous search only showed configuration files. Let's search for actual code patterns and documentation to better understand the impact of this check.


Approve this change with confidence, I do! Strong with the Force, it is!

Evidence in the codebase, we have found! Many explicit constructors already in use, there are. A established pattern in the project, this is. The google-explicit-constructor check, enforce these good practices throughout the codebase, it will.

Examples of wisdom in the codebase, we see:

  • In Acts/Material/HomogeneousVolumeMaterial.hpp, explicit constructors already used, they are
  • In Acts/Plugins/Detray/DetrayConversionUtils.hpp, explicit constructor pattern followed, it is
  • In Acts/Geometry/Volume.hpp, explicit constructors documented and implemented, they are

Prevent accidental implicit conversions and make code intentions clearer, this check will. Aligned with existing codebase practices, it is!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the documentation and implementation of google-explicit-constructor check

# Search for documentation or implementation details of the check
rg -A 5 "google-explicit-constructor" 

Length of output: 844


Script:

#!/bin/bash
# Search for any files that might be affected by the google-explicit-constructor check
# Look for implicit constructors that might be flagged
ast-grep --pattern 'class $_ {
  $_($$$) {
    $$$
  }
}'

# Also search for any test files or examples related to this check
rg -i "implicit.*constructor|explicit.*constructor" -A 3

Length of output: 4961

cmake/ActsStaticAnalysis.cmake (1)

18-18: Consistent with .clang-tidy, this change is. Approve it, I do!

In harmony with the Force, both configuration files now are. The same check in both places, we see.

✅ Verification successful

Perfect alignment between files, I sense. Approve this change with confidence, we must!

Examined the Force flows between .clang-tidy and cmake/ActsStaticAnalysis.cmake, I have. In perfect harmony, they are:

  • The same checks in both files, present they are
  • In identical order, they flow
  • The google-explicit-constructor check, properly placed it is

Strong with the Force, this change is. No disturbance in the configuration files, I detect.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistency between .clang-tidy and CMake configuration

# Compare the checks in both files
echo "Checking consistency between configurations..."
rg -A 20 "Checks: " .clang-tidy
rg -A 20 "list\(APPEND _chks" cmake/ActsStaticAnalysis.cmake

Length of output: 2920

@paulgessinger paulgessinger added the 🛑 blocked This item is blocked by another item label Dec 10, 2024
Copy link

github-actions bot commented Dec 10, 2024

📊: Physics performance monitoring for dcf02c0

Full contents

physmon summary

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)
CI/clang_tidy/limits.yml (1)

Line range hint 1-24: Document the meaning of zero, we should.

Hmmmm... Future maintainers benefit from clarity, they will. Add comment explaining that zero means "no limit on violations", we should.

Add this comment at the top of the file, you should:

+# Limits configuration for clang-tidy checks
+# A value of 0 means no limit on the number of violations reported
+
 limits:
   "clang-analyzer-optin.cplusplus.UninitializedObject": 0
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fbdac63 and dcf02c0.

📒 Files selected for processing (1)
  • CI/clang_tidy/limits.yml (1 hunks)
🔇 Additional comments (1)
CI/clang_tidy/limits.yml (1)

7-7: Approve this change, I do. But verify the full implementation, we must.

Correctly placed and configured, the new check is. But ensure that enabled in .clang-tidy file, it also is.

Run this verification script, we shall:

✅ Verification successful

Verified the implementation is, young padawan.

Found in both places, the check is:

  • In .clang-tidy, enabled as part of checks list, it is
  • In cmake/ActsStaticAnalysis.cmake, properly configured, it appears

Complete and correct, this implementation is. Working together in harmony, all components are.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the complete implementation of google-explicit-constructor

# Check if the check is enabled in .clang-tidy
echo "Search for google-explicit-constructor in .clang-tidy, we must:"
rg "google-explicit-constructor" .clang-tidy

# Check if CMake configuration includes this check
echo "Search for google-explicit-constructor in CMake files, we shall:"
rg "google-explicit-constructor" cmake/

Length of output: 481

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Changes to build tools, continous integration, ... 🛑 blocked This item is blocked by another item
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant