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

Replace C++ linting configs with those managed by yscope-dev-utils; Forcibly enable CMAKE_EXPORT_COMPILE_COMMANDS. #15

Merged
merged 3 commits into from
Oct 4, 2024

Conversation

kirkrodrigues
Copy link
Member

@kirkrodrigues kirkrodrigues commented Oct 3, 2024

Description

We recently added the C++ linting configs we use across our repos to yscope-dev-utils, as well as a process for using them while allowing repo-specific overrides. Thus, this PR updates to use them and the process. To set them up, this PR adds the task lint:cpp-configs.

This PR also forcibly enables CMAKE_EXPORT_COMPILE_COMMANDS. Previously, we had written the code such that CMAKE_EXPORT_COMPILE_COMMANDS would only be set if it wasn't already set, but for some CMake versions (e.g., 3.16.3), it defaults to OFF rather than being unset. Forcibly enabling it should have no known downsides

Validation performed

  • task lint:cpp-configs generated symlinks to the C++ linting configs.
    • Running it again succeeded idempotently.
  • task lint:cpp-check succeeded.
  • Added extra spaces in a C++ file and then:
    • task lint:cpp-check detected the error.
    • task lint:cpp-fix fixed the error.
  • Ran clang-tidy manually based on the command in Add initial implementation with support for decoding CLP IR streams. #1 and found no violations.

Summary by CodeRabbit

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a new task for C++ linting configurations in the project setup.
  • Improvements

    • Updated the README to clarify setup instructions, including Emscripten installation and C++ linting configuration.
    • Simplified the .clang-format configuration for a more standardized formatting approach.
  • Bug Fixes

    • Corrected indentation issues in the lint-tasks.yml file.
  • Chores

    • Updated the commit reference for the yscope-dev-utils subproject.
    • Added rules to the .gitignore file to ignore specific lint configuration files.

Copy link

coderabbitai bot commented Oct 3, 2024

Walkthrough

The pull request introduces several modifications across multiple files. Key changes include updates to the .gitignore file to ignore lint configuration files, adjustments to the CMakeLists.txt to simplify compile command settings, enhancements to the README.md for clearer setup instructions, and the addition of a new linting task in lint-tasks.yml. Additionally, the .clang-format file has been significantly revised to adopt a base style, while the .clang-tidy file has been removed. Lastly, a subproject commit reference has been updated.

Changes

File Path Change Summary
.gitignore Added entries: .clang-format, .clang-tidy.
CMakeLists.txt Removed conditional checks for compile commands and response files; set CMAKE_EXPORT_COMPILE_COMMANDS to ON unconditionally.
README.md Updated setup instructions to explicitly include Emscripten installation command and added guidance for C++ linting configuration.
lint-tasks.yml Added new task cpp-configs to execute a shell script for C++ linting configurations; corrected indentation in aliases.
src/clp_ffi_js/.clang-format Updated to use BasedOnStyle: "InheritParentConfig"; removed multiple specific formatting options.
src/clp_ffi_js/.clang-tidy File deleted; previously contained configuration for Clang-Tidy checks and naming conventions.
tools/yscope-dev-utils Updated subproject commit reference from 92cd10da59a6c2fa5c5182ff7ca0c3d7862a7113 to 159768c7d171595ed2cba17b758c10043a2efe96.

Possibly related PRs

Suggested reviewers

  • junhaoliao

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 43c734b and c6614c2.

📒 Files selected for processing (1)
  • CMakeLists.txt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • CMakeLists.txt

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.

@kirkrodrigues kirkrodrigues changed the title Update to the latest C++ linting configs and process from yscope-dev-utils; Forcibly enable CMAKE_EXPORT_COMPILE_COMMANDs. Update to the latest C++ linting configs and process from yscope-dev-utils; Forcibly enable CMAKE_EXPORT_COMPILE_COMMANDS. Oct 3, 2024
@junhaoliao junhaoliao self-requested a review October 3, 2024 13:33
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 (4)
README.md (2)

37-40: Good addition of Emscripten installation step.

The inclusion of the Emscripten installation command is beneficial. However, it would be helpful to briefly explain what Emscripten is and why it's necessary for the project. This context would assist new contributors in understanding the project's requirements better.

Consider adding a brief explanation, such as:

# Emscripten is required for compiling C++ to WebAssembly
Download and install [emscripten]:

42-46: Great addition of C++ linting setup step.

This new step for setting up C++ linting tool configs directly addresses the PR objectives and provides clear instructions for contributors. It's well-explained and easy to follow.

For consistency with the Emscripten step, consider adding a brief explanation of why this step is necessary. For example:

# Set up the config files for our C++ linting tools to ensure code quality and consistency
Set up the config files for our C++ linting tools:
CMakeLists.txt (2)

29-38: LGTM! Consider adding a comment explaining the clang-tidy limitation.

The changes to forcibly enable CMAKE_EXPORT_COMPILE_COMMANDS and disable response files for clang-tidy are well-implemented and align with the PR objectives. These modifications will ensure consistent behaviour across different CMake versions and improve compatibility with clang-tidy.

Consider adding a brief comment explaining why response files are disabled for clang-tidy. This would help future maintainers understand the reasoning behind this configuration. For example:

