Skip to content

fix(linting): Select CMake files for linting using an include rather than exclude list; Finish incomplete changes from previous PRs.#11

Merged
kirkrodrigues merged 3 commits into
y-scope:mainfrom
kirkrodrigues:fix-typo
Oct 27, 2024

Conversation

@kirkrodrigues

@kirkrodrigues kirkrodrigues commented Oct 27, 2024

Copy link
Copy Markdown
Member

Description

#10 demonstrates that there are usually more CMake files to exclude (e.g., those in submodules) than include in a repo, so it's better to select the CMake files to lint using an include list.

This PR also finishes some incomplete changes from previous PRs:

Validation performed

  • Workflow succeeded.
  • Added a lint violation in CMakeLists.txt and validated task lint:check detected it.
  • Created a temporary CMakeLists.txt with a lint violation in src/ and validated task lint:check detected it.
  • Changed taskfile.yaml and validated task lint:check detected the change and recreated the lint venv.

Summary by CodeRabbit

  • Documentation

    • Updated the README.md with instructions for handling CMake files in relation to linting.
  • Chores

    • Removed the .yamllint.yaml configuration file, eliminating custom linting rules.
    • Refined task definitions in lint-tasks.yaml, including updates to the cmake and yml tasks for consistency and clarity.

@coderabbitai

coderabbitai Bot commented Oct 27, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The changes in this pull request involve the removal of the .yamllint.yaml configuration file, which previously defined custom linting rules for YAML files. Additionally, the README.md file has been updated to include specific instructions for handling CMake files in relation to the linting process. The lint-tasks.yaml file has undergone several modifications, including updates to task definitions for CMake and C++ linting, as well as adjustments to file references and command structures.

Changes

File Change Summary
.yamllint.yaml Removed; contained custom YAML linting configurations and ignore patterns.
README.md Added instructions for including CMake files in the gersemi command within the "Adding files" section.
lint-tasks.yaml Updated task definitions for cmake-check, cmake-fix, and cpp-static-check; modified yml task reference; simplified cmake task command.

Possibly related PRs


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 161070d and 951403f.

📒 Files selected for processing (3)
  • .yamllint.yaml (0 hunks)
  • README.md (1 hunks)
  • lint-tasks.yaml (2 hunks)
💤 Files with no reviewable changes (1)
  • .yamllint.yaml
🔇 Additional comments (2)
lint-tasks.yaml (2)

85-85: LGTM: Proper update to taskfile reference

The change correctly updates the reference from Taskfile.yml to taskfile.yaml, aligning with the standardization mentioned in PR #6.


140-140: 🛠️ Refactor suggestion

Verify coverage of CMake files

The change implements an include-list approach by explicitly specifying CMakeLists.txt and src/ for linting. While this aligns with the PR objectives, please verify:

  1. Are there any CMake files outside these paths that should be included?
  2. Should we add a comment explaining the include-list strategy for future maintainers?

Let's verify the CMake file coverage:

Consider adding a comment to explain the include-list strategy:

  cmake:
    internal: true
    requires:
      vars: ["FLAGS"]
    cmd: |-
      . "{{.G_LINT_VENV_DIR}}/bin/activate"
+     # Using explicit include list to avoid linting submodule CMake files
      gersemi {{.FLAGS}} CMakeLists.txt src/
✅ Verification successful

Current CMake file coverage is complete

The verification shows that only CMakeLists.txt in the root directory exists, with no additional CMake files in src/ or other subdirectories. The current include-list approach (CMakeLists.txt src/) provides complete coverage.

Consider adding the suggested documentation comment to explain the include-list strategy for future maintainers:

  cmake:
    internal: true
    requires:
      vars: ["FLAGS"]
    cmd: |-
      . "{{.G_LINT_VENV_DIR}}/bin/activate"
+     # Using explicit include list to avoid linting submodule CMake files
      gersemi {{.FLAGS}} CMakeLists.txt src/
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any CMake files that might be missed by the current include list

# Find all CMake files in the repository (excluding .git and build directories)
echo "All CMake files in repository:"
fd -e cmake -e txt -g 'CMakeLists.txt' --exclude '.git' --exclude 'build'

# Compare with files that would be linted
echo -e "\nFiles that would be linted by current configuration:"
fd -e cmake -e txt -g 'CMakeLists.txt' . 'CMakeLists.txt' 'src'

Length of output: 414


Script:

#!/bin/bash
# Let's try a different approach to find all CMake files
echo "All CMake files in repository (using ripgrep):"
rg --files --glob 'CMakeLists.txt' --glob '*.cmake'

echo -e "\nChecking for any CMake files in subdirectories:"
find . -name 'CMakeLists.txt' -o -name '*.cmake' | grep -v "^\./\.git"

echo -e "\nChecking contents of src directory for CMake files:"
find ./src -name 'CMakeLists.txt' -o -name '*.cmake' 2>/dev/null

Length of output: 540

Comment thread README.md
Comment on lines +22 to +24
* **CMake**. If adding a CMake file, add it (or its parent directory) as an argument to the
`gersemi` command in [lint-tasks.yaml](lint-tasks.yaml).
* If adding a directory, the file must be named `CMakeLists.txt` or use the `.cmake` extension.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance clarity and consistency of CMake linting instructions

The current instructions could be clearer about the include-list approach. Consider these improvements:

-* **CMake**. If adding a CMake file, add it (or its parent directory) as an argument to the
-  `gersemi` command in [lint-tasks.yaml](lint-tasks.yaml).
-  * If adding a directory, the file must be named `CMakeLists.txt` or use the `.cmake` extension.
+* **CMake**. The project uses an include-list approach for CMake linting. When adding a new CMake file:
+  * Add the file path or its parent directory as an argument to the `gersemi` command in `lint-tasks.yaml`
+  * Files must be named either `CMakeLists.txt` or use the `.cmake` extension

The suggested changes:

  • Explicitly mention the include-list approach
  • Use consistent file referencing (remove square brackets)
  • Improve readability with better bullet point structure
  • Make the requirements more prominent
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* **CMake**. If adding a CMake file, add it (or its parent directory) as an argument to the
`gersemi` command in [lint-tasks.yaml](lint-tasks.yaml).
* If adding a directory, the file must be named `CMakeLists.txt` or use the `.cmake` extension.
* **CMake**. The project uses an include-list approach for CMake linting. When adding a new CMake file:
* Add the file path or its parent directory as an argument to the `gersemi` command in `lint-tasks.yaml`
* Files must be named either `CMakeLists.txt` or use the `.cmake` extension

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.

1 participant