Skip to content

Commit

Permalink
Swiftlint refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoddikko committed Feb 23, 2023
1 parent f4b0615 commit 6c754ad
Show file tree
Hide file tree
Showing 38 changed files with 102 additions and 230 deletions.
Binary file modified .DS_Store
Binary file not shown.
20 changes: 1 addition & 19 deletions YoddChatGpt.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@
7188A77D29A7848F00384404 /* Sources */,
7188A77E29A7848F00384404 /* Frameworks */,
7188A77F29A7848F00384404 /* Resources */,
71ADBD7529A7C3930087BB0B /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -428,24 +427,7 @@
/* Begin PBXShellScriptBuildPhase section */
7157E83E29A7C43A00CDCF7C /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\nif which swiftlint > /dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
71ADBD7529A7C3930087BB0B /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
buildActionMask = 12;
files = (
);
inputFileListPaths = (
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
filePath = "YoddChatGpt/DataModel/DataController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "39"
endingLineNumber = "39"
startingLineNumber = "38"
endingLineNumber = "38"
landmarkName = "save(context:)"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -110,8 +110,8 @@
filePath = "YoddChatGpt/DataModel/DataController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "28"
endingLineNumber = "28"
startingLineNumber = "27"
endingLineNumber = "27"
landmarkName = "DataController"
landmarkType = "3">
</BreakpointContent>
Expand All @@ -126,10 +126,10 @@
filePath = "YoddChatGpt/DataModel/DataController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "30"
endingLineNumber = "30"
landmarkName = "init()"
landmarkType = "7">
startingLineNumber = "29"
endingLineNumber = "29"
landmarkName = "DataController"
landmarkType = "3">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand All @@ -142,8 +142,8 @@
filePath = "YoddChatGpt/DataModel/DataController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "32"
endingLineNumber = "32"
startingLineNumber = "31"
endingLineNumber = "31"
landmarkName = "init()"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -158,10 +158,10 @@
filePath = "YoddChatGpt/DataModel/DataController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "29"
endingLineNumber = "29"
landmarkName = "DataController"
landmarkType = "3">
startingLineNumber = "28"
endingLineNumber = "28"
landmarkName = "shared"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand Down Expand Up @@ -222,8 +222,8 @@
filePath = "YoddChatGpt/ViewModel/ThemeViewModel.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "50"
endingLineNumber = "50"
startingLineNumber = "48"
endingLineNumber = "48"
landmarkName = "init()"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -238,8 +238,8 @@
filePath = "YoddChatGpt/DataModel/DataController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "67"
endingLineNumber = "67"
startingLineNumber = "65"
endingLineNumber = "65"
landmarkName = "saveMessage(message:context:)"
landmarkType = "7">
</BreakpointContent>
Expand Down Expand Up @@ -334,8 +334,8 @@
filePath = "YoddChatGpt/View/Chat/BotMessageBubble.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "42"
endingLineNumber = "42"
startingLineNumber = "41"
endingLineNumber = "41"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
Expand Down Expand Up @@ -366,8 +366,8 @@
filePath = "YoddChatGpt/View/Settings/ModelTypesList/ChatGPTSwiftModelTypesList.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "28"
endingLineNumber = "28"
startingLineNumber = "27"
endingLineNumber = "27"
landmarkName = "ChatGPTSwiftModelTypesList"
landmarkType = "14">
<Locations>
Expand Down Expand Up @@ -537,8 +537,8 @@
filePath = "YoddChatGpt/Extensions/NSManagedObjectContext+extension.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "35"
endingLineNumber = "35"
startingLineNumber = "34"
endingLineNumber = "34"
landmarkName = "NSManagedObjectContext"
landmarkType = "21">
</BreakpointContent>
Expand All @@ -553,8 +553,8 @@
filePath = "YoddChatGpt/View/Chat/ChatView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "143"
endingLineNumber = "143"
startingLineNumber = "138"
endingLineNumber = "138"
landmarkName = "sendFromKeyboard()"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -569,8 +569,8 @@
filePath = "YoddChatGpt/View/Settings/SettingsView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "133"
endingLineNumber = "133"
startingLineNumber = "128"
endingLineNumber = "128"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
Expand Down
Binary file modified YoddChatGpt/.DS_Store
Binary file not shown.
24 changes: 10 additions & 14 deletions YoddChatGpt/DataModel/DataController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ The MIT License (MIT)
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


//
// DataController.swift
// YoddChatGpt
Expand All @@ -22,31 +21,30 @@ import Foundation
import CoreData

//Multiple NSEntityDescriptions claim the NSManagedObject subclass 'Message' so +entity is unable to disambiguate
class DataController : ObservableObject {
class DataController: ObservableObject {
let container = NSPersistentContainer(name: "MessageModel")

static let shared = DataController()

init() {
container.loadPersistentStores { desc, error in
if let error = error {
// swiftlint:disable:next no_direct_standard_out_logs
print("ERROR >>> Failed to load the data \(error.localizedDescription)")
}
}
}


func save(context: NSManagedObjectContext) {
do {
try context.save()
// print("Data saved")
} catch {
print("ERROR >>> Data couldn't be saved")
// print("ERROR >>> Data couldn't be saved")
}
}


func addMessage (body : String, sender: String, type : String, context : NSManagedObjectContext) {
func addMessage (body: String, sender: String, type: String, context: NSManagedObjectContext) {
let message = Message(context: context)
message.date = Date()
message.body = body
Expand All @@ -63,7 +61,7 @@ class DataController : ObservableObject {
save(context: context)
}

func saveMessage (message: Message, context : NSManagedObjectContext) {
func saveMessage (message: Message, context: NSManagedObjectContext) {
if message.saved == false {
message.saved = true
} else {
Expand All @@ -72,24 +70,24 @@ class DataController : ObservableObject {
save(context: context)
}


func deleteData (context : NSManagedObjectContext, message : Message) {
func deleteData (context: NSManagedObjectContext, message: Message) {
context.delete(message)
}

func deleteAllData (context : NSManagedObjectContext) {
func deleteAllData (context: NSManagedObjectContext) {
let fetchRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest(entityName: "Message")
let deleteRequest = NSBatchDeleteRequest(fetchRequest: fetchRequest)

do {
try context.executeAndMergeChanges(using: deleteRequest)
} catch let error as NSError {
// swiftlint:disable:next no_direct_standard_out_logs
print(error)
// TODO: handle the error
}
}

func deleteAllUnsavedData (context : NSManagedObjectContext) {
func deleteAllUnsavedData (context: NSManagedObjectContext) {
let fetchRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest(entityName: "Message")
fetchRequest.predicate = NSPredicate(format: "saved == %@", "\(false)")

Expand All @@ -98,11 +96,9 @@ class DataController : ObservableObject {
do {
try context.executeAndMergeChanges(using: deleteRequest)
} catch let error as NSError {
// swiftlint:disable:next no_direct_standard_out_logs
print(error)
// TODO: handle the error

}
}


}
3 changes: 1 addition & 2 deletions YoddChatGpt/Extensions/Color+extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ The MIT License (MIT)

import SwiftUI


extension Color {
init(hex: String) {
let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
Expand All @@ -41,7 +40,7 @@ extension Color {
.sRGB,
red: Double(r) / 255,
green: Double(g) / 255,
blue: Double(b) / 255,
blue: Double(b) / 255,
opacity: Double(a) / 255
)
}
Expand Down
4 changes: 0 additions & 4 deletions YoddChatGpt/Extensions/NSManagedObjectContext+extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ The MIT License (MIT)
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


//
// NSManagedObjectContext+extension.swift
// YoddChatGpt
Expand All @@ -33,6 +32,3 @@ extension NSManagedObjectContext {
NSManagedObjectContext.mergeChanges(fromRemoteContextSave: changes, into: [self])
}
}



1 change: 0 additions & 1 deletion YoddChatGpt/Extensions/View+extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ The MIT License (MIT)
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


//
// View+extension.swift
// YoddChatGpt
Expand Down
7 changes: 3 additions & 4 deletions YoddChatGpt/Model/Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ The MIT License (MIT)
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


//
// Message.swift
// YoddChatGpt
Expand All @@ -20,9 +19,9 @@ The MIT License (MIT)

import Foundation

struct TemporaryMessage : Hashable {
var body : String
var sender : Sender
struct TemporaryMessage: Hashable {
var body: String
var sender: Sender
var timeStamp = Date()
var id = UUID()

Expand Down
1 change: 0 additions & 1 deletion YoddChatGpt/Model/Shapes/RoundedCorner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ The MIT License (MIT)
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


//
// RoundedCorner.swift
// YoddChatGpt
Expand Down
Binary file modified YoddChatGpt/View/.DS_Store
Binary file not shown.
Binary file added YoddChatGpt/View/Chat/.DS_Store
Binary file not shown.
9 changes: 2 additions & 7 deletions YoddChatGpt/View/Chat/BotLoadingMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ The MIT License (MIT)
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


//
// BotLoadingMessage.swift
// YoddChatGpt
Expand All @@ -28,7 +27,7 @@ struct BotLoadingMessage: View {

@State var scale = 0.8

var secondaryColor : Color
var secondaryColor: Color

var body: some View {
HStack {
Expand All @@ -47,7 +46,7 @@ struct BotLoadingMessage: View {

Circle()
.foregroundColor(.secondary)
.frame(width: 5, height: 5)
.frame(width: 5, height: 5)
.scaleEffect(scale2)
.onAppear {
let baseAnimation = Animation.easeInOut(duration: 1)
Expand All @@ -70,10 +69,6 @@ struct BotLoadingMessage: View {
scale3 = 0.5
}
}




}
.padding(.trailing, 30)
.padding(.vertical, 10)
Expand Down
Loading

0 comments on commit 6c754ad

Please sign in to comment.