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

CI: bump clang-format to 20 #1157

Merged
merged 1 commit into from
Mar 8, 2025
Merged

CI: bump clang-format to 20 #1157

merged 1 commit into from
Mar 8, 2025

Conversation

ken-matsui
Copy link
Member

@ken-matsui ken-matsui commented Mar 8, 2025

Summary by CodeRabbit

  • Chores

    • Updated internal build and testing workflows to use the latest formatting tools.
  • Style

    • Standardized code formatting and layout across various command and interface components for improved maintainability.

Note: These internal improvements are cosmetic only and do not change any visible functionality for end-users.

Copy link

coderabbitai bot commented Mar 8, 2025

Walkthrough

This pull request updates the GitHub Actions workflow to install Clang tools version 20 instead of version 19 and applies widespread code reformatting changes across the codebase. The changes include modifications to indentation, line breaks, and multi-line splits in method signatures and calls. All adjustments are cosmetic; they enhance readability without affecting the underlying logic, control flow, or functionality of the application.

Changes

File(s) Change Summary
.github/workflows/cpp.yml Updated Clang installation: switched from version 19 to 20, including changes to the LLVM script command, apt-get install command for clang-format, and the CABIN_FMT var.
src/Cmd/... (Add.cc, Build.cc, Clean.cc, Fmt.cc, Lint.cc, Remove.cc, Run.cc, Search.cc) Reformatted command definitions: adjusted multi-line formatting for option and argument declarations to improve readability without affecting functionality.
src/Cli.{cc,hpp} Modified formatting of method signatures and calls: split parameters and function calls onto multiple lines for enhanced clarity.
src/{Algos.hpp, Builder/Project.cc, Cabin.cc, Command.cc, Manifest.cc, Parallelism.cc, Rustify/Tests.hpp, TermColor.hpp} General code reformatting: applied line breaks, indentation adjustments, and parenthesis/braced initializers changes to improve structure with no alterations to logic.

Poem

I'm a bunny, swift and neat,
Hopping through the lines of code so sweet.
With line breaks and format in full bloom,
I cheer the changes that now zoom.
Here's to clarity in each reformatted beat!
🐇💻

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
  • @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.

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

🧹 Nitpick comments (2)
src/Cabin.cc (1)

85-94: Pass-by-value Usage in colorizeAnyhowError

Although static analysis hints suggest that a function parameter might be passed by const reference, the current implementation of colorizeAnyhowError deliberately accepts its string parameter by value to allow for move semantics during modification. This is an acceptable and common pattern; however, please keep an eye on performance if this function is called with very large strings.

🧰 Tools
🪛 Cppcheck (2.10-2)

[performance] 94-94: Function parameter 'other' should be passed by const reference.

(passedByValue)

src/Manifest.cc (1)

30-48: Optional Improvement: Parameter Passing in tryFromString.
The function Edition::tryFromString(std::string str) currently takes its parameter by value. Although this allows for move semantics later, static analysis suggests that taking the parameter as a const std::string& might be more efficient when the argument does not need to be mutated. Since this PR focuses solely on formatting, you may consider this change in a separate refactoring if performance becomes a concern.

🧰 Tools
🪛 Cppcheck (2.10-2)

[performance] 43-43: Function parameter 'macros' should be passed by const reference.

(passedByValue)


[performance] 43-43: Function parameter 'includeDirs' should be passed by const reference.

(passedByValue)


[performance] 44-44: Function parameter 'others' should be passed by const reference.

(passedByValue)


[performance] 38-38: Function parameter 'other' should be passed by const reference.

(passedByValue)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8f2a1b and 3f5012c.

