diff --git a/CookSmart/.swiftformat b/CookSmart/.swiftformat index 53aa45d..178085a 100644 --- a/CookSmart/.swiftformat +++ b/CookSmart/.swiftformat @@ -18,3 +18,4 @@ # Disabled Rules --disable blankLinesAtStartOfScope +--disable wrapMultilineStatementBraces diff --git a/CookSmart/BuildTools/.swiftlint.yml b/CookSmart/BuildTools/.swiftlint.yml index 53c2b60..73cee7f 100644 --- a/CookSmart/BuildTools/.swiftlint.yml +++ b/CookSmart/BuildTools/.swiftlint.yml @@ -1,7 +1,7 @@ # Rules found at https://realm.github.io/SwiftLint/rule-directory.html excluded: - - fastlane + - ../fastlane disabled_rules: # rule identifiers to exclude from running - identifier_name diff --git a/CookSmart/BuildTools/Mintfile b/CookSmart/BuildTools/Mintfile index 29a3238..5da7365 100644 --- a/CookSmart/BuildTools/Mintfile +++ b/CookSmart/BuildTools/Mintfile @@ -1,2 +1,2 @@ -nicklockwood/SwiftFormat@0.44.7 -realm/SwiftLint@0.39.1 +nicklockwood/SwiftFormat@0.52.10 +realm/SwiftLint@0.53.0 diff --git a/CookSmart/CakeTests/DoubleStringUtilsTests.swift b/CookSmart/CakeTests/DoubleStringUtilsTests.swift index 87588c7..272e1f7 100644 --- a/CookSmart/CakeTests/DoubleStringUtilsTests.swift +++ b/CookSmart/CakeTests/DoubleStringUtilsTests.swift @@ -1,5 +1,5 @@ // -// DoubleUtilsTests.swift +// DoubleStringUtilsTests.swift // cake // // Created by Olga Galchenko on 4/11/20. diff --git a/CookSmart/CookSmart.xcodeproj/project.pbxproj b/CookSmart/CookSmart.xcodeproj/project.pbxproj index 1fbc532..6092d25 100644 --- a/CookSmart/CookSmart.xcodeproj/project.pbxproj +++ b/CookSmart/CookSmart.xcodeproj/project.pbxproj @@ -35,9 +35,9 @@ 80592C0E189268D60082D4E1 /* CSScaleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 80592C0D189268D60082D4E1 /* CSScaleView.m */; }; 80592C1718939E030082D4E1 /* CSGradientView.m in Sources */ = {isa = PBXBuildFile; fileRef = 80592C1618939E030082D4E1 /* CSGradientView.m */; }; 80629C5E18D4AED600106131 /* libVGAnalytics.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 80629C5B18D4AE8A00106131 /* libVGAnalytics.a */; }; - 80629C6818D4B3BF00106131 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 80629C6718D4B3BF00106131 /* libz.dylib */; }; 807C0B6C1BB3DD4D007D2C03 /* CSIngredientListViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 807C0B6B1BB3DD4D007D2C03 /* CSIngredientListViewCell.m */; }; 80A614DE18BF3D4100A205BB /* CSGlassView.m in Sources */ = {isa = PBXBuildFile; fileRef = 80A614DD18BF3D4100A205BB /* CSGlassView.m */; }; + 80CD77B72B1158A10042B93D /* libz.1.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 80629C6718D4B3BF00106131 /* libz.1.tbd */; }; 931AF96818C2B8AF0018AA8B /* WeightUnits.plist in Resources */ = {isa = PBXBuildFile; fileRef = 931AF96718C2B8AF0018AA8B /* WeightUnits.plist */; }; 931AF96A18C2B9C90018AA8B /* VolumeUnits.plist in Resources */ = {isa = PBXBuildFile; fileRef = 931AF96918C2B9C90018AA8B /* VolumeUnits.plist */; }; 931AF96D18C2BAE50018AA8B /* CSUnitCollection.m in Sources */ = {isa = PBXBuildFile; fileRef = 931AF96C18C2BAE50018AA8B /* CSUnitCollection.m */; }; @@ -113,9 +113,6 @@ 77F41931243950CB0055053E /* ScaleScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScaleScrollView.swift; sourceTree = ""; }; 80433B2C1BB26C1A006B7A85 /* CSRecentsIngredientGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSRecentsIngredientGroup.h; sourceTree = ""; }; 80433B2D1BB26C1A006B7A85 /* CSRecentsIngredientGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSRecentsIngredientGroup.m; sourceTree = ""; }; - 80433B2F1BB27270006B7A85 /* FBSDKCoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBSDKCoreKit.framework; path = CookSmart/FBSDKCoreKit.framework; sourceTree = ""; }; - 80433B301BB27270006B7A85 /* FBSDKLoginKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBSDKLoginKit.framework; path = CookSmart/FBSDKLoginKit.framework; sourceTree = ""; }; - 80433B311BB27270006B7A85 /* FBSDKShareKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBSDKShareKit.framework; path = CookSmart/FBSDKShareKit.framework; sourceTree = ""; }; 80433B351BB2731B006B7A85 /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = ""; }; 80592C0318924B010082D4E1 /* CSIngredients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSIngredients.h; sourceTree = ""; }; 80592C0418924B010082D4E1 /* CSIngredients.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSIngredients.m; sourceTree = ""; }; @@ -128,7 +125,7 @@ 80592C1518939E030082D4E1 /* CSGradientView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSGradientView.h; sourceTree = ""; }; 80592C1618939E030082D4E1 /* CSGradientView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSGradientView.m; sourceTree = ""; }; 80629C5518D4AE8A00106131 /* VGAnalytics.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = VGAnalytics.xcodeproj; path = "../analytics/iOS Analytics/VGAnalytics.xcodeproj"; sourceTree = ""; }; - 80629C6718D4B3BF00106131 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; + 80629C6718D4B3BF00106131 /* libz.1.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.1.tbd; path = ../iPhoneOS.sdk/usr/lib/libz.1.tbd; sourceTree = SDKROOT; }; 807C0B6A1BB3DD4D007D2C03 /* CSIngredientListViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSIngredientListViewCell.h; sourceTree = ""; }; 807C0B6B1BB3DD4D007D2C03 /* CSIngredientListViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSIngredientListViewCell.m; sourceTree = ""; }; 8087757D18C24D1F00A94031 /* CSScaleVCInternals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSScaleVCInternals.h; sourceTree = ""; }; @@ -156,7 +153,6 @@ B7BCA29A180524A800CF7588 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; B7BCA29E180524A800CF7588 /* CookSmart-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CookSmart-Prefix.pch"; sourceTree = ""; }; B7BCA2A2180524A800CF7588 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - B7BCA2A9180524A800CF7588 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; B7BCA2BF1805284A00CF7588 /* Ingredients.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Ingredients.plist; sourceTree = ""; }; DC82F26018AC25B9004FD733 /* CSFilteredIngredientGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSFilteredIngredientGroup.h; sourceTree = ""; }; DC82F26118AC25B9004FD733 /* CSFilteredIngredientGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSFilteredIngredientGroup.m; sourceTree = ""; }; @@ -175,8 +171,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 80629C6818D4B3BF00106131 /* libz.dylib in Frameworks */, 80629C5E18D4AED600106131 /* libVGAnalytics.a in Frameworks */, + 80CD77B72B1158A10042B93D /* libz.1.tbd in Frameworks */, B7BCA293180524A800CF7588 /* CoreGraphics.framework in Frameworks */, B7BCA295180524A800CF7588 /* UIKit.framework in Frameworks */, B7BCA291180524A800CF7588 /* Foundation.framework in Frameworks */, @@ -334,14 +330,10 @@ B7BCA28F180524A800CF7588 /* Frameworks */ = { isa = PBXGroup; children = ( - 80629C6718D4B3BF00106131 /* libz.dylib */, - 80433B2F1BB27270006B7A85 /* FBSDKCoreKit.framework */, - 80433B301BB27270006B7A85 /* FBSDKLoginKit.framework */, - 80433B311BB27270006B7A85 /* FBSDKShareKit.framework */, + 80629C6718D4B3BF00106131 /* libz.1.tbd */, B7BCA290180524A800CF7588 /* Foundation.framework */, B7BCA292180524A800CF7588 /* CoreGraphics.framework */, B7BCA294180524A800CF7588 /* UIKit.framework */, - B7BCA2A9180524A800CF7588 /* XCTest.framework */, ); name = Frameworks; sourceTree = ""; @@ -552,7 +544,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "cd BuildTools\nmint run swiftlint swiftlint --path ${SOURCE_ROOT} --config ./BuildTools/.swiftlint.yml\n"; + shellScript = "cd BuildTools\nmint run swiftlint swiftlint --config ${SOURCE_ROOT}/BuildTools/.swiftlint.yml ${SOURCE_ROOT}\n"; }; 392D864F24301E96002064D6 /* Mint */ = { isa = PBXShellScriptBuildPhase; @@ -874,7 +866,6 @@ "$(inherited)", "@executable_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; MARKETING_VERSION = 1.4.1; OTHER_LDFLAGS = ( "-all_load", @@ -914,7 +905,6 @@ "$(inherited)", "@executable_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; MARKETING_VERSION = 1.4.1; OTHER_CFLAGS = ""; OTHER_LDFLAGS = ( diff --git a/CookSmart/CookSmart/CSIngredients.h b/CookSmart/CookSmart/CSIngredients.h index b4003e7..0355e79 100644 --- a/CookSmart/CookSmart/CSIngredients.h +++ b/CookSmart/CookSmart/CSIngredients.h @@ -14,7 +14,7 @@ @class CSIngredientGroup; @class CSRecentsIngredientGroup; -static inline NSString *pathToIngredientsOnDisk() +static inline NSString *pathToIngredientsOnDisk(void) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSCAssert([paths count] > 0, @"Unable to get the path to the documents directory."); @@ -22,7 +22,7 @@ static inline NSString *pathToIngredientsOnDisk() return [documentsDirectory stringByAppendingPathComponent:@"ingredients.plist"]; } -static inline NSString *pathToIngredientsInBundle() +static inline NSString *pathToIngredientsInBundle(void) { return [[NSBundle mainBundle] pathForResource:@"Ingredients" ofType:@"plist"]; } diff --git a/CookSmart/CookSmart/CSScaleVC.h b/CookSmart/CookSmart/CSScaleVC.h index ad650c9..23f5b29 100644 --- a/CookSmart/CookSmart/CSScaleVC.h +++ b/CookSmart/CookSmart/CSScaleVC.h @@ -20,7 +20,7 @@ @class CSIngredient; @protocol UnitPickerDelegate; -@interface CSScaleVC : UIViewController +@interface CSScaleVC : UIViewController @property (strong, nonatomic) CSIngredient* ingredient; @property (assign, nonatomic) BOOL syncsScales; diff --git a/CookSmart/CookSmart/CSScaleVC.m b/CookSmart/CookSmart/CSScaleVC.m index 2c11e70..1337a38 100644 --- a/CookSmart/CookSmart/CSScaleVC.m +++ b/CookSmart/CookSmart/CSScaleVC.m @@ -19,7 +19,7 @@ #define UNIT_VERTICAL_PADDING 10 #define UNIT_LABEL_SPREAD (150.0) // Unit labels will be spread over that many points -@interface CSScaleVC () +@interface CSScaleVC () @property (weak, nonatomic) IBOutlet UILabel *volumeLabel; @property (weak, nonatomic) IBOutlet UILabel *weightLabel; diff --git a/CookSmart/CookSmart/Core/Fraction.swift b/CookSmart/CookSmart/Core/Fraction.swift index f304ed0..aabd195 100644 --- a/CookSmart/CookSmart/Core/Fraction.swift +++ b/CookSmart/CookSmart/Core/Fraction.swift @@ -23,7 +23,7 @@ enum Fraction: Double, CaseIterable { init(value: Double) { var closestFraction: Fraction = .zero - var smallestDifference: Double = 1.0 + var smallestDifference = 1.0 for fraction in Fraction.allCases { let difference = fabs(fraction.rawValue - value) diff --git a/CookSmart/CookSmart/Core/Label.swift b/CookSmart/CookSmart/Core/Label.swift index c466cb9..5dd265c 100644 --- a/CookSmart/CookSmart/Core/Label.swift +++ b/CookSmart/CookSmart/Core/Label.swift @@ -28,7 +28,7 @@ final class Label: UILabel, StyledView { } struct LabelStyle { - var titleColor: UIColor = UIColor.label + var titleColor: UIColor = .label var font: UIFont = AvenirFont.regular.of(size: 17) static var standard: LabelStyle { diff --git a/CookSmart/CookSmart/Scale View/ScaleScrollView.swift b/CookSmart/CookSmart/Scale View/ScaleScrollView.swift index 0825d5e..40aaf0b 100644 --- a/CookSmart/CookSmart/Scale View/ScaleScrollView.swift +++ b/CookSmart/CookSmart/Scale View/ScaleScrollView.swift @@ -1,5 +1,5 @@ // -// ScaleView.swift +// ScaleScrollView.swift // cake // // Created by Olga Galchenko on 4/4/20. @@ -24,8 +24,7 @@ class ScaleScrollView: UIScrollView { .eraseToAnyPublisher() } - init(unitsPerTile: Int = 1, - mirror: Bool = false) { + init(unitsPerTile: Int = 1, mirror: Bool = false) { self.unitsPerTile = unitsPerTile self.mirror = mirror @@ -267,11 +266,6 @@ struct ScalePreview: PreviewProvider { } struct ScalePreviewContainer: UIViewRepresentable { - init(unitsPerTile: Int, mirror: Bool) { - self.unitsPerTile = unitsPerTile - self.mirror = mirror - } - var unitsPerTile: Int var mirror: Bool diff --git a/CookSmart/CookSmart/Scale View/ScaleTile.swift b/CookSmart/CookSmart/Scale View/ScaleTile.swift index f173528..e75136d 100644 --- a/CookSmart/CookSmart/Scale View/ScaleTile.swift +++ b/CookSmart/CookSmart/Scale View/ScaleTile.swift @@ -78,7 +78,7 @@ class ScaleTile: UIView { // MARK: Private - let valueLabel: Label = Label(style: .tiny) + let valueLabel: Label = .init(style: .tiny) let mirror: Bool private func setUpViews() { @@ -192,10 +192,6 @@ struct ScaleTilePreview: PreviewProvider { } struct TilePreviewContainer: UIViewRepresentable { - init(value: Float, mirror: Bool) { - self.value = value - self.mirror = mirror - } let value: Float let mirror: Bool diff --git a/CookSmart/CookSmart/ScaleView.swift b/CookSmart/CookSmart/ScaleView.swift index beafa85..ac9b779 100644 --- a/CookSmart/CookSmart/ScaleView.swift +++ b/CookSmart/CookSmart/ScaleView.swift @@ -1,5 +1,5 @@ // -// ScalesView.swift +// ScaleView.swift // cake // // Created by Olga Galchenko on 4/12/20. diff --git a/CookSmart/CookSmart/ScaleViewController.swift b/CookSmart/CookSmart/ScaleViewController.swift index 3e89569..bd214f0 100644 --- a/CookSmart/CookSmart/ScaleViewController.swift +++ b/CookSmart/CookSmart/ScaleViewController.swift @@ -59,7 +59,7 @@ class ScaleViewController: UIViewController { private var displayMode: DisplayMode = .scales - private let volumeUnitButton: Button = { + private lazy var volumeUnitButton: Button = { let button = Button() button.setTitleColor(.label, for: .disabled) button.setTitle("Volume", for: .disabled) @@ -67,7 +67,7 @@ class ScaleViewController: UIViewController { return button }() - private let weightUnitButton: Button = { + private lazy var weightUnitButton: Button = { let button = Button() button.setTitleColor(.label, for: .disabled) button.setTitle("Weight", for: .disabled) @@ -121,7 +121,8 @@ class ScaleViewController: UIViewController { @objc private func toggleDisplayMode() { guard let scalesTopConstraint = scalesTopConstraint, - let unitPickerBottomConstraint = unitPickerBottomConstraint else { + let unitPickerBottomConstraint = unitPickerBottomConstraint + else { return } displayMode = (displayMode == .scales) ? .unitPicker : .scales diff --git a/CookSmart/CookSmart/UnitPickerView.swift b/CookSmart/CookSmart/UnitPickerView.swift index b4f9447..7eb31cb 100644 --- a/CookSmart/CookSmart/UnitPickerView.swift +++ b/CookSmart/CookSmart/UnitPickerView.swift @@ -36,7 +36,7 @@ class UnitPickerView: UIView { fatalError("init(coder:) has not been implemented") } - private let doneButton: UIButton = { + private lazy var doneButton: UIButton = { let button = Button() button.setTitle("Done", for: .normal) button.addTarget(self, action: #selector(doneButtonPressed), for: .touchUpInside)