Skip to content

Commit a4b77f8

Browse files
authored
fix: Update SwiftLint configuration to include Tests directory and lint only modified Swift files (#426)
1 parent ac73bd9 commit a4b77f8

File tree

255 files changed

+727
-396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+727
-396
lines changed

.swiftlint.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ opt_in_rules:
3131
- static_operator
3232
analyzer_rules:
3333
- explicit_self
34+
file_header:
35+
required_pattern: |
36+
\/\/
37+
\/\/ .*?\.swift
38+
\/\/ TPPDF
39+
\/\/
40+
\/\/ (Created by .*? on \d{2}\.\d{2}\.\d{4}\.)
41+
\/\/ Copyright © \d{4}-\d{4} techprimate GmbH. All rights reserved\.
42+
\/\/
3443
file_length:
3544
error: 1200
3645
warning: 500
@@ -47,7 +56,10 @@ identifier_name:
4756
error: 2
4857
warning: 2
4958
included:
59+
- Example*
60+
- Shared*
5061
- Source
62+
- Tests
5163
line_length: 150
5264
reporter: xcode
5365
type_body_length:
@@ -58,3 +70,5 @@ type_name:
5870
error: 60
5971
warning: 50
6072
min_length: 2
73+
allowed_symbols:
74+
- _

Dangerfile.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,13 @@ if sourceChanges, !testsUpdated {
4949
warn("The library files were changed, but the tests remained unmodified. Consider updating or adding to the tests to match the library changes.")
5050
}
5151

52-
// Run Swiftlint
53-
SwiftLint.lint(inline: false, configFile: ".swiftlint.yml")
52+
// Run SwiftLint only on files in included paths (Source/ and Tests/)
53+
let includedPaths = ["Source", "Tests"]
54+
let changedSwiftFiles = (danger.git.modifiedFiles + danger.git.createdFiles)
55+
.filter { file in
56+
file.fileType == .swift && includedPaths.contains { file.hasPrefix($0) }
57+
}
58+
59+
if !changedSwiftFiles.isEmpty {
60+
SwiftLint.lint(inline: false, configFile: ".swiftlint.yml")
61+
}

Example macOS-SwiftPM/Example/AppDelegate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//
22
// AppDelegate.swift
3-
// Example
3+
// TPPDF
44
//
5-
// Created by Philip Niedertscheider on 23.06.20.
5+
// Created by Philip Niedertscheider on 23.06.2020.
66
// Copyright © 2016-2025 techprimate GmbH. All rights reserved.
77
//
88

Example macOS-SwiftPM/Example/UI/ContentView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//
22
// ContentView.swift
3-
// Example
3+
// TPPDF
44
//
5-
// Created by Philip Niedertscheider on 23.06.20.
5+
// Created by Philip Niedertscheider on 23.06.2020.
66
// Copyright © 2016-2025 techprimate GmbH. All rights reserved.
77
//
88

Example macOS-SwiftPM/Example/UI/DetailView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//
22
// DetailView.swift
3-
// Example
3+
// TPPDF
44
//
5-
// Created by Philip Niedertscheider on 24.06.20.
5+
// Created by Philip Niedertscheider on 24.06.2020.
66
// Copyright © 2016-2025 techprimate GmbH. All rights reserved.
77
//
88

Example macOS-SwiftPM/Example/UI/PDFView+SwiftUI.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//
22
// PDFView+SwiftUI.swift
3-
// Example
3+
// TPPDF
44
//
5-
// Created by Philip Niedertscheider on 23.06.20.
5+
// Created by Philip Niedertscheider on 23.06.2020.
66
// Copyright © 2016-2025 techprimate GmbH. All rights reserved.
77
//
88

Example macOS-SwiftPM/Example/UI/ProgressBar.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//
22
// ProgressBar.swift
3-
// Example
3+
// TPPDF
44
//
5-
// Created by Philip Niedertscheider on 24.06.20.
5+
// Created by Philip Niedertscheider on 24.06.2020.
66
// Copyright © 2016-2025 techprimate GmbH. All rights reserved.
77
//
88

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ format-yaml:
308308
# Runs SwiftLint and dprint checks without modifying files.
309309
.PHONY: lint
310310
lint:
311-
swiftlint --config .swiftlint.yml --strict
311+
swiftlint --config .swiftlint.yml --strict --quiet
312312
dprint check "**/*.{md,json,yaml,yml}"
313313

314314
# ============================================================================

Shared iOS/UI/ExamplesListViewController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//
22
// ExamplesListViewController.swift
3-
// TPPDF_Example
3+
// TPPDF
44
//
5-
// Created by Philip Niedertscheider on 18.12.19.
5+
// Created by Philip Niedertscheider on 18.12.2019.
66
// Copyright © 2016-2025 techprimate GmbH. All rights reserved.
77
//
88

@@ -11,11 +11,11 @@ import UIKit
1111

1212
class ExamplesListViewController: UITableViewController {
1313
override func numberOfSections(in _: UITableView) -> Int {
14-
return Examples.factories.count
14+
Examples.factories.count
1515
}
1616

1717
override func tableView(_: UITableView, numberOfRowsInSection section: Int) -> Int {
18-
return Examples.factories[section].examples.count
18+
Examples.factories[section].examples.count
1919
}
2020

2121
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
@@ -30,7 +30,7 @@ class ExamplesListViewController: UITableViewController {
3030
}
3131

3232
override func tableView(_: UITableView, titleForHeaderInSection section: Int) -> String? {
33-
return Examples.factories[section].header
33+
Examples.factories[section].header
3434
}
3535

3636
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

Shared iOS/UI/ViewController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ViewController.swift
33
// TPPDF
44
//
5-
// Created by Philip Niedertscheider on 08.11.16.
5+
// Created by Philip Niedertscheider on 08.11.2016.
66
// Copyright © 2016-2025 techprimate GmbH. All rights reserved.
77
//
88

@@ -16,7 +16,7 @@ class ViewController: UIViewController {
1616

1717
var progressObserver: NSObjectProtocol!
1818

19-
public var exampleFactory: ExampleFactory?
19+
var exampleFactory: ExampleFactory?
2020

2121
override func viewWillAppear(_ animated: Bool) {
2222
super.viewWillAppear(animated)
@@ -48,8 +48,8 @@ class ViewController: UIViewController {
4848
generator.debug = exampleFactory is ExperimentFactory
4949

5050
progressView.observedProgress = generator.progress
51-
observer = generator.progress.observe(\.completedUnitCount) { p, _ in
52-
print(p.localizedDescription ?? "")
51+
observer = generator.progress.observe(\.completedUnitCount) { progress, _ in
52+
print(progress.localizedDescription ?? "")
5353
}
5454
DispatchQueue.global(qos: .background).async {
5555
do {

0 commit comments

Comments
 (0)