Skip to content

Commit 67b5792

Browse files
authored
Enable SwiftLint rule: collection_alignment (#25562)
The rule requires all elements in a collection literal to be vertically aligned with the first element. `collection_alignment` is not auto-correctable, so the 46 violations across 9 files were aligned by hand. The change is whitespace-only — no behaviour changes. Part of the Orchard SwiftLint rules rollout campaign.
1 parent 881de38 commit 67b5792

10 files changed

Lines changed: 58 additions & 55 deletions

File tree

.swiftlint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ only_rules:
1313
# Prefer `Array(xs)` over `xs.map { $0 }`.
1414
- array_init
1515

16+
# All elements in a collection literal should be vertically aligned.
17+
- collection_alignment
18+
1619
# Colons should be next to the identifier when specifying a type.
1720
- colon
1821

Sources/WordPressData/Swift/CoreDataHelper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public extension CoreDataStack {
289289

290290
do {
291291
let options = [NSMigratePersistentStoresAutomaticallyOption: true,
292-
NSInferMappingModelAutomaticallyOption: true]
292+
NSInferMappingModelAutomaticallyOption: true]
293293
try storeCoordinator.addPersistentStore(ofType: NSSQLiteStoreType,
294294
configurationName: nil,
295295
at: currentDatabaseLocation,

Tests/WordPressKitTests/WordPressKitTests/Tests/MediaServiceRemoteRESTTests.swift

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -267,18 +267,18 @@ class MediaServiceRemoteRESTTests: RemoteTestCase, RESTTestable {
267267
let width = 432
268268

269269
let jsonDictionary: [String: Any] = ["ID": id,
270-
"URL": url,
271-
"guid": guid,
272-
"date": date,
273-
"post_ID": postID,
274-
"mime_type": mimeType,
275-
"file": file,
276-
"title": title,
277-
"caption": caption,
278-
"description": description,
279-
"alt": alt,
280-
"height": height,
281-
"width": width]
270+
"URL": url,
271+
"guid": guid,
272+
"date": date,
273+
"post_ID": postID,
274+
"mime_type": mimeType,
275+
"file": file,
276+
"title": title,
277+
"caption": caption,
278+
"description": description,
279+
"alt": alt,
280+
"height": height,
281+
"width": width]
282282

283283
let remoteMedia = MediaServiceRemoteREST.remoteMedia(fromJSONDictionary: jsonDictionary)
284284
XCTAssertEqual(remoteMedia?.mediaID?.intValue, id)
@@ -327,18 +327,18 @@ class MediaServiceRemoteRESTTests: RemoteTestCase, RESTTestable {
327327
"width": width]
328328

329329
let jsonDictionary2: [String: Any] = ["ID": id2,
330-
"URL": url,
331-
"guid": guid,
332-
"date": date,
333-
"post_ID": postID,
334-
"mime_type": mimeType,
335-
"file": file,
336-
"title": title,
337-
"caption": caption,
338-
"description": description,
339-
"alt": alt,
340-
"height": height,
341-
"width": width]
330+
"URL": url,
331+
"guid": guid,
332+
"date": date,
333+
"post_ID": postID,
334+
"mime_type": mimeType,
335+
"file": file,
336+
"title": title,
337+
"caption": caption,
338+
"description": description,
339+
"alt": alt,
340+
"height": height,
341+
"width": width]
342342
let jsonArray = [jsonDictionary1, jsonDictionary2]
343343

344344
let remoteMediaArray: [RemoteMedia] = MediaServiceRemoteREST.remoteMedia(fromJSONArray: jsonArray) as! [RemoteMedia]

WordPress/Classes/ViewRelated/Blog/Site Management/DeleteSiteViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ open class DeleteSiteViewController: UITableViewController {
127127
paragraphStyle.alignment = .natural
128128

129129
let attributes: [NSAttributedString.Key: Any] = [.font: WPStyleGuide.fontForTextStyle(.body, fontWeight: .regular),
130-
.foregroundColor: UIAppColor.neutral(.shade70),
131-
.paragraphStyle: paragraphStyle ]
130+
.foregroundColor: UIAppColor.neutral(.shade70),
131+
.paragraphStyle: paragraphStyle ]
132132
let htmlAttributes: StyledHTMLAttributes = [.BodyAttribute: attributes]
133133

134134
let attributedText1 = NSAttributedString.attributedStringWithHTML(paragraph1, attributes: htmlAttributes)
@@ -142,7 +142,7 @@ open class DeleteSiteViewController: UITableViewController {
142142
sectionThreeBody.textColor = UIAppColor.neutral(.shade70)
143143

144144
let contactButtonAttributes: [NSAttributedString.Key: Any] = [.foregroundColor: UIAppColor.primary,
145-
.underlineStyle: NSUnderlineStyle.single.rawValue]
145+
.underlineStyle: NSUnderlineStyle.single.rawValue]
146146
supportButton.setAttributedTitle(NSAttributedString(string: NSLocalizedString("Contact Support",
147147
comment: "Button label for contacting support"),
148148
attributes: contactButtonAttributes),

WordPress/Classes/ViewRelated/Gutenberg/Layout Picker/GutenbergLightNavigationController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class GutenbergLightNavigationController: UINavigationController {
2222
let barButtonItemAppearance = UIBarButtonItem.appearance(whenContainedInInstancesOf: [GutenbergLightNavigationController.self])
2323
barButtonItemAppearance.tintColor = tintColor
2424
barButtonItemAppearance.setTitleTextAttributes([NSAttributedString.Key.font: WPFontManager.systemRegularFont(ofSize: 17.0),
25-
NSAttributedString.Key.foregroundColor: tintColor],
26-
for: .normal)
25+
NSAttributedString.Key.foregroundColor: tintColor],
26+
for: .normal)
2727
barButtonItemAppearance.setTitleTextAttributes([NSAttributedString.Key.font: WPFontManager.systemRegularFont(ofSize: 17.0),
28-
NSAttributedString.Key.foregroundColor: tintColor.withAlphaComponent(0.25)],
29-
for: .disabled)
28+
NSAttributedString.Key.foregroundColor: tintColor.withAlphaComponent(0.25)],
29+
for: .disabled)
3030

