Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 57 additions & 14 deletions .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,65 @@
--header "\nCopyright © {year} Stream.io Inc. All rights reserved.\n"
--swiftversion 6.0

--ifdef no-indent
--disable redundantType
--disable extensionAccessControl
--disable andOperator
--disable hoistPatternLet
--disable typeSugar
--disable opaqueGenericParameters
--disable genericExtensions
--disable preferForLoop
--disable redundantGet # it removes get async throws from getters
--rules blankLinesAroundMark
--rules blankLinesAtEndOfScope
--rules blankLinesAtStartOfScope
--rules blankLinesBetweenScopes
--rules braces
--rules consecutiveBlankLines
--rules consecutiveSpaces
--rules duplicateImports
--rules elseOnSameLine
--rules emptyBraces
--rules enumNamespaces
--rules fileHeader
--rules indent
--rules initCoderUnavailable
--rules isEmpty
--rules leadingDelimiters
--rules linebreakAtEndOfFile
--rules linebreaks
--rules modifierOrder
--rules numberFormatting
--rules redundantBackticks
--rules redundantBreak
--rules redundantExtensionACL
--rules redundantFileprivate
--rules redundantLet
--rules redundantLetError
--rules redundantNilInit
--rules redundantObjc
--rules redundantPattern
--rules redundantRawValues
--rules redundantVoidReturnType
--rules semicolons
--rules sortedImports
--rules spaceAroundBraces
--rules spaceAroundBrackets
--rules spaceAroundComments
--rules spaceAroundGenerics
--rules spaceAroundOperators
--rules spaceAroundParens
--rules spaceInsideBraces
--rules spaceInsideBrackets
--rules spaceInsideComments
--rules spaceInsideGenerics
--rules spaceInsideParens
--rules strongOutlets
--rules strongifiedSelf
--rules todos
--rules trailingCommas
--rules trailingSpace
--rules unusedArguments
--rules void
--rules wrap
--rules wrapArguments
--rules wrapAttributes
--rules yodaConditions

# Rules inferred from Swift Standard Library:
--disable anyObjectProtocol, wrapMultilineStatementBraces
# Configuration for enabled rules
--ifdef no-indent
--indent 4
--enable isEmpty
--disable redundantParens # it generates mistakes for e.g. "if (a || b), let x = ... {}"
--semicolons inline
--nospaceoperators ..., ..< # what about ==, +=?
--commas inline
Expand Down
10 changes: 8 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ excluded:
- vendor/bundle

only_rules:
# Currently enabled autocorrectable rules
- attribute_name_spacing
- closing_brace
- colon
Expand All @@ -26,14 +25,15 @@ only_rules:
- empty_enum_arguments
- empty_parameters
- empty_parentheses_with_trailing_closure
- explicit_init
- file_name_no_space
- joined_default_parameter
- leading_whitespace
- legacy_cggeometry_functions
- legacy_constant
- legacy_constructor
- legacy_nsgeometry_functions
- mark
- multiline_arguments
- no_space_in_method_call
- prefer_type_checking
- private_over_fileprivate
Expand All @@ -59,9 +59,15 @@ only_rules:
- vertical_whitespace
- void_return

multiline_arguments:
only_enforce_after_first_closure_on_first_line: true

trailing_whitespace:
ignores_empty_lines: true

file_name_no_space:
severity: error

