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

Enforce attributes to be on the same line only if they don't have arguments #5618

Open
2 tasks done
Reyshawn opened this issue Jun 5, 2024 · 1 comment
Open
2 tasks done
Labels
discussion Topics that cannot be categorized as bugs or enhancements yet. They require further discussions. enhancement Ideas for improvements of existing features and rules.

Comments

@Reyshawn
Copy link

Reyshawn commented Jun 5, 2024

New Issue Checklist

Describe the bug

When I set the @objc attribute always at the same line and set the option attributes_with_arguments_always_on_line_above to true.

It triggers a warning when I put the @objc(addEpisodesObject:), which has arguments on its own line;

// MARK: Generated accessors for episodes
extension Season {
    @objc(addEpisodesObject:)
    @NSManaged public func addToEpisodes(_ value: Episode)
}
opt_in_rules:
  - attributes
attributes:
  attributes_with_arguments_always_on_line_above: true
  always_on_same_line:
    - "@IBSegueAction"
    - "@IBAction"
    - "@NSManaged"
    - "@objc"
    - "@nonobjc"

How could I enforce attributes to be on their own line if they have arguments, and on the same line if they don't have arguments?

Environment

  • SwiftLint version (run swiftlint version to be sure)?
    0.55.1
  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
    Homebrew
  • Paste your configuration file:
# insert yaml contents here
  • Are you using nested configurations?
    If so, paste their relative paths and respective contents.
  • Which Xcode version are you using (check xcodebuild -version)?
    Xcode 15.4
    Build version 15F31d
  • Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
    to quickly test if your example is really demonstrating the issue. If your example is more
    complex, you can use swiftlint lint --path [file here] --no-cache --enable-all-rules.
@SimplyDanny
Copy link
Collaborator

I wouldn't consider this as a bug. The implementation is just giving always_on_same_line precedence over attributes_with_arguments_always_on_line_above which might be exactly the behavior others want. So I'm not sure whether and, if so, how to change it.

@SimplyDanny SimplyDanny added enhancement Ideas for improvements of existing features and rules. discussion Topics that cannot be categorized as bugs or enhancements yet. They require further discussions. labels Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Topics that cannot be categorized as bugs or enhancements yet. They require further discussions. enhancement Ideas for improvements of existing features and rules.
Projects
None yet
Development

No branches or pull requests

2 participants