# Disable response files since clang-tidy doesn't support them
# This ensures that include directories are passed directly to clang-tidy
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES OFF)

Incomplete C++ Linting Configuration Updates

  • Found .clang-format in ./src/clp_ffi_js/, but other linting configuration files (clang-tidy, cpplint) are missing.
  • The lint:cpp-configs task is not present in package.json.

Please ensure all C++ linting configurations and tasks are properly added to meet the PR objectives.

🔗 Analysis chain

Line range hint 1-38: Verify the C++ linting configuration updates.

The changes to enable compile commands and disable response files for clang-tidy are implemented correctly. However, the PR objectives mention updating C++ linting configurations, which are not directly visible in this CMakeLists.txt file.

To ensure all aspects of the PR objectives are met, please run the following script to verify the C++ linting configuration updates:

This script will help verify that the C++ linting configuration updates mentioned in the PR objectives have been implemented correctly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify C++ linting configuration updates

# Check for the existence of C++ linting configuration files
echo "Checking for C++ linting configuration files:"
fd -e yml -e yaml -e json . | grep -E '(clang-tidy|clang-format|cpplint)'

# Check for the new lint:cpp-configs task
echo "Checking for the new lint:cpp-configs task:"
grep -n "lint:cpp-configs" package.json

# Verify symlinks to C++ linting configurations
echo "Verifying symlinks to C++ linting configurations:"
find . -type l -name "*clang-tidy*" -o -name "*clang-format*" -o -name "*cpplint*"

Length of output: 538

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 475dd1f and 43c734b.

📒 Files selected for processing (7)
  • .gitignore (1 hunks)
  • CMakeLists.txt (1 hunks)
  • README.md (1 hunks)
  • lint-tasks.yml (1 hunks)
  • src/clp_ffi_js/.clang-format (1 hunks)
  • src/clp_ffi_js/.clang-tidy (0 hunks)
  • tools/yscope-dev-utils (1 hunks)
💤 Files with no reviewable changes (1)
  • src/clp_ffi_js/.clang-tidy
✅ Files skipped from review due to trivial changes (3)
  • .gitignore
  • src/clp_ffi_js/.clang-format
  • tools/yscope-dev-utils
🔇 Additional comments (5)
lint-tasks.yml (3)

15-16: LGTM: New task for C++ linting configurations added successfully.

The new cpp-configs task has been correctly added to the lint-tasks.yml file. It executes a shell script that creates symlinks for C++ lint configurations, which aligns with the PR objectives. The use of the {{.ROOT_DIR}} variable ensures portability across different environments.


Line range hint 18-23: Indentation correction improves YAML structure.

The indentation of the aliases section under the yml task has been corrected. This improvement ensures that the yml-check and yml-fix aliases are properly associated with the yml task. The fix enhances the readability and maintainability of the configuration file while preventing potential parsing issues.


Line range hint 1-55: Summary: Changes align well with PR objectives.

The modifications to lint-tasks.yml successfully implement the required updates for C++ linting configurations and improve the overall structure of the file. The addition of the cpp-configs task and the correction of indentation in the yml task contribute to better maintainability and functionality of the linting process.

These changes align perfectly with the PR objectives of incorporating the latest C++ linting configurations and processes from the yscope-dev-utils repository. The new task will facilitate the generation of symlinks to the C++ linting configurations, as intended.

README.md (2)

35-36: Excellent addition to the setup instructions.

This new instruction provides clarity for developers, ensuring they complete all necessary setup steps before opening the project in an IDE. It's a good practice to have these steps clearly outlined.


35-46: Overall, excellent improvements to the README.

The changes made to the README file significantly enhance the setup instructions for the project. The addition of explicit steps for installing Emscripten and setting up C++ linting configs aligns well with the PR objectives and provides clearer guidance for contributors. These improvements will likely reduce setup issues and ensure more consistent code quality across contributions.

While the changes are already very good, the minor suggestions provided for adding brief explanations could further improve the document's clarity. Great work on enhancing the project's documentation!

Copy link
Collaborator

@junhaoliao junhaoliao left a comment

Choose a reason for hiding this comment

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

Verified on a Mac ARM computer and observed the realpath issue no long exists after git checking out the yscope-dev-utils version in this PR.

For the PR title to be used as the final commit message, how about:

Replace C++ linting configs with those managed by yscope-dev-utils; Forcibly enable `CMAKE_EXPORT_COMPILE_COMMANDS`.

@kirkrodrigues kirkrodrigues changed the title Update to the latest C++ linting configs and process from yscope-dev-utils; Forcibly enable CMAKE_EXPORT_COMPILE_COMMANDS. Replace C++ linting configs with those managed by yscope-dev-utils; Forcibly enable CMAKE_EXPORT_COMPILE_COMMANDS. Oct 4, 2024
@kirkrodrigues kirkrodrigues merged commit be24868 into y-scope:main Oct 4, 2024
3 checks passed
@kirkrodrigues kirkrodrigues deleted the update-ydu branch October 4, 2024 09:15
@kirkrodrigues kirkrodrigues restored the update-ydu branch November 6, 2024 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants