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

Update wrapAttributes "complex attributes" logic to exclude attributes with a single unnamed argument #1595

Merged

Conversation

calda
Copy link
Collaborator

@calda calda commented Dec 12, 2023

This PR updates the wrapAttributes "complex attributes" logic to exclude attributes with a single unnamed argument.

This removes the need to special-case the @Environment attribute, which we specifically don't want to consider "complex". Since this doesn't require special casing any particular attribute, it generalizes to other similar attributes like @AppStorage from SwiftUI and @Dependency from TCA.

These are no longer considered complex, so can be configured to not wrap using --storedvarattrs same-line:

@Environment(\.controlPanelStyle) private var controlPanelStyle
@Dependency(\.controlsService) private var controlsService
@AppStorage("ControlsConfig") private var controlsConfig: ControlConfiguration

These examples are all still considered complex, so can be configured to always wrap using --complexattrs prev-line:

@AppStorage("ControlsConfig", store: myCustomUserDefaults)
private var controlsConfig: ControlConfiguration

@Tweak(name: "Aspect ratio")
private var aspectRatio = AspectRatio.stretch

@available(*, unavailable)
var saturn5Builder: Saturn5Builder

@available(*, unavailable, message: "No longer in production")
var saturn5Builder: Saturn5Builder

Copy link

codecov bot commented Dec 12, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a73bd38) 95.07% compared to head (1da8235) 95.07%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1595      +/-   ##
===========================================
- Coverage    95.07%   95.07%   -0.01%     
===========================================
  Files           20       20              
  Lines        22084    22112      +28     
===========================================
+ Hits         20996    21022      +26     
- Misses        1088     1090       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -746,7 +746,7 @@ public struct FormatOptions: CustomStringConvertible {
storedVarAttributes: AttributeMode = .preserve,
computedVarAttributes: AttributeMode = .preserve,
complexAttributes: AttributeMode = .preserve,
complexAttributesExceptions: Set<String> = ["@Environment"],
complexAttributesExceptions: Set<String> = [],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We no longer have a use case for this option, so we could remove it if we want. It seems like somebody could find this useful though, so it may be worth keeping.

@@ -746,7 +746,7 @@ public struct FormatOptions: CustomStringConvertible {
storedVarAttributes: AttributeMode = .preserve,
computedVarAttributes: AttributeMode = .preserve,
complexAttributes: AttributeMode = .preserve,
complexAttributesExceptions: Set<String> = ["@Environment"],
Copy link

Choose a reason for hiding this comment

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

👍

@nicklockwood nicklockwood merged commit 4a072af into nicklockwood:develop Dec 13, 2023
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.

3 participants