Skip to content

Commit a25dc39

Browse files
committed
Apply swiftLint fixes
1 parent ad61278 commit a25dc39

File tree

11 files changed

+59
-33
lines changed

11 files changed

+59
-33
lines changed

Example/Podfile

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ end
66

77
target 'SwiftCronExampleTests' do
88
pod 'SwiftCron', :path => '../'
9+
pod 'SwiftLint'
910
end
1011

1112
pre_install do |installer|

Example/SwiftCronExample.xcodeproj/project.pbxproj

+15
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
8679D26D1CE1F4730071D783 /* Sources */,
203203
8679D26E1CE1F4730071D783 /* Frameworks */,
204204
8679D26F1CE1F4730071D783 /* Resources */,
205+
955360B1207221680040C5C5 /* Run SwiftLint */,
205206
42C8277495ABC8132337E07F /* [CP] Embed Pods Frameworks */,
206207
32DF2E51192F05F6A8F079E6 /* [CP] Copy Pods Resources */,
207208
);
@@ -362,6 +363,20 @@
362363
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
363364
showEnvVarsInLog = 0;
364365
};
366+
955360B1207221680040C5C5 /* Run SwiftLint */ = {
367+
isa = PBXShellScriptBuildPhase;
368+
buildActionMask = 2147483647;
369+
files = (
370+
);
371+
inputPaths = (
372+
);
373+
name = "Run SwiftLint";
374+
outputPaths = (
375+
);
376+
runOnlyForDeploymentPostprocessing = 0;
377+
shellPath = /bin/sh;
378+
shellScript = "\"${PODS_ROOT}/SwiftLint/swiftlint\"";
379+
};
365380
E87025957E0569C2E0F11DA7 /* [CP] Check Pods Manifest.lock */ = {
366381
isa = PBXShellScriptBuildPhase;
367382
buildActionMask = 2147483647;

Example/SwiftCronExample/AppDelegate.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414

1515
var window: UIWindow?
1616

17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17+
func application(
18+
_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?)
19+
-> Bool {
1820
return true
1921
}
2022

Example/SwiftCronExampleTests/CronExpressionTests.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ class CronExpressionTests: XCTestCase {
1515

1616
func testCreatingCronExpressionWithInvalidValueReturnsNil() {
1717
let invalidDay = "!@# $%^"
18-
let cronExpression = CronExpression(minute: "4", hour: "3", day: invalidDay, month: "1", weekday: "2", year: "2016")
18+
let cronExpression = CronExpression(minute: "4", hour: "3",
19+
day: invalidDay, month: "1",
20+
weekday: "2", year: "2016")
1921

2022
XCTAssertNil(cronExpression)
2123
}

Example/SwiftCronExampleTests/DayTests.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,31 @@ class DayTests: XCTestCase {
3333
}
3434

3535
func testLastDayOfMonthInFeb2016Returns28() {
36-
let dateToTestFrom = TestData.feb1_2016
36+
let dateToTestFrom = TestData.feb1Of2016
3737

38-
let cronExpressionUnderTest = CronExpression(day:"L", month:2, year: 2016)!
38+
let cronExpressionUnderTest = CronExpression(day: "L", month: 2, year: 2016)!
3939

40-
let expectedNextRunDate = TestData.feb28_2016
40+
let expectedNextRunDate = TestData.feb28Of2016
4141
let nextRunDate = cronExpressionUnderTest.getNextRunDate(dateToTestFrom)!
4242
XCTAssertTrue(Calendar.current.isDate(expectedNextRunDate, inSameDayAs: nextRunDate))
4343
}
4444

4545
func testLastDayOfMonthInMay2016Returns31() {
46-
let dateToTestFrom = TestData.may15_2016
46+
let dateToTestFrom = TestData.may15Of2016
4747

48-
let cronExpressionUnderTest = CronExpression(day:"L", month:5, year: 2016)!
48+
let cronExpressionUnderTest = CronExpression(day: "L", month: 5, year: 2016)!
4949

50-
let expectedNextRunDate = TestData.may31_2016
50+
let expectedNextRunDate = TestData.may31Of2016
5151
let nextRunDate = cronExpressionUnderTest.getNextRunDate(dateToTestFrom)!
5252
XCTAssertTrue(Calendar.current.isDate(expectedNextRunDate, inSameDayAs: nextRunDate))
5353
}
5454

5555
func testLastDayOfMonthInJune2016Returns30() {
5656
let dateToTestFrom = TestData.june1
5757

58-
let cronExpressionUnderTest = CronExpression(day:"L", month:6, year: 2016)!
58+
let cronExpressionUnderTest = CronExpression(day: "L", month: 6, year: 2016)!
5959

60-
let expectedNextRunDate = TestData.june30_2016
60+
let expectedNextRunDate = TestData.june30Of2016
6161
let nextRunDate = cronExpressionUnderTest.getNextRunDate(dateToTestFrom)!
6262
XCTAssertTrue(Calendar.current.isDate(expectedNextRunDate, inSameDayAs: nextRunDate))
6363
}

Example/SwiftCronExampleTests/DescriptionTests.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class DescriptionTests: XCTestCase {
195195
}
196196

197197
func testEveryWeekdayAtEvery30MinutesOnATuesday() {
198-
let cronExpression = CronExpression(minute: "30", weekday:"2")!
198+
let cronExpression = CronExpression(minute: "30", weekday: "2")!
199199

200200
let description = cronExpression.shortDescription
201201
let expectedDescription = "Every 30 minutes on a Tuesday"
@@ -205,6 +205,4 @@ class DescriptionTests: XCTestCase {
205205
XCTAssertEqual(longDesc, expectedDescription)
206206
}
207207

208-
// TODO: test all the crazy possible steps permutations
209-
210208
}

Example/SwiftCronExampleTests/HourTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class HourTests: XCTestCase {
3737
}
3838

3939
func testEverySecondAndEveryFourthHourOfDay() {
40-
let dateToTestFrom = TestData.may15_2016
40+
let dateToTestFrom = TestData.may15Of2016
4141

4242
let everySecondAndFourthHourOfDayCron = CronExpression(minute: "0", hour: "2,4")!
4343

Example/SwiftCronExampleTests/SwiftCronTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SwiftCronTests: XCTestCase {
3636
let cron = CronExpression(cronString: "32 4 8 12 3 *")
3737
var runDate: Date?
3838

39-
runDate = cron?.getNextRunDate(TestData.jan1_2017)
39+
runDate = cron?.getNextRunDate(TestData.janFirst2017)
4040
XCTAssertNotNil(runDate)
4141
})
4242

Example/SwiftCronExampleTests/Test Data/TestData.swift

+14-7
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@
99
import Foundation
1010

1111
class TestData {
12-
static let may11 = (Calendar.current as NSCalendar).date(era: 1, year: 2016, month: 05, day: 11, hour: 0, minute: 0, second: 0, nanosecond: 0)!
13-
static let may12 = (Calendar.current as NSCalendar).date(era: 1, year: 2016, month: 05, day: 12, hour: 0, minute: 0, second: 0, nanosecond: 0)!
14-
static let may14 = (Calendar.current as NSCalendar).date(era: 1, year: 2016, month: 05, day: 14, hour: 0, minute: 0, second: 0, nanosecond: 0)!
15-
static let may16 = (Calendar.current as NSCalendar).date(era: 1, year: 2016, month: 05, day: 16, hour: 0, minute: 0, second: 0, nanosecond: 0)!
16-
static let june1 = (Calendar.current as NSCalendar).date(era: 1, year: 2016, month: 06, day: 1, hour: 0, minute: 0, second: 0, nanosecond: 0)!
17-
static let june8 = (Calendar.current as NSCalendar).date(era: 1, year: 2016, month: 06, day: 8, hour: 0, minute: 0, second: 0, nanosecond: 0)!
18-
static let jan1_2017 = (Calendar.current as NSCalendar).date(era: 1, year: 2017, month: 01, day: 1, hour: 0, minute: 0, second: 0, nanosecond: 0)!
12+
static let may11 = (Calendar.current as NSCalendar)
13+
.date(era: 1, year: 2016, month: 05, day: 11, hour: 0, minute: 0, second: 0, nanosecond: 0)!
14+
static let may12 = (Calendar.current as NSCalendar)
15+
.date(era: 1, year: 2016, month: 05, day: 12, hour: 0, minute: 0, second: 0, nanosecond: 0)!
16+
static let may14 = (Calendar.current as NSCalendar)
17+
.date(era: 1, year: 2016, month: 05, day: 14, hour: 0, minute: 0, second: 0, nanosecond: 0)!
18+
static let may16 = (Calendar.current as NSCalendar)
19+
.date(era: 1, year: 2016, month: 05, day: 16, hour: 0, minute: 0, second: 0, nanosecond: 0)!
20+
static let june1 = (Calendar.current as NSCalendar)
21+
.date(era: 1, year: 2016, month: 06, day: 1, hour: 0, minute: 0, second: 0, nanosecond: 0)!
22+
static let june8 = (Calendar.current as NSCalendar)
23+
.date(era: 1, year: 2016, month: 06, day: 8, hour: 0, minute: 0, second: 0, nanosecond: 0)!
24+
static let janFirst2017 = (Calendar.current as NSCalendar)
25+
.date(era: 1, year: 2017, month: 01, day: 1, hour: 0, minute: 0, second: 0, nanosecond: 0)!
1926
}

Example/SwiftCronExampleTests/TestData.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
import Foundation
1010

1111
class TestData {
12-
static let feb28_2016 = DateBuilder().with(year: 2016).with(month: 2).with(day: 28).build()
13-
static let feb1_2016 = DateBuilder().with(year: 2016).with(month: 2).with(day: 1).build()
14-
static let may15_2016 = DateBuilder().with(year: 2016).with(month: 5).with(day: 15).build()
15-
static let may31_2016 = DateBuilder().with(year: 2016).with(month: 5).with(day: 31).build()
16-
static let june30_2016 = DateBuilder().with(year: 2016).with(month: 6).with(day: 30).build()
17-
static let july11_2016 = DateBuilder().with(year: 2016).with(month: 7).with(day: 11).build()
18-
static let july27_2016 = DateBuilder().with(year: 2016).with(month: 7).with(day: 27).build()
12+
static let feb28Of2016 = DateBuilder().with(year: 2016).with(month: 2).with(day: 28).build()
13+
static let feb1Of2016 = DateBuilder().with(year: 2016).with(month: 2).with(day: 1).build()
14+
static let may15Of2016 = DateBuilder().with(year: 2016).with(month: 5).with(day: 15).build()
15+
static let may31Of2016 = DateBuilder().with(year: 2016).with(month: 5).with(day: 31).build()
16+
static let june30Of2016 = DateBuilder().with(year: 2016).with(month: 6).with(day: 30).build()
17+
static let july11Of2016 = DateBuilder().with(year: 2016).with(month: 7).with(day: 11).build()
18+
static let july27Of2016 = DateBuilder().with(year: 2016).with(month: 7).with(day: 27).build()
1919
static let may11 = DateBuilder().with(year: 2016).with(month: 5).with(day: 11).build()
2020
static let may12 = DateBuilder().with(year: 2016).with(month: 5).with(day: 12).build()
2121
static let may14 = DateBuilder().with(year: 2016).with(month: 5).with(day: 14).build()
2222
static let may16 = DateBuilder().with(year: 2016).with(month: 5).with(day: 16).build()
2323
static let june1 = DateBuilder().with(year: 2016).with(month: 6).with(day: 1).build()
2424
static let june8 = DateBuilder().with(year: 2016).with(month: 6).with(day: 8).build()
25-
static let jan1_2017 = DateBuilder().with(year: 2017).with(month: 1).with(day: 1).build()
25+
static let janFirst2017 = DateBuilder().with(year: 2017).with(month: 1).with(day: 1).build()
2626
}

Example/SwiftCronExampleTests/YearTests.swift

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ class YearTests: XCTestCase {
2929
let firstDayOfMonthCron = CronExpression(minute: "0", hour: "0", day: "1", month: "1")
3030
let nextRunDate = firstDayOfMonthCron?.getNextRunDate(dateToTestFrom)
3131

32-
XCTAssertTrue(calendar.isDate(TestData.jan1_2017, inSameDayAs: nextRunDate!))
32+
XCTAssertTrue(calendar.isDate(TestData.janFirst2017, inSameDayAs: nextRunDate!))
3333
}
3434

3535
func testEveryThursdayIn2018RunsIn2018() {
3636
let thursdaysIn2018Cron = CronExpression(minute: "0", hour: "0", weekday: "4", year: "2018")!
37-
let dateToTestFrom = TestData.may15_2016
37+
let dateToTestFrom = TestData.may15Of2016
3838
let firstThursdayIn2018 = DateBuilder().with(day: 4).with(month: 1).with(year: 2018).build()
3939
let nextRunDate = thursdaysIn2018Cron.getNextRunDate(dateToTestFrom)!
4040
XCTAssertTrue(Calendar.current.isDate(firstThursdayIn2018, inSameDayAs: nextRunDate))
@@ -52,7 +52,8 @@ class YearTests: XCTestCase {
5252
func testNextRunDateIsNilWhenDateIsNotInReasonableFuture() {
5353
let dateToTestFrom = DateBuilder().with(month: 5).with(year: 2015).build()
5454

55-
let firstDayOfFirstMonthInPastCron = CronExpression(minute: "0", hour: "0", day: "1", month: "1", year: "999999")
55+
let firstDayOfFirstMonthInPastCron =
56+
CronExpression(minute: "0", hour: "0", day: "1", month: "1", year: "999999")
5657
let nextRunDate = firstDayOfFirstMonthInPastCron?.getNextRunDate(dateToTestFrom)
5758

5859
XCTAssertNil(nextRunDate)

0 commit comments

Comments
 (0)