3131
setNeedsStatusBarAppearanceUpdate()
3232
}

WordPress/Classes/ViewRelated/Me/App Settings/AppSettingsViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ class AppSettingsViewController: UITableViewController {
212212
let title = NSLocalizedString("appSettings.media.imageQuality.title", value: "Quality", comment: "The quality of image used when uploading")
213213

214214
let settingsSelectionConfiguration = [SettingsSelectionDefaultValueKey: currentImageQuality,
215-
SettingsSelectionTitleKey: title,
216-
SettingsSelectionTitlesKey: titles,
217-
SettingsSelectionValuesKey: values] as [String: Any]
215+
SettingsSelectionTitleKey: title,
216+
SettingsSelectionTitlesKey: titles,
217+
SettingsSelectionValuesKey: values] as [String: Any]
218218

219219
let viewController = SettingsSelectionViewController(dictionary: settingsSelectionConfiguration)
220220

WordPress/Classes/ViewRelated/Plugins/Views/PluginDetailViewHeaderCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class PluginDetailViewHeaderCell: UITableViewCell, NibLoadable {
3030
let author = directoryEntry.author
3131

3232
let defaultAttributes: [NSAttributedString.Key: Any] = [.font: UIFont.preferredFont(forTextStyle: .subheadline),
33-
.foregroundColor: UIAppColor.neutral(.shade70)]
33+
.foregroundColor: UIAppColor.neutral(.shade70)]
3434

3535
let authorAttributes: [NSAttributedString.Key: Any] = [.foregroundColor: UIAppColor.primary(.shade40)]
3636

WordPress/Classes/ViewRelated/Stats/Shared Views/Stats Detail/SiteStatsInsightsDetailsViewModel.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -858,19 +858,19 @@ private extension SiteStatsInsightsDetailsViewModel {
858858
}
859859

