Skip to content
Permalink
Browse files

make swiftlint happier (no more showstoppers)

  • Loading branch information...
amiantos committed Nov 22, 2018
1 parent 2a481d2 commit 8ce96ae32a31dae1d51d2a105aac6bb9d32c031b
Showing with 385 additions and 370 deletions.
  1. +0 −3 .swiftlint.yml
  2. +12 −12 Numu Tracker/AppDelegate.swift
  3. +1 −1 Numu Tracker/Classes/Interface/NumuUIButton.swift
  4. +1 −1 Numu Tracker/Info.plist
  5. +6 −6 Numu Tracker/Operations/AsyncOperation.swift
  6. +13 −11 Numu Tracker/Operations/Auth/AuthOperation.swift
  7. +2 −2 Numu Tracker/Operations/Auth/GetCKUserOperation.swift
  8. +6 −6 Numu Tracker/Operations/FetchJSONOperation.swift
  9. +16 −16 Numu Tracker/Operations/ImportAppleMusicOperation.swift
  10. +23 −23 Numu Tracker/Operations/ImportSpotifyOperation.swift
  11. +13 −13 Numu Tracker/Views/Modals/Alert/NumuAlertView.swift
  12. +61 −55 Numu Tracker/Views/Modals/Release Details/ReleaseDetailsViewController.swift
  13. +1 −3 Numu Tracker/Views/Modals/Release Details/Rows/ListenAMTableViewCell.swift
  14. +8 −8 Numu Tracker/Views/Modals/Release Details/Rows/ListenSpotifyTableViewCell.swift
  15. +5 −5 Numu Tracker/Views/Modals/Release Details/Rows/MoreReleasesTableViewCell.swift
  16. +1 −1 Numu Tracker/Views/Modals/Release Details/Rows/NumuModalButton.swift
  17. +6 −6 Numu Tracker/Views/Modals/Release Details/Rows/SearchSoundCloudTableViewCell.swift
  18. +5 −5 Numu Tracker/Views/Modals/Release Details/Rows/SearchYouTubeTableViewCell.swift
  19. +12 −12 Numu Tracker/Views/Modals/Sort/NumuSortView.swift
  20. +5 −5 Numu Tracker/Views/artistreleases/ArtistReleaseTableViewCell.swift
  21. +45 −38 Numu Tracker/Views/artistreleases/ArtistReleasesTableViewController.swift
  22. +42 −38 Numu Tracker/Views/artists/ArtistsTableViewController.swift
  23. +28 −27 Numu Tracker/Views/releases/AllReleasesTableViewController.swift
  24. +8 −8 Numu Tracker/Views/releases/ReleaseTableViewCell.swift
  25. +2 −2 Numu Tracker/Views/settings/HelpViewController.swift
  26. +2 −2 Numu Tracker/Views/settings/Import Artists/ImportSpotifyViewController.swift
  27. +8 −8 Numu Tracker/Views/settings/MusicServicesViewController.swift
  28. +8 −8 Numu Tracker/Views/settings/ReleaseFiltersViewController.swift
  29. +11 −11 Numu Tracker/Views/settings/Spotify Login/LoginSpotifyViewController.swift
  30. +1 −1 Numu Tracker/Views/settings/StatsViewController.swift
  31. +5 −5 Numu Tracker/backend/Extensions.swift
  32. +4 −4 Numu Tracker/backend/NumuAPI.swift
  33. +12 −12 Numu Tracker/backend/NumuClient.swift
  34. +7 −7 Numu Tracker/backend/NumuCredential.swift
  35. +5 −5 Numu Tracker/backend/NumuReviewHelper.swift
@@ -1,6 +1,3 @@
disabled_rules:
- trailing_whitespace
- force_cast
opt_in_rules:
- empty_count
- empty_string
@@ -25,34 +25,34 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

// Development
//let pusher = Pusher(key: "")
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

Fabric.with([Crashlytics.self])

NumuReviewHelper.incrementActivityCount()

let redirectURL: URL = URL(string: "numu://")!
SpotifyLogin.shared.configure(clientID: "SPOTIFY_CLIENT_ID", clientSecret: "SPOTIFY_CLIENT_SECRET", redirectURL: redirectURL)

