Skip to content

Commit

Permalink
General hygiene
Browse files Browse the repository at this point in the history
* Revved Swiftlint and Swiftformat
* Fixed the associated build phase invocations
* Fixed swiftlint and swiftformat rule definitions
* Fixed linting issues in the code
  • Loading branch information
vovagalchenko committed Nov 25, 2023
1 parent 93c909b commit 77adfdc
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 43 deletions.
1 change: 1 addition & 0 deletions CookSmart/.swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
# Disabled Rules

--disable blankLinesAtStartOfScope
--disable wrapMultilineStatementBraces
2 changes: 1 addition & 1 deletion CookSmart/BuildTools/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions CookSmart/BuildTools/Mintfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nicklockwood/SwiftFormat@0.44.7
realm/SwiftLint@0.39.1
nicklockwood/SwiftFormat@0.52.10
realm/SwiftLint@0.53.0
2 changes: 1 addition & 1 deletion CookSmart/CakeTests/DoubleStringUtilsTests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// DoubleUtilsTests.swift
// DoubleStringUtilsTests.swift
// cake
//
// Created by Olga Galchenko on 4/11/20.
Expand Down
20 changes: 5 additions & 15 deletions CookSmart/CookSmart.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -113,9 +113,6 @@
77F41931243950CB0055053E /* ScaleScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScaleScrollView.swift; sourceTree = "<group>"; };
80433B2C1BB26C1A006B7A85 /* CSRecentsIngredientGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSRecentsIngredientGroup.h; sourceTree = "<group>"; };
80433B2D1BB26C1A006B7A85 /* CSRecentsIngredientGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSRecentsIngredientGroup.m; sourceTree = "<group>"; };
80433B2F1BB27270006B7A85 /* FBSDKCoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBSDKCoreKit.framework; path = CookSmart/FBSDKCoreKit.framework; sourceTree = "<group>"; };
80433B301BB27270006B7A85 /* FBSDKLoginKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBSDKLoginKit.framework; path = CookSmart/FBSDKLoginKit.framework; sourceTree = "<group>"; };
80433B311BB27270006B7A85 /* FBSDKShareKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBSDKShareKit.framework; path = CookSmart/FBSDKShareKit.framework; sourceTree = "<group>"; };
80433B351BB2731B006B7A85 /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = "<group>"; };
80592C0318924B010082D4E1 /* CSIngredients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSIngredients.h; sourceTree = "<group>"; };
80592C0418924B010082D4E1 /* CSIngredients.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSIngredients.m; sourceTree = "<group>"; };
Expand All @@ -128,7 +125,7 @@
80592C1518939E030082D4E1 /* CSGradientView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSGradientView.h; sourceTree = "<group>"; };
80592C1618939E030082D4E1 /* CSGradientView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSGradientView.m; sourceTree = "<group>"; };
80629C5518D4AE8A00106131 /* VGAnalytics.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = VGAnalytics.xcodeproj; path = "../analytics/iOS Analytics/VGAnalytics.xcodeproj"; sourceTree = "<group>"; };
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 = "<group>"; };
807C0B6B1BB3DD4D007D2C03 /* CSIngredientListViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSIngredientListViewCell.m; sourceTree = "<group>"; };
8087757D18C24D1F00A94031 /* CSScaleVCInternals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSScaleVCInternals.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -156,7 +153,6 @@
B7BCA29A180524A800CF7588 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
B7BCA29E180524A800CF7588 /* CookSmart-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CookSmart-Prefix.pch"; sourceTree = "<group>"; };
B7BCA2A2180524A800CF7588 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
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 = "<group>"; };
DC82F26018AC25B9004FD733 /* CSFilteredIngredientGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSFilteredIngredientGroup.h; sourceTree = "<group>"; };
DC82F26118AC25B9004FD733 /* CSFilteredIngredientGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSFilteredIngredientGroup.m; sourceTree = "<group>"; };
Expand All @@ -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 */,
Expand Down Expand Up @@ -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 = "<group>";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -874,7 +866,6 @@
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
MARKETING_VERSION = 1.4.1;
OTHER_LDFLAGS = (
"-all_load",
Expand Down Expand Up @@ -914,7 +905,6 @@
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
MARKETING_VERSION = 1.4.1;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = (
Expand Down
4 changes: 2 additions & 2 deletions CookSmart/CookSmart/CSIngredients.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
@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.");
NSString *documentsDirectory = paths[0];
return [documentsDirectory stringByAppendingPathComponent:@"ingredients.plist"];
}

static inline NSString *pathToIngredientsInBundle()
static inline NSString *pathToIngredientsInBundle(void)
{
return [[NSBundle mainBundle] pathForResource:@"Ingredients" ofType:@"plist"];
}
Expand Down
2 changes: 1 addition & 1 deletion CookSmart/CookSmart/CSScaleVC.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@class CSIngredient;
@protocol UnitPickerDelegate;
@interface CSScaleVC : UIViewController <UIScrollViewDelegate, UIActionSheetDelegate, UnitPickerDelegate>
@interface CSScaleVC : UIViewController <UIScrollViewDelegate, UIActionSheetDelegate>

@property (strong, nonatomic) CSIngredient* ingredient;
@property (assign, nonatomic) BOOL syncsScales;
Expand Down
2 changes: 1 addition & 1 deletion CookSmart/CookSmart/CSScaleVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 () <UnitPickerDelegate>

@property (weak, nonatomic) IBOutlet UILabel *volumeLabel;
@property (weak, nonatomic) IBOutlet UILabel *weightLabel;
Expand Down
2 changes: 1 addition & 1 deletion CookSmart/CookSmart/Core/Fraction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion CookSmart/CookSmart/Core/Label.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 2 additions & 8 deletions CookSmart/CookSmart/Scale View/ScaleScrollView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ScaleView.swift
// ScaleScrollView.swift
// cake
//
// Created by Olga Galchenko on 4/4/20.
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions CookSmart/CookSmart/Scale View/ScaleTile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CookSmart/CookSmart/ScaleView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ScalesView.swift
// ScaleView.swift
// cake
//
// Created by Olga Galchenko on 4/12/20.
Expand Down
7 changes: 4 additions & 3 deletions CookSmart/CookSmart/ScaleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ 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)
button.addTarget(self, action: #selector(toggleDisplayMode), for: .touchUpInside)
return button
}()

private let weightUnitButton: Button = {
private lazy var weightUnitButton: Button = {
let button = Button()
button.setTitleColor(.label, for: .disabled)
button.setTitle("Weight", for: .disabled)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CookSmart/CookSmart/UnitPickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 77adfdc

Please sign in to comment.