Skip to content

Comments

[CI] Update swiftformat config#3753

Merged
testableapple merged 2 commits intodevelopfrom
ci/update-swiftformat-config
Jul 31, 2025
Merged

[CI] Update swiftformat config#3753
testableapple merged 2 commits intodevelopfrom
ci/update-swiftformat-config

Conversation

@testableapple
Copy link
Contributor

@testableapple testableapple commented Jul 28, 2025

Summary by CodeRabbit

  • Chores
    • Updated formatting and linting configurations to improve exclusion handling for specific directories and files.
    • Removed an obsolete formatting configuration file.
    • Added a new pre-push hook for stricter code linting.
    • Adjusted skip conditions for automated hooks.

@testableapple testableapple added the 🤖 CI/CD Any work related to CI/CD label Jul 28, 2025
@testableapple testableapple requested a review from a team as a code owner July 28, 2025 17:17
@coderabbitai
Copy link

coderabbitai bot commented Jul 28, 2025

Walkthrough

This change updates SwiftFormat and SwiftLint exclusion handling by moving exclusion rules from inline command arguments into configuration files for both lefthook and SwiftFormat. It also removes a redundant SwiftFormat snippets file, adjusts Fastlane configuration for formatting, and introduces a pre-push hook for SwiftLint in lefthook.yml.

Changes

Cohort / File(s) Change Summary
SwiftFormat Exclusion Configuration
.swiftformat
Added --exclude option specifying directories and paths to ignore during formatting.
SwiftFormat Snippets Removal
.swiftformat-snippets
Deleted file containing custom SwiftFormat rules and preferences.
Fastlane Formatting Path Update
fastlane/Fastfile
Updated formatting lane to use a consolidated source path list and removed inline exclusions from the SwiftFormat command.
Lefthook Hook & Exclusion Reorganization
lefthook.yml
Moved exclusion patterns to dedicated YAML lists, added a pre-push SwiftLint hook, reorganized job structure, and updated skip conditions.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Lefthook as Lefthook
    participant SwiftFormat as SwiftFormat
    participant SwiftLint as SwiftLint

    Dev->>Lefthook: git commit / push
    Lefthook->>SwiftFormat: Run with exclusion list from config
    Lefthook->>SwiftLint: Run with exclusion list from config
    Lefthook->>Lefthook: On push, run pre-push SwiftLint with exclusions
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

🤖 CI/CD

Suggested reviewers

  • nuno-vieira
  • laevandus

Poem

In the warren where code bunnies dwell,
Exclusions now tidy, all is well.
Hooks leap in order, pre-push on the run,
Formatting and linting—neatly done!
No more snippets scattered, just clean, swift delight—
This rabbit’s code garden is looking just right! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ci/update-swiftformat-config

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 generate unit tests to generate unit tests 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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0eb718b and 1189cbc.

📒 Files selected for processing (4)
  • .swiftformat (1 hunks)
  • .swiftformat-snippets (0 hunks)
  • fastlane/Fastfile (2 hunks)
  • lefthook.yml (1 hunks)
💤 Files with no reviewable changes (1)
  • .swiftformat-snippets
🧰 Additional context used
🧠 Learnings (1)
fastlane/Fastfile (1)

Learnt from: testableapple
PR: #3740
File: fastlane/Fastfile:849-886
Timestamp: 2025-07-23T16:14:40.281Z
Learning: The team prefers simpler error handling in fastlane scripts and relies on fastlane's default error reporting mechanisms rather than adding explicit begin-rescue blocks around shell commands.

🔇 Additional comments (5)
fastlane/Fastfile (2)

798-799: LGTM! Cleaner exclusion handling.

The simplification of the SwiftFormat command by removing the --exclude option and iterating over a unified sources_matrix[:swiftformat] key is a good improvement. This centralizes exclusion management in the .swiftformat configuration file.


835-835: Good refactoring to unify source paths.

The consolidation of separate include/exclude keys into a single swiftformat key simplifies the configuration and aligns with the new centralized exclusion approach.

lefthook.yml (3)

4-11: LGTM! Improved exclusion handling for SwiftFormat.

Moving exclusions from inline --exclude arguments to the YAML exclude list is cleaner and more maintainable. The lefthook configuration syntax is correct.


16-23: Good consistency in SwiftLint exclusion handling.

The exclusion patterns are consistent with the SwiftFormat configuration above, maintaining the same approach across both tools.


28-38: Excellent addition of pre-push SwiftLint strict mode.

The new pre-push hook running SwiftLint in strict mode is a great way to catch issues before code is pushed. The configuration properly uses {push_files} and includes appropriate skip conditions.

Comment on lines +37 to +38
# Exclude paths
--exclude **/Generated,Sources/StreamChatUI/StreamNuke,Sources/StreamChatUI/StreamSwiftyGif,Sources/StreamChatUI/StreamDifferenceKit
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify path consistency across configuration files.

The exclusion paths look well-structured, but there's a discrepancy between the StreamChatUI paths here and the StreamChatSwiftUI paths in lefthook.yml. Ensure these paths match the actual directory structure.