📒 Files selected for processing (19)
  • .github/workflows/cpp.yml (1 hunks)
  • src/Algos.hpp (1 hunks)
  • src/Builder/Project.cc (1 hunks)
  • src/Cabin.cc (1 hunks)
  • src/Cli.cc (4 hunks)
  • src/Cli.hpp (2 hunks)
  • src/Cmd/Add.cc (1 hunks)
  • src/Cmd/Build.cc (1 hunks)
  • src/Cmd/Clean.cc (1 hunks)
  • src/Cmd/Fmt.cc (1 hunks)
  • src/Cmd/Lint.cc (1 hunks)
  • src/Cmd/Remove.cc (1 hunks)
  • src/Cmd/Run.cc (1 hunks)
  • src/Cmd/Search.cc (1 hunks)
  • src/Command.cc (2 hunks)
  • src/Manifest.cc (3 hunks)
  • src/Parallelism.cc (1 hunks)
  • src/Rustify/Tests.hpp (3 hunks)
  • src/TermColor.hpp (1 hunks)
🧰 Additional context used
🪛 Cppcheck (2.10-2)
src/Cabin.cc

[performance] 25-25: Function parameter 'str' should be passed by const reference.

(passedByValue)


[performance] 38-38: Function parameter 'other' should be passed by const reference.

(passedByValue)

src/Manifest.cc

[performance] 58-58: Function parameter 'str' should be passed by const reference.

(passedByValue)

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: build & test (Clang 16)
  • GitHub Check: build & test (GCC 13)
  • GitHub Check: build & test (Clang 18)
  • GitHub Check: build & test (Apple Clang - macOS 13)
  • GitHub Check: build & test (GCC 12)
  • GitHub Check: build & test (GCC 14)
  • GitHub Check: build & test (Clang 17)
  • GitHub Check: build & test (Clang 19)
  • GitHub Check: analyze (c-cpp)
  • GitHub Check: create
🔇 Additional comments (28)
src/Parallelism.cc (1)

53-57: Cosmetic Reformat in Constructor Initializer List
The initializer list in the ParallelismState constructor has been reformatted into multiple lines for enhanced readability. There is no change in logic or functionality.

src/TermColor.hpp (1)

31-34: Improved requires Clause Formatting
The requires clause for the templated ColorStr constructor has been split into multiple lines to improve readability without affecting its behavior.

.github/workflows/cpp.yml (2)

140-141: Upgrade to Clang Tools Version 20
The commands have been updated to install Clang tools version 20 (using sudo ./llvm.sh 20 and installing clang-format-20), aligning with the PR objective.


146-146: Updated Environment Variable for Clang-Format
The environment variable CABIN_FMT now references clang-format-20, ensuring consistency with the new installation commands.

src/Rustify/Tests.hpp (3)

155-159: Refined Formatting in assertEq Error Message
The formatting string in the assertEq function has been reformatted into a multi-line structure to enhance clarity. This change is purely cosmetic and does not alter the assertion logic.


194-198: Clearer Formatting in assertNe Error Message
The error message in the assertNe function now uses a multi-line format, making the output easier to read while retaining its original semantics.


232-237: Enhanced Readability in assertLt Error Message
The multi-line formatting of the error message in assertLt improves readability without impacting functionality.

src/Cmd/Remove.cc (1)

23-28: Reformatted Argument Declaration for REMOVE_CMD
The argument for the "deps" parameter has been spread across multiple lines for improved clarity. This formatting refinement does not change the underlying logic.

src/Builder/Project.cc (1)

104-106: Improved Compiler Flag Formatting

The new multi-line layout for appending the optimization flag (using fmt::format("-O{}", profile.optLevel)) improves the readability of the code. No functionality has been altered.

src/Cmd/Fmt.cc (1)

29-33: CLI Option Formatting Enhancement: --exclude

Reformatting the definition of the --exclude option into a multi-line structure enhances clarity without changing its behavior.

src/Cmd/Build.cc (1)

32-36: CLI Command Option Reformatting for --compdb

Splitting the --compdb option declaration into multiple lines improves readability and is consistent with the new formatting style applied throughout the project. This cosmetic change does not impact functionality.

src/Cmd/Search.cc (1)

23-34: Improved Readability for Search Command Options

Expanding the option definitions for --per-page and --page across multiple lines clearly separates their properties (description, placeholder, and default value), thereby enhancing code understandability while preserving their intended behavior.

src/Cabin.cc (1)

23-67: Enhanced CLI Option Definitions in getCli()