860860
return [StatsTotalRowData(name: AnnualSiteStats.totalPosts,
861-
data: annualInsights.totalPostsCount.abbreviatedString()),
862-
StatsTotalRowData(name: AnnualSiteStats.totalComments,
863-
data: annualInsights.totalCommentsCount.abbreviatedString()),
864-
StatsTotalRowData(name: AnnualSiteStats.commentsPerPost,
865-
data: Int(round(annualInsights.averageCommentsCount)).abbreviatedString()),
866-
StatsTotalRowData(name: AnnualSiteStats.totalLikes,
867-
data: annualInsights.totalLikesCount.abbreviatedString()),
868-
StatsTotalRowData(name: AnnualSiteStats.likesPerPost,
869-
data: Int(round(annualInsights.averageLikesCount)).abbreviatedString()),
870-
StatsTotalRowData(name: AnnualSiteStats.totalWords,
871-
data: annualInsights.totalWordsCount.abbreviatedString()),
872-
StatsTotalRowData(name: AnnualSiteStats.wordsPerPost,
873-
data: Int(round(annualInsights.averageWordsCount)).abbreviatedString())]
861+
data: annualInsights.totalPostsCount.abbreviatedString()),
862+
StatsTotalRowData(name: AnnualSiteStats.totalComments,
863+
data: annualInsights.totalCommentsCount.abbreviatedString()),
864+
StatsTotalRowData(name: AnnualSiteStats.commentsPerPost,
865+
data: Int(round(annualInsights.averageCommentsCount)).abbreviatedString()),
866+
StatsTotalRowData(name: AnnualSiteStats.totalLikes,
867+
data: annualInsights.totalLikesCount.abbreviatedString()),
868+
StatsTotalRowData(name: AnnualSiteStats.likesPerPost,
869+
data: Int(round(annualInsights.averageLikesCount)).abbreviatedString()),
870+
StatsTotalRowData(name: AnnualSiteStats.totalWords,
871+
data: annualInsights.totalWordsCount.abbreviatedString()),
872+
StatsTotalRowData(name: AnnualSiteStats.wordsPerPost,
873+
data: Int(round(annualInsights.averageWordsCount)).abbreviatedString())]
874874
}
875875

876876
// MARK: - Posts and Pages

WordPress/Classes/ViewRelated/Support/SupportTableViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,9 @@ class ButtonCell: WPTableViewCellDefault {
654654

655655
NSLayoutConstraint.activate([
656656
button.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: SupportTableLayoutSpacing.sidePadding),
657-
button.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -SupportTableLayoutSpacing.sidePadding),
658-
button.topAnchor.constraint(equalTo: contentView.topAnchor, constant: SupportTableLayoutSpacing.topBottomPadding),
659-
button.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -SupportTableLayoutSpacing.topBottomPadding)
657+
button.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -SupportTableLayoutSpacing.sidePadding),
658+
button.topAnchor.constraint(equalTo: contentView.topAnchor, constant: SupportTableLayoutSpacing.topBottomPadding),
659+
button.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -SupportTableLayoutSpacing.topBottomPadding)
660660
])
661661
}
662662

WordPress/WordPressShareExtension/Sources/UI/ShareExtensionEditorViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class ShareExtensionEditorViewController: ShareExtensionAbstractViewController {
5353
self.configureDefaultProperties(for: textView, accessibilityLabel: accessibilityLabel)
5454

5555
let linkAttributes: [NSAttributedString.Key: Any] = [.underlineStyle: NSUnderlineStyle.single.rawValue,
56-
.foregroundColor: ShareColors.aztecLinkColor]
56+
.foregroundColor: ShareColors.aztecLinkColor]
5757

5858
textView.delegate = self
5959
textView.formattingDelegate = self
@@ -94,8 +94,8 @@ class ShareExtensionEditorViewController: ShareExtensionAbstractViewController {
9494
titleParagraphStyle.alignment = .natural
9595

9696
let attributes: [NSAttributedString.Key: Any] = [.foregroundColor: UIColor.label,
97-
.font: ShareFonts.title,
98-
.paragraphStyle: titleParagraphStyle]
97+
.font: ShareFonts.title,
98+
.paragraphStyle: titleParagraphStyle]
9999

100100
let textView = UITextView()
101101

0 commit comments

Comments
 (0)