Skip to content

Comments

feat!: Only pass line-length to format if a value is provided#330

Merged
wolfenrain merged 5 commits intoVeryGoodOpenSource:mainfrom
erick-forks:main
May 26, 2025
Merged

feat!: Only pass line-length to format if a value is provided#330
wolfenrain merged 5 commits intoVeryGoodOpenSource:mainfrom
erick-forks:main

Conversation

@erickzanardo
Copy link
Member

@erickzanardo erickzanardo commented May 23, 2025

Migration Details

Since Dart 3.7 the line length can be configured in the analysis_options, hence format_line_length has now been made optional and has no explicit workflow default.

When using a Dart version lower than 3.7, to keep using the default line length value of 80 on the format checking step, be sure to explicitly pass it on the format_line_length attribute, for example:

name: My Flutter Workflow

on: pull_request

jobs:
  build:
    uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_package.yml@v2
    with:
      format_line_length: 80

Status

READY

Description

Only pass a value for the line_length flag in the dart format command if the user explicitly passed a value to it.

Fixes #329

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@erickzanardo erickzanardo requested a review from a team as a code owner May 23, 2025 20:06
@coderabbitai
Copy link

coderabbitai bot commented May 23, 2025

Walkthrough

The changes remove the default value for the format_line_length input parameter from both Dart and Flutter package workflows and their documentation. The workflows now only append the --line-length flag to the dart format command if the input is explicitly provided, making the parameter optional and respecting package-level configuration.

Changes

Files/Paths Change Summary
.github/workflows/dart_package.yml, .github/workflows/flutter_package.yml Removed default "80" from format_line_length input; dart format now conditionally adds --line-length only if input is set.
site/docs/workflows/dart_package.md, site/docs/workflows/flutter_package.md Updated documentation to remove explicit default value for format_line_length input.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Workflow
    participant DartFormatter

    User->>Workflow: Trigger workflow (optionally sets format_line_length)
    Workflow->>Workflow: Check if format_line_length is provided
    alt format_line_length is provided
        Workflow->>DartFormatter: Run dart format with --line-length=<value>
    else format_line_length is not provided
        Workflow->>DartFormatter: Run dart format without --line-length
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Only add line-length flag to the format command when user provides a value (#329)
Remove default for format_line_length in workflow and documentation (#329)

Poem

A hop and a skip, the line length is free,
No more defaults—just let it be!
If you wish, set the length, but if not,
The formatter listens, respects what you’ve got.
In workflows and docs, the change is now clear—
CodeRabbit’s delight, let your configs steer!
🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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 (3)
.github/workflows/dart_package.yml (2)

26-28: Enforce numeric input for line length
Since format_line_length represents an integer, changing its type to number will validate user input at the workflow boundary and catch non-numeric values early.

Apply this diff:

-      format_line_length:
-        required: false
-        type: string
+      format_line_length:
+        required: false
+        type: number

102-102: Tighten conditional flag inclusion
The current expression includes --line-length when format_line_length is truthy, but may still pass unintended values. For more precise control, explicitly check for a non-empty string and update the step:

-        run: dart format ${{inputs.format_line_length && format('--line-length {0}', inputs.format_line_length) || ''}} --set-exit-if-changed ${{inputs.format_directories}}
+        run: dart format ${{ inputs.format_line_length != '' && format('--line-length {0}', inputs.format_line_length) || '' }} --set-exit-if-changed ${{ inputs.format_directories }}
.github/workflows/flutter_package.yml (1)

30-32: Use a numeric type for line length
Aligning with the Dart workflow, enforce format_line_length as a number to ensure only valid integers are provided:

-      format_line_length:
-        required: false
-        type: string
+      format_line_length:
+        required: false
+        type: number
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7131cfc and 76c925a.

📒 Files selected for processing (4)
  • .github/workflows/dart_package.yml (1 hunks)
  • .github/workflows/flutter_package.yml (1 hunks)
  • site/docs/workflows/dart_package.md (0 hunks)
  • site/docs/workflows/flutter_package.md (0 hunks)
💤 Files with no reviewable changes (2)
  • site/docs/workflows/flutter_package.md
  • site/docs/workflows/dart_package.md
🔇 Additional comments (1)
.github/workflows/flutter_package.yml (1)

103-103: Verify formatting command in both cases
The conditional flag logic is correct. Please test the workflow with and without format_line_length to confirm no malformed command (e.g., extra spaces) occurs at runtime.

@erickzanardo erickzanardo changed the title feat: Only pass line-length to format if a value is provided feat!: Only pass line-length to format if a value is provided May 26, 2025
@wolfenrain wolfenrain merged commit 3f83846 into VeryGoodOpenSource:main May 26, 2025
10 checks passed
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.

feat: Use package formatter configuration for line length

3 participants