Skip to content

Commit

Permalink
undo linting changes to regular expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbarela committed Jan 25, 2024
1 parent 3fe71fc commit e5783f0
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 91 deletions.
11 changes: 4 additions & 7 deletions Marlin/Marlin/DataSources/DFRS/DFRS+Decodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,10 @@ struct DFRSProperties: Decodable {
static func parsePosition(position: String) -> CLLocationCoordinate2D {
var latitude = 0.0
var longitude = 0.0

let pattern = #"""
(?<latdeg>[0-9]*)°(?<latminutes>[0-9]*)'(?<latseconds>[0-9]*\.?[0-9]*)\"\
(?<latdirection>[NS])\
\n(?<londeg>[0-9]*)°(?<lonminutes>[0-9]*)'(?<lonseconds>[0-9]*\.?[0-9]*)\"\
(?<londirection>[EW])
"""#
// swiftlint:disable line_length
let pattern = #"(?<latdeg>[0-9]*)°(?<latminutes>[0-9]*)'(?<latseconds>[0-9]*\.?[0-9]*)\"(?<latdirection>[NS]) \n(?<londeg>[0-9]*)°(?<lonminutes>[0-9]*)'(?<lonseconds>[0-9]*\.?[0-9]*)\"(?<londirection>[EW])"#
// swiftlint:enable line_length

let regex = try? NSRegularExpression(pattern: pattern, options: [])
let nsrange = NSRange(position.startIndex..<position.endIndex,
in: position)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,9 @@ struct DifferentialGPSStationModel: Locatable, Bookmarkable, Codable, GeoJSONExp
static func parsePosition(position: String) -> CLLocationCoordinate2D {
var latitude = 0.0
var longitude = 0.0

let pattern = #"""
(?<latdeg>[0-9]*)°(?<latminutes>[0-9]*)'(?<latseconds>[0-9]*\.?[0-9]*)\"\
(?<latdirection>[NS])\
\n(?<londeg>[0-9]*)°(?<lonminutes>[0-9]*)'(?<lonseconds>[0-9]*\.?[0-9]*)\"\
(?<londirection>[EW])
"""#
// swiftlint:disable line_length
let pattern = #"(?<latdeg>[0-9]*)°(?<latminutes>[0-9]*)'(?<latseconds>[0-9]*\.?[0-9]*)\"(?<latdirection>[NS]) \n(?<londeg>[0-9]*)°(?<lonminutes>[0-9]*)'(?<lonseconds>[0-9]*\.?[0-9]*)\"(?<londirection>[EW])"#
// swiftlint:enable line_length
let regex = try? NSRegularExpression(pattern: pattern, options: [])
let nsrange = NSRange(position.startIndex..<position.endIndex,
in: position)
Expand Down
10 changes: 3 additions & 7 deletions Marlin/Marlin/DataSources/Light/Light+Decodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,9 @@ struct LightsProperties: Codable {
static func parsePosition(position: String) -> CLLocationCoordinate2D {
var latitude = 0.0
var longitude = 0.0

let pattern = #"""
(?<latdeg>[0-9]*)°(?<latminutes>[0-9]*)'(?<latseconds>[0-9]*\.?[0-9]*)\"\
(?<latdirection>[NS])\
\n(?<londeg>[0-9]*)°(?<lonminutes>[0-9]*)'(?<lonseconds>[0-9]*\.?[0-9]*)\"\
(?<londirection>[EW])
"""#
// swiftlint:disable line_length
let pattern = #"(?<latdeg>[0-9]*)°(?<latminutes>[0-9]*)'(?<latseconds>[0-9]*\.?[0-9]*)\"(?<latdirection>[NS]) \n(?<londeg>[0-9]*)°(?<lonminutes>[0-9]*)'(?<lonseconds>[0-9]*\.?[0-9]*)\"(?<londirection>[EW])"#
// swiftlint:enable line_length
let regex = try? NSRegularExpression(pattern: pattern, options: [])
let nsrange = NSRange(position.startIndex..<position.endIndex,
in: position)
Expand Down
42 changes: 15 additions & 27 deletions Marlin/Marlin/DataSources/Light/LightProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,9 @@ struct LightModel: Locatable, Bookmarkable, Codable, CustomStringConvertible {
var latitude = 0.0
var longitude = 0.0

let pattern = #"""
(?<latdeg>[0-9]*)°(?<latminutes>[0-9]*)'(?<latseconds>[0-9]*\.?[0-9]*)\"\
(?<latdirection>[NS])\
\n(?<londeg>[0-9]*)°(?<lonminutes>[0-9]*)'(?<lonseconds>[0-9]*\.?[0-9]*)\"\
(?<londirection>[EW])
"""#
// swiftlint:disable line_length
let pattern = #"(?<latdeg>[0-9]*)°(?<latminutes>[0-9]*)'(?<latseconds>[0-9]*\.?[0-9]*)\"(?<latdirection>[NS]) \n(?<londeg>[0-9]*)°(?<lonminutes>[0-9]*)'(?<lonseconds>[0-9]*\.?[0-9]*)\"(?<londirection>[EW])"#
// swiftlint:enable line_length
let regex = try? NSRegularExpression(pattern: pattern, options: [])
let nsrange = NSRange(position.startIndex..<position.endIndex,
in: position)
Expand Down Expand Up @@ -407,10 +404,9 @@ struct LightModel: Locatable, Bookmarkable, Codable, CustomStringConvertible {
}
var sectors: [ImageSector] = []
// Azimuth coverage 270^-170^.
let pattern = #"""
(?<azimuth>(Azimuth coverage)?).?((?<startdeg>(\d*))\°)?\
((?<startminutes>[0-9]*)[\`'])?(-(?<enddeg>(\d*))\°)?(?<endminutes>[0-9]*)[\`']?\..*
"""#
// swiftlint:disable line_length
let pattern = #"(?<azimuth>(Azimuth coverage)?).?((?<startdeg>(\d*))\°)?((?<startminutes>[0-9]*)[\`'])?(-(?<enddeg>(\d*))\°)?(?<endminutes>[0-9]*)[\`']?\..*"#
// swiftlint:enable line_length
let regex = try? NSRegularExpression(pattern: pattern, options: [])
let nsrange = NSRange(remarks.startIndex..<remarks.endIndex,
in: remarks)
Expand Down Expand Up @@ -545,12 +541,9 @@ struct LightModel: Locatable, Bookmarkable, Codable, CustomStringConvertible {
}
var sectors: [ImageSector] = []

let pattern = #"""
(?<visible>(Visible)?)(?<fullLightObscured>(bscured)?)((?<color>[A-Z]+)?)\.?\
(?<unintensified>(\(unintensified\))?)(?<obscured>(\(bscured\))?)\
( (?<startdeg>(\d*))°)?((?<startminutes>[0-9]*)[\`'])?(-(?<enddeg>(\d*))°)\
(?<endminutes>[0-9]*)[\`']?
"""#
// swiftlint:disable line_length
let pattern = #"(?<visible>(Visible)?)(?<fullLightObscured>(bscured)?)((?<color>[A-Z]+)?)\.?(?<unintensified>(\(unintensified\))?)(?<obscured>(\(bscured\))?)( (?<startdeg>(\d*))°)?((?<startminutes>[0-9]*)[\`'])?(-(?<enddeg>(\d*))°)(?<endminutes>[0-9]*)[\`']?"#
// swiftlint:enable line_length
let regex = try? NSRegularExpression(pattern: pattern, options: [])
let nsrange = NSRange(remarks.startIndex..<remarks.endIndex,
in: remarks)
Expand Down Expand Up @@ -1133,11 +1126,9 @@ extension LightProtocol {
}
var sectors: [ImageSector] = []
// Azimuth coverage 270^-170^.
let pattern = #"""
(?<azimuth>(Azimuth coverage)?).?\
((?<startdeg>(\d*))\°)?((?<startminutes>[0-9]*)[\`'])?\
(-(?<enddeg>(\d*))\°)?(?<endminutes>[0-9]*)[\`']?\..*
"""#
// swiftlint:disable line_length
let pattern = #"(?<azimuth>(Azimuth coverage)?).?((?<startdeg>(\d*))\°)?((?<startminutes>[0-9]*)[\`'])?(-(?<enddeg>(\d*))\°)?(?<endminutes>[0-9]*)[\`']?\..*"#
// swiftlint:enable line_length
let regex = try? NSRegularExpression(pattern: pattern, options: [])
let nsrange = NSRange(remarks.startIndex..<remarks.endIndex,
in: remarks)
Expand Down Expand Up @@ -1272,12 +1263,9 @@ extension LightProtocol {
}
var sectors: [ImageSector] = []

let pattern = #"""
(?<visible>(Visible)?)(?<fullLightObscured>(bscured)?)\
((?<color>[A-Z]+)?)\.?(?<unintensified>(\(unintensified\))?)\
(?<obscured>(\(bscured\))?)( (?<startdeg>(\d*))°)?((?<startminutes>[0-9]*)[\`'])?\
(-(?<enddeg>(\d*))°)(?<endminutes>[0-9]*)[\`']?
"""#
// swiftlint:disable line_length
let pattern = #"(?<visible>(Visible)?)(?<fullLightObscured>(bscured)?)((?<color>[A-Z]+)?)\.?(?<unintensified>(\(unintensified\))?)(?<obscured>(\(bscured\))?)( (?<startdeg>(\d*))°)?((?<startminutes>[0-9]*)[\`'])?(-(?<enddeg>(\d*))°)(?<endminutes>[0-9]*)[\`']?"#
// swiftlint:enable line_length
let regex = try? NSRegularExpression(pattern: pattern, options: [])
let nsrange = NSRange(remarks.startIndex..<remarks.endIndex,
in: remarks)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ class RadioBeacon: NSManagedObject {
return nil
}
var sectors: [ImageSector] = []
let pattern = #"""
(?<azimuth>(Azimuth coverage)?).?((?<startdeg>(\d*))\^)?((?<startminutes>[0-9]*)[\`'])?\
(-(?<enddeg>(\d*))\^)?(?<endminutes>[0-9]*)[\`']?\.
"""#
// swiftlint:disable line_length
let pattern = #"(?<azimuth>(Azimuth coverage)?).?((?<startdeg>(\d*))\^)?((?<startminutes>[0-9]*)[\`'])?(-(?<enddeg>(\d*))\^)?(?<endminutes>[0-9]*)[\`']?\."#
// swiftlint:enable line_length
let regex = try? NSRegularExpression(pattern: pattern, options: [])
let nsrange = NSRange(remarks.startIndex..<remarks.endIndex,
in: remarks)
Expand Down
17 changes: 6 additions & 11 deletions Marlin/Marlin/DataSources/RadioBeacon/RadioBeaconModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,9 @@ struct RadioBeaconModel: Codable, Bookmarkable, Locatable, GeoJSONExportable, Cu
var latitude = 0.0
var longitude = 0.0

let pattern = #"""
(?<latdeg>[0-9]*)°(?<latminutes>[0-9]*)'(?<latseconds>[0-9]*\.?[0-9]*)\"\
(?<latdirection>[NS])\
\n(?<londeg>[0-9]*)°(?<lonminutes>[0-9]*)'(?<lonseconds>[0-9]*\.?[0-9]*)\"\
(?<londirection>[EW])
"""#
// swiftlint:disable line_length
let pattern = #"(?<latdeg>[0-9]*)°(?<latminutes>[0-9]*)'(?<latseconds>[0-9]*\.?[0-9]*)\"(?<latdirection>[NS]) \n(?<londeg>[0-9]*)°(?<lonminutes>[0-9]*)'(?<lonseconds>[0-9]*\.?[0-9]*)\"(?<londirection>[EW])"#
// swiftlint:enable line_length
let regex = try? NSRegularExpression(pattern: pattern, options: [])
let nsrange = NSRange(position.startIndex..<position.endIndex,
in: position)
Expand Down Expand Up @@ -359,11 +356,9 @@ struct RadioBeaconModel: Codable, Bookmarkable, Locatable, GeoJSONExportable, Cu
return nil
}
var sectors: [ImageSector] = []
let pattern = #"""
(?<azimuth>(Azimuth coverage)?).?\
((?<startdeg>(\d*))\^)?((?<startminutes>[0-9]*)[\`'])?\
(-(?<enddeg>(\d*))\^)?(?<endminutes>[0-9]*)[\`']?\.
"""#
// swiftlint:disable line_length
let pattern = #"(?<azimuth>(Azimuth coverage)?).?((?<startdeg>(\d*))\^)?((?<startminutes>[0-9]*)[\`'])?(-(?<enddeg>(\d*))\^)?(?<endminutes>[0-9]*)[\`']?\."#
// swiftlint:enable line_length
let regex = try? NSRegularExpression(pattern: pattern, options: [])
let nsrange = NSRange(remarks.startIndex..<remarks.endIndex,
in: remarks)
Expand Down
17 changes: 6 additions & 11 deletions Marlin/Marlin/Extensions/CLLocationCoordinate2DExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -731,13 +731,9 @@ extension CLLocationCoordinate2D {
return nil
}

let pattern = #"""
(?<latdeg>-?[0-9]*\.?\d+)[\s°-]*(?<latminutes>\d{1,2}\.?\d+)?\
[\s\`'-]*(?<latseconds>\d{1,2}\.?\d+)?[\s\"\
]?(?<latdirection>([NOEWS])?)[\s,]*(?<londeg>-?[0-9]*\.?\d+)\
[\s°-]*(?<lonminutes>\d{1,2}\.?\d+)?[\s\`'-]*\
(?<lonseconds>\d{1,2}\.?\d+)?[\s\" ]*(?<londirection>([NOEWS])?)
"""#
// swiftlint:disable line_length
let pattern = #"(?<latdeg>-?[0-9]*\.?\d+)[\s°-]*(?<latminutes>\d{1,2}\.?\d+)?[\s\`'-]*(?<latseconds>\d{1,2}\.?\d+)?[\s\" ]?(?<latdirection>([NOEWS])?)[\s,]*(?<londeg>-?[0-9]*\.?\d+)[\s°-]*(?<lonminutes>\d{1,2}\.?\d+)?[\s\`'-]*(?<lonseconds>\d{1,2}\.?\d+)?[\s\" ]*(?<londirection>([NOEWS])?)"#
// swiftlint:enable line_length

var foundLat: Bool = false
var foundLon: Bool = false
Expand Down Expand Up @@ -811,10 +807,9 @@ extension CLLocationCoordinate2D {
extension Double {

init?(coordinateString: String) {
let pattern = #"""
(?<deg>-?[0-9]*\.?\d+)[\s°-]*(?<minutes>\d{1,2}\.?\d+)?[\s\`'-]*\
(?<seconds>\d{1,2}\.?\d+)?[\s\" ]?(?<direction>([NOEWS])?)
"""#
// swiftlint:disable line_length
let pattern = #"(?<deg>-?[0-9]*\.?\d+)[\s°-]*(?<minutes>\d{1,2}\.?\d+)?[\s\`'-]*(?<seconds>\d{1,2}\.?\d+)?[\s\" ]?(?<direction>([NOEWS])?)"#
// swiftlint:enable line_length

var found: Bool = false
var degrees: Double = 0.0
Expand Down
6 changes: 3 additions & 3 deletions Marlin/MarlinTests/BottomSheet/MarlinBottomSheetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ final class MarlinBottomSheetTests: XCTestCase {

let bottomSheetItem = BottomSheetItem(item: newItem, zoom: false)

let repository = AsamRepository(repository: AsamCoreDataDataSource(context: persistentStore.viewContext))
let bookmarkRepository = BookmarkRepositoryManager(repository:
let repository = AsamRepository(localDataSource: AsamCoreDataDataSource(context: persistentStore.viewContext))
let bookmarkRepository = BookmarkRepositoryManager(repository:
BookmarkCoreDataRepository(context: persistentStore.viewContext))

let view = TestBottomSheet(bottomSheetItems: [bottomSheetItem])
Expand Down Expand Up @@ -143,7 +143,7 @@ final class MarlinBottomSheetTests: XCTestCase {

let bottomSheetItem2 = BottomSheetItem(item: newItem2, zoom: false)

let repository = AsamRepository(repository: AsamCoreDataDataSource(context: persistentStore.viewContext))
let repository = AsamRepository(localDataSource: AsamCoreDataDataSource(context: persistentStore.viewContext))
let bookmarkRepository = BookmarkRepositoryManager(repository:
BookmarkCoreDataRepository(context: persistentStore.viewContext))
let moduRepository = ModuRepositoryManager(repository:
Expand Down
6 changes: 3 additions & 3 deletions Marlin/MarlinTests/MarlinFullFlowTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class MarlinFullFlowTest: XCTestCase {
.removeDuplicates()
.sink { output in
TestHelpers.clearData()
for dataSource in MSI.shared.masterDataList {
for dataSource in MSI.shared.mainDataList {
switch dataSource {
case let mapImage as MapImage.Type:
mapImage.imageCache.clearCache()
Expand Down Expand Up @@ -66,7 +66,7 @@ final class MarlinFullFlowTest: XCTestCase {
return
}

for dataSource in MSI.shared.masterDataList {
for dataSource in MSI.shared.mainDataList {
switch dataSource {
case let mapImage as MapImage.Type:
mapImage.imageCache.clearCache()
Expand Down Expand Up @@ -250,7 +250,7 @@ final class MarlinFullFlowTest: XCTestCase {
return
}

for dataSource in MSI.shared.masterDataList {
for dataSource in MSI.shared.mainDataList {
switch dataSource {
case let mapImage as MapImage.Type:
mapImage.imageCache.clearCache()
Expand Down
2 changes: 1 addition & 1 deletion Marlin/MarlinTests/Views/BadgeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class BadgeTests: XCTestCase {
}

func testCheckBadge() {
let badge = CheckBadge(on: Binding.constant(true))
let badge = CheckBadge(checked: Binding.constant(true))
let controller = UIHostingController(rootView: badge)
let window = TestHelpers.getKeyWindowVisible()
window.rootViewController = controller
Expand Down
20 changes: 10 additions & 10 deletions Marlin/MarlinTests/Views/DataLoadedNotificationBannerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class DataLoadedNotificationBannerTests: XCTestCase {

func testShowNotification() {
let appState = AppState()
appState.dataSourceBatchImportNotificationsPending = [
appState.dsBatchImportNotificationsPending = [
Asam.key : [DataSourceUpdatedNotification(key: Asam.key, updates: 1, inserts: 3)]
]
appState.loadingDataSource[MockDataSourceNonMappable.key] = false
Expand All @@ -36,7 +36,7 @@ final class DataLoadedNotificationBannerTests: XCTestCase {

func testExpandNotification() {
let appState = AppState()
appState.dataSourceBatchImportNotificationsPending = [
appState.dsBatchImportNotificationsPending = [
Asam.key : [DataSourceUpdatedNotification(key: Asam.key, updates: 1, inserts: 3)],
Modu.key : [DataSourceUpdatedNotification(key: Modu.key, updates: 1, inserts: 3)],
Light.key : [DataSourceUpdatedNotification(key: Light.key, updates: 1, inserts: 3)],
Expand All @@ -61,7 +61,7 @@ final class DataLoadedNotificationBannerTests: XCTestCase {

func testClearNotification() {
let appState = AppState()
appState.dataSourceBatchImportNotificationsPending = [
appState.dsBatchImportNotificationsPending = [
Asam.key : [DataSourceUpdatedNotification(key: Asam.key, updates: 1, inserts: 3)]
]
appState.loadingDataSource[MockDataSourceNonMappable.key] = false
Expand All @@ -74,20 +74,20 @@ final class DataLoadedNotificationBannerTests: XCTestCase {
let controller = UIHostingController(rootView: view)
let window = TestHelpers.getKeyWindowVisible()
window.rootViewController = controller
XCTAssertFalse(appState.dataSourceBatchImportNotificationsPending.isEmpty)
XCTAssertFalse(appState.dsBatchImportNotificationsPending.isEmpty)
tester().waitForView(withAccessibilityLabel: "3 new \(Asam.fullDataSourceName)")
tester().waitForView(withAccessibilityLabel: "Clear")
let lastDate = appState.lastNotificationRequestDate
appState.consolidatedDataLoadedNotification = ""
tester().tapView(withAccessibilityLabel: "Clear")
XCTAssertNotEqual(lastDate, appState.lastNotificationRequestDate)
XCTAssertTrue(appState.dataSourceBatchImportNotificationsPending.isEmpty)
XCTAssertTrue(appState.dsBatchImportNotificationsPending.isEmpty)
tester().waitForAbsenceOfView(withAccessibilityLabel: "3 new \(Asam.fullDataSourceName)")
}

func testShowNotificationAddExtra() {
let appState = AppState()
appState.dataSourceBatchImportNotificationsPending = [
appState.dsBatchImportNotificationsPending = [
Asam.key : [DataSourceUpdatedNotification(key: Asam.key, updates: 1, inserts: 3)]
]
appState.consolidatedDataLoadedNotification = "3 new \(Asam.fullDataSourceName)"
Expand All @@ -99,7 +99,7 @@ final class DataLoadedNotificationBannerTests: XCTestCase {
window.rootViewController = controller
tester().waitForView(withAccessibilityLabel: "3 new \(Asam.fullDataSourceName)")

appState.dataSourceBatchImportNotificationsPending = [
appState.dsBatchImportNotificationsPending = [
Asam.key : [DataSourceUpdatedNotification(key: Asam.key, updates: 1, inserts: 12)]
]
appState.consolidatedDataLoadedNotification = "15 new \(Asam.fullDataSourceName)"
Expand All @@ -109,7 +109,7 @@ final class DataLoadedNotificationBannerTests: XCTestCase {

func testOnlyShowDataSourcesWithInserts() {
let appState = AppState()
appState.dataSourceBatchImportNotificationsPending = [
appState.dsBatchImportNotificationsPending = [
Asam.key : [DataSourceUpdatedNotification(key: Asam.key, updates: 1, inserts: 3)],
Modu.key : [DataSourceUpdatedNotification(key: Modu.key, updates: 2, inserts: 0)]
]
Expand All @@ -125,7 +125,7 @@ final class DataLoadedNotificationBannerTests: XCTestCase {

func testShowPreviousInsertsIfNewWithOnlyUpdatesComesIn() {
let appState = AppState()
appState.dataSourceBatchImportNotificationsPending = [
appState.dsBatchImportNotificationsPending = [
Asam.key : [DataSourceUpdatedNotification(key: Asam.key, updates: 1, inserts: 3)]
]
appState.consolidatedDataLoadedNotification = "3 new \(Asam.fullDataSourceName)"
Expand All @@ -137,7 +137,7 @@ final class DataLoadedNotificationBannerTests: XCTestCase {
window.rootViewController = controller
tester().waitForView(withAccessibilityLabel: "3 new \(Asam.fullDataSourceName)")

appState.dataSourceBatchImportNotificationsPending = [
appState.dsBatchImportNotificationsPending = [
Asam.key : [DataSourceUpdatedNotification(key: Asam.key, updates: 1, inserts: 0)]
]
appState.consolidatedDataLoadedNotification = "3 new \(Asam.fullDataSourceName)"
Expand Down

0 comments on commit e5783f0

Please sign in to comment.