NotificationCenter.default.addObserver(
self, selector: #selector(self.runLogInOperations), name: .LoggedOut, object: nil)

NotificationCenter.default.addObserver(
self, selector: #selector(self.ckDataChange), name: Notification.Name.CKAccountChanged, object: nil)

runLogInOperations()

return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
let handled = SpotifyLogin.shared.applicationOpenURL(url) { (error) in }

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
let handled = SpotifyLogin.shared.applicationOpenURL(url) { (_) in }
return handled
}

@objc func ckDataChange() {
// Need to re-run authorization procedure here.
runLogInOperations()
@@ -93,14 +93,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

@objc fileprivate func runLogInOperations() {
let queue = OperationQueue()

// Get and store CK record ID if available
let getCKUserOperation = GetCKUserOperation()
// If user account exists already, link it to CK or create new account
let registerWithCKOperation = RegisterWithCKOperation()
// Try to auth with any credentials
let authOperation = AuthOperation()

registerWithCKOperation.addDependency(getCKUserOperation)
authOperation.addDependency(registerWithCKOperation)
authOperation.completionBlock = {
@@ -15,5 +15,5 @@ class NumuUIButton: UIButton {
self.backgroundColor = isHighlighted ? .black : .clear
}
}

}
@@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>817</string>
<string>837</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
@@ -12,11 +12,11 @@ class AsyncOperation: Operation {
enum State: String {
case isReady, isExecuting, isFinished
}

override var isAsynchronous: Bool {
return true
}

var state = State.isReady {
willSet {
willChangeValue(forKey: state.rawValue)
@@ -27,21 +27,21 @@ class AsyncOperation: Operation {
didChangeValue(forKey: state.rawValue)
}
}

override var isExecuting: Bool {
return state == .isExecuting
}

override var isFinished: Bool {
return state == .isFinished
}

override func start() {
guard !self.isCancelled else {
state = .isFinished
return
}

state = .isExecuting
main()
}
@@ -11,7 +11,7 @@ import UIKit
import Crashlytics

class AuthOperation: AsyncOperation {

let queue = OperationQueue()

override func main() {
@@ -42,24 +42,26 @@ class AuthOperation: AsyncOperation {
self.showLogRegPrompt()
}
}

func sendNotifcations() {
DispatchQueue.main.async(execute: {
NotificationCenter.default.post(name: .LoggedIn, object: self)
NotificationCenter.default.post(name: .UpdatedArtists, object: self)
})
}

func showLogRegPrompt() {
let loginViewController = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(
withIdentifier: "LogRegPrompt") as! UINavigationController
DispatchQueue.main.async {
if let appDelegate = UIApplication.shared.delegate,
let appWindow = appDelegate.window!,
let rootViewController = appWindow.rootViewController {
rootViewController.present(loginViewController, animated: false, completion: nil)
if let loginViewController = UIStoryboard(name: "Main", bundle: Bundle.main)
.instantiateViewController(withIdentifier: "LogRegPrompt") as? UINavigationController {
DispatchQueue.main.async {
if let appDelegate = UIApplication.shared.delegate,
let appWindow = appDelegate.window!,
let rootViewController = appWindow.rootViewController {
rootViewController.present(loginViewController, animated: false, completion: nil)
}
}
} else {
// Display error message?
}
}

}
@@ -10,7 +10,7 @@ import Foundation
import CloudKit

class GetCKUserOperation: AsyncOperation {

override func main() {
print("Running CKUserRecordIDOperation..")
if UserDefaults.standard.string(forKey: "userRecordID") == nil {
@@ -28,5 +28,5 @@ class GetCKUserOperation: AsyncOperation {
self.state = .isFinished
}
}

}
@@ -10,25 +10,25 @@ import Foundation
import SwiftyJSON

final class FetchOperation: AsyncOperation {

private(set) var dataFetched: Data?

private let session = URLSession(configuration: .default)
private var dataTask: URLSessionDataTask?
private var url: String
public var json: JSON

init(_ url: String) {
self.url = url
self.json = JSON.null
}

override func main() {

let url = URL(string: self.url)!
dataTask = session.dataTask(with: url) {[unowned self] (data, _, _) in
guard let data = data else { return }

do {
self.json = try JSON(data: data)
} catch {
@@ -12,19 +12,19 @@ import UIKit
import Crashlytics

class ImportAppleMusicOperation: AsyncOperation {

private let session = URLSession(configuration: .default)
private var dataTask: URLSessionDataTask?

var artistsImported: Int = 0

override func main() {
print("Running ImportAppleMusicOperation...")
if !defaults.logged {
self.state = .isFinished
return
}

MPMediaLibrary.requestAuthorization { (status) in
if status == .authorized {
self.runImportArtists()
@@ -34,7 +34,7 @@ class ImportAppleMusicOperation: AsyncOperation {
}
}
}

func runImportArtists() {
// Build list of artists to be imported.
let query = MPMediaQuery.artists()
@@ -49,25 +49,25 @@ class ImportAppleMusicOperation: AsyncOperation {
}
let uniques = Array(Set(artistsFound))
let json = ["artists": uniques]

do {
let jsonData = try JSONSerialization.data(withJSONObject: json, options: .prettyPrinted)

// create post request
let url = URL(string: "https://www.numutracker.com/v2/json.php?import")!
let request = NSMutableURLRequest(url: url)
request.httpMethod = "POST"

// insert json data to the request
request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
request.httpBody = jsonData

dataTask = session.dataTask(with: request as URLRequest) {[unowned self] (data, _, error) in
guard let data = data else { return }
do {
if let returnedJSON = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
if let success = returnedJSON["success"] {
self.artistsImported = success as! Int
if let success = returnedJSON["success"] as? Int {
self.artistsImported = success
NumuReviewHelper.incrementAndAskForReview()
self.displaySuccessMessage()
DispatchQueue.main.async(execute: {
@@ -83,16 +83,16 @@ class ImportAppleMusicOperation: AsyncOperation {
print(self.artistsImported)
self.state = .isFinished
}

dataTask?.resume()

} catch {
print(error.localizedDescription)
self.state = .isFinished
}

}

func displaySuccessMessage() {
DispatchQueue.main.async {
let alertView = NumuAlertView()
@@ -108,7 +108,7 @@ class ImportAppleMusicOperation: AsyncOperation {
}
}
}

func displayAMError() {
var error: String
switch MPMediaLibrary.authorizationStatus() {

0 comments on commit 8ce96ae

Please sign in to comment.
You can’t perform that action at this time.