The restructured command-line option definitions in the getCli() function significantly improve clarity and maintainability. Splitting each option into its own multi-line block makes it easier to read and update in the future, with no changes to functionality.

🧰 Tools
🪛 Cppcheck (2.10-2)

[performance] 25-25: Function parameter 'str' should be passed by const reference.

(passedByValue)


[performance] 38-38: Function parameter 'other' should be passed by const reference.

(passedByValue)

src/Cmd/Add.cc (1)

25-49: Enhanced Formatting for Command Options.
The chained method calls (for example in the .setArg() and various .addOpt() invocations) have been reformatted into a multi‐line layout. This change improves readability without affecting functionality.

src/Cmd/Run.cc (1)

27-38: Reformatted RUN_CMD Initialization.
The multi-line formatting for the RUN_CMD constant (including the .setShort(), .setDesc(), and .addOpt() calls) enhances the alignment and readability of the command configuration while preserving the underlying logic.

src/Manifest.cc (3)

55-62: Improved Package Parsing Readability.
Breaking down the retrieval of the package’s edition and version values into multi-line calls clarifies the chain of operations. No functionality is altered.

🧰 Tools
🪛 Cppcheck (2.10-2)

[performance] 58-58: Function parameter 'str' should be passed by const reference.

(passedByValue)


168-172: Clearer Dev Profile Option Level Extraction.
The refactoring of the devOptLevel assignment into a multi-line format makes the code easier to follow while maintaining the original behavior.


203-208: Consistent Formatting for Release Profile Options.
Similar multi-line formatting applied to the extraction of relOptLevel contributes to a uniform style across profile parsing. All changes are cosmetic.

src/Cmd/Lint.cc (1)

22-29: Enhanced Formatting for the --exclude Option.
Reformatting the definition of the --exclude option into multiple lines improves its clarity without any changes to its functionality.

src/Algos.hpp (1)

59-65: Reformatted Levenshtein Distance Calculation.
The updated indentation and line breaks in the call to std::min (used for computing deletion, insertion, and substitution costs) enhance readability while keeping the algorithm’s logic intact.

src/Cmd/Clean.cc (1)

19-24: Cosmetic Formatting: Enhanced Option Configuration Readability

The multi-line formatting of the .addOpt() call—including the detailed breakdown of the option configuration for --profile—improves the overall readability without affecting functionality.

src/Cli.hpp (2)

199-200: Cosmetic Formatting: Improved Function Declaration Layout

The reformatting of the declaration for missingOptArgumentFor now spans multiple lines. This improves clarity and consistency with other declarations without changing its behavior.


256-257: Cosmetic Formatting: Clearer Declaration for expandOpts

Splitting the declaration of expandOpts over two lines enhances readability. No functionality is affected by this change.

src/Command.cc (2)

174-178: Cosmetic Formatting: Clearer Return Statement in waitWithOutput()

The modified multi-line formatting for the return statement within Child::waitWithOutput clarifies the structure of the returned CommandOutput object. This is a cosmetic change that does not affect execution.


271-274: Cosmetic Formatting: Improved Readability in spawn() Method

Reformatting the return statement in the parent branch of Command::spawn()—by splitting the creation of the Child object onto multiple lines—enhances clarity without impacting functionality.

src/Cli.cc (3)

111-113: Cosmetic Formatting: Refined Signature Layout for Opt::format

The updated multi-line splitting of the parameters in the Opt::format signature makes the method easier to read and maintain while preserving its functionality.


660-662: Cosmetic Formatting: Improved Declaration of formatAllSubcmds

Breaking the parameter list for Cli::formatAllSubcmds across multiple lines enhances readability without altering the method’s logic or behavior.


709-713: Cosmetic Formatting: Clarified Help Message Construction

The revised chaining of method calls on the temporary Subcmd{ "..." } object—especially the multi-line layout for setting the description—improves the clarity of the help command suggestion. This change is purely cosmetic.

@ken-matsui ken-matsui merged commit 5003289 into main Mar 8, 2025
20 checks passed
@ken-matsui ken-matsui deleted the format-20 branch March 8, 2025 07:09
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