custom_rules:
coredata_date_forbidden:
included: "Sources/StreamFeeds/Database/DTOs"
Expand Down
43 changes: 24 additions & 19 deletions DemoApp/FeedsView/FeedsListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,29 +149,34 @@ struct FeedsListView: View {
}
.disabled(updatedActivityText.trimmed.isEmpty)
}
.alert("Delete Activity", isPresented: .init(
get: { activityToDelete != nil },
set: { if !$0 { activityToDelete = nil } }
), actions: {
Button("Cancel", role: .cancel) {
activityToDelete = nil
}
Button("Delete", role: .destructive) {
if let activity = activityToDelete {
Task {
do {
_ = try await feed.deleteActivity(id: activity.id)
activityToDelete = nil
} catch {
log.error("Error deleting an activity \(error)")
bannerError = error
.alert(
"Delete Activity",
isPresented: .init(
get: { activityToDelete != nil },
set: { if !$0 { activityToDelete = nil } }
),
actions: {
Button("Cancel", role: .cancel) {
activityToDelete = nil
}
Button("Delete", role: .destructive) {
if let activity = activityToDelete {
Task {
do {
_ = try await feed.deleteActivity(id: activity.id)
activityToDelete = nil
} catch {
log.error("Error deleting an activity \(error)")
bannerError = error
}
}
}
}
},
message: {
Text("Are you sure you want to delete this activity?")
}
}, message: {
Text("Are you sure you want to delete this activity?")
})
)
}

func refresh() async {
Expand Down
2 changes: 1 addition & 1 deletion Githubfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export SONAR_VERSION='6.2.1.4610'
export IPSW_VERSION='3.1.592'
export INTERFACE_ANALYZER_VERSION='1.0.7'
export SWIFT_LINT_VERSION='0.59.1'
export SWIFT_FORMAT_VERSION='0.56.4'
export SWIFT_FORMAT_VERSION='0.58.2'
export SWIFT_GEN_VERSION='6.5.1'
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ struct CommentReactionList_Tests {
await client.eventsMiddleware.sendEvent(
CommentReactionUpdatedEvent.dummy(
comment: .dummy(id: Self.commentId, objectId: "activity-123"),
fid: "user:test", reaction: .dummy(commentId: Self.commentId, custom: ["key": .string("UPDATED")], type: "like", user: .dummy(id: "current-user-id"))
fid: "user:test",
reaction: .dummy(commentId: Self.commentId, custom: ["key": .string("UPDATED")], type: "like", user: .dummy(id: "current-user-id"))
)
)

Expand All @@ -113,7 +114,8 @@ struct CommentReactionList_Tests {
await client.eventsMiddleware.sendEvent(
CommentReactionDeletedEvent.dummy(
comment: .dummy(id: Self.commentId, objectId: "activity-123"),
fid: "user:test", reaction: .dummy(commentId: Self.commentId, type: "like", user: .dummy(id: "current-user-id"))
fid: "user:test",
reaction: .dummy(commentId: Self.commentId, type: "like", user: .dummy(id: "current-user-id"))
)
)

Expand All @@ -132,7 +134,8 @@ struct CommentReactionList_Tests {
await client.eventsMiddleware.sendEvent(
CommentReactionDeletedEvent.dummy(
comment: .dummy(id: "comment-456", objectId: "activity-123"),
fid: "user:test", reaction: .dummy(commentId: "comment-456", type: "like", user: .dummy(id: "current-user-id"))
fid: "user:test",
reaction: .dummy(commentId: "comment-456", type: "like", user: .dummy(id: "current-user-id"))
)
)

Expand All @@ -151,7 +154,8 @@ struct CommentReactionList_Tests {
await client.eventsMiddleware.sendEvent(
CommentReactionAddedEvent.dummy(
comment: .dummy(id: "comment-456", objectId: "activity-123"),
fid: "user:test", reaction: .dummy(commentId: "comment-456", type: "heart", user: .dummy(id: "other-user"))
fid: "user:test",
reaction: .dummy(commentId: "comment-456", type: "heart", user: .dummy(id: "other-user"))
)
)

Expand All @@ -172,7 +176,8 @@ struct CommentReactionList_Tests {
await client.eventsMiddleware.sendEvent(
CommentReactionUpdatedEvent.dummy(
comment: .dummy(id: "comment-456", objectId: "activity-123"),
fid: "user:test", reaction: .dummy(commentId: "comment-456", type: "heart", user: .dummy(id: "current-user-id"))
fid: "user:test",
reaction: .dummy(commentId: "comment-456", type: "heart", user: .dummy(id: "current-user-id"))
)
)

Expand Down