🏁 Script executed:

#!/bin/bash
# Verify the actual directory structure to confirm correct paths
echo "Checking for StreamChatUI directories:"
fd -t d StreamChatUI Sources/
echo "Checking for StreamChatSwiftUI directories:"
fd -t d StreamChatSwiftUI Sources/
echo "Checking for the specific excluded subdirectories:"
fd -t d -e / StreamNuke StreamSwiftyGif StreamDifferenceKit Sources/

Length of output: 584


🏁 Script executed:

#!/bin/bash
# List immediate subdirectories under Sources/StreamChatUI to confirm exclusions
echo "Subdirectories in Sources/StreamChatUI:"
ls -d Sources/StreamChatUI/*/ || echo "No subdirectories found or path does not exist."

# Search all YAML configs for any references to StreamChatSwiftUI vs StreamChatUI
echo -e "\nReferences to 'StreamChatSwiftUI' in .yml files:"
grep -R -n "StreamChatSwiftUI" --include="*.yml" . || echo "No references to StreamChatSwiftUI found."

echo -e "\nReferences to 'StreamChatUI' in .yml files:"
grep -R -n "StreamChatUI" --include="*.yml" . || echo "No references to StreamChatUI found."

Length of output: 3469


Ensure consistent exclusion paths across all configs

The .swiftformat exclusions correctly reference Sources/StreamChatUI (where the directories actually live). However, lefthook.yml still points to the non-existent Sources/StreamChatSwiftUI/... path. Update those entries to use Sources/StreamChatUI so all tooling excludes the same directories.

• Fix in lefthook.yml: replace

Sources/StreamChatSwiftUI/StreamNuke/**
Sources/StreamChatSwiftUI/StreamSwiftyGif/**
Sources/StreamChatSwiftUI/StreamDifferenceKit/**

with

Sources/StreamChatUI/StreamNuke/**
Sources/StreamChatUI/StreamSwiftyGif/**
Sources/StreamChatUI/StreamDifferenceKit/**

Affected blocks at lines 9–11, 21–23, and 34–36 in lefthook.yml.

🤖 Prompt for AI Agents
In lefthook.yml at lines 9–11, 21–23, and 34–36, update the exclusion paths from
Sources/StreamChatSwiftUI/... to Sources/StreamChatUI/... to match the correct
directory names used in the .swiftformat file. Replace all instances of
Sources/StreamChatSwiftUI/StreamNuke/**,
Sources/StreamChatSwiftUI/StreamSwiftyGif/**, and
Sources/StreamChatSwiftUI/StreamDifferenceKit/** with
Sources/StreamChatUI/StreamNuke/**, Sources/StreamChatUI/StreamSwiftyGif/**, and
Sources/StreamChatUI/StreamDifferenceKit/** respectively to ensure consistent
exclusion paths across all configs.

Comment on lines +9 to +11
- Sources/StreamChatSwiftUI/StreamNuke/**
- Sources/StreamChatSwiftUI/StreamSwiftyGif/**
- Sources/StreamChatSwiftUI/StreamDifferenceKit/**
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: Path inconsistency with .swiftformat configuration.

The exclusion paths use StreamChatSwiftUI here, but the .swiftformat file uses StreamChatUI. This inconsistency could result in different files being excluded by different tools, leading to formatting/linting inconsistencies.

The paths should be consistent across all configuration files. Verify which path is correct and update accordingly:

#!/bin/bash
# Verify the correct directory structure
echo "Checking actual directory structure:"
find Sources/ -type d -name "StreamNuke" -o -name "StreamSwiftyGif" -o -name "StreamDifferenceKit" 2>/dev/null

Also applies to: 21-23, 34-36

🤖 Prompt for AI Agents
In lefthook.yml around lines 9 to 11 (and also lines 21-23, 34-36), the
exclusion paths use "StreamChatSwiftUI" which is inconsistent with the
".swiftformat" file that uses "StreamChatUI". To fix this, verify the correct
directory name by checking the actual folder structure under Sources/ using a
command like 'find Sources/ -type d -name "StreamNuke" -o -name
"StreamSwiftyGif" -o -name "StreamDifferenceKit"'. Then update all exclusion
paths in lefthook.yml to match the correct directory name consistently across
all configuration files.

- rebase

- run: mint run swiftlint lint --config .swiftlint.yml --strict --progress --quiet --reporter json {staged_files}
pre-push:
Copy link
Contributor

Choose a reason for hiding this comment

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

So the summary is that if I commit, then we autocorrect and include autocorrected files with the commit. If I push, then we just lint again for making sure no linting related issues end up in develop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeap

@testableapple testableapple merged commit 54b6ce5 into develop Jul 31, 2025
5 of 6 checks passed
@testableapple testableapple deleted the ci/update-swiftformat-config branch July 31, 2025 13:19
@coderabbitai coderabbitai bot mentioned this pull request Oct 7, 2025
6 tasks
@coderabbitai coderabbitai bot mentioned this pull request Dec 15, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 CI/CD Any work related to CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants