Function multipartFormData
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
class func multipartFormData(
_ multipartForm: MultipartFormData,
params: Any,
rootKey: String
) {
Function handleCustomError
has 30 lines of code (exceeds 25 allowed). Consider refactoring.
class func handleCustomError(_ code: Int?, dictionary: [String: Any]) -> NSError? {
if
let messageDict = dictionary["errors"] as? [String: [String]],
let firstKey = messageDict.keys.first
{
Similar blocks of code found in 2 locations. Consider refactoring.
func attachVertically(
to view: UIView,
topMargin: CGFloat = UI.Defaults.margin,
bottomMargin: CGFloat = UI.Defaults.margin
) {
Similar blocks of code found in 2 locations. Consider refactoring.
func attachHorizontally(
to view: UIView,
leadingMargin: CGFloat = UI.Defaults.margin,
trailingMargin: CGFloat = UI.Defaults.margin
) {
Similar blocks of code found in 2 locations. Consider refactoring.
func centerHorizontally(
with view: UIView,
withOffset offset: CGFloat = 0
) {
centerXAnchor.constraint(
Similar blocks of code found in 2 locations. Consider refactoring.
func centerVertically(
with view: UIView,
withOffset offset: CGFloat = 0
) {
centerYAnchor.constraint(
Function validateSerializationErrors
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
fileprivate class func validateSerializationErrors(
response: HTTPURLResponse,
error: Error?,
data: Data,
success: @escaping SuccessCallback,
Line should be 90 characters or less: currently 117 characters
try! fileManager.moveItem(at: self, to: URL(fileURLWithPath: newName, relativeTo: deletingLastPathComponent()))
Force tries should be avoided.
try! fileManager.moveItem(at: self, to: URL(fileURLWithPath: newName, relativeTo: deletingLastPathComponent()))
Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning.
left = left + right
Line should be 90 characters or less: currently 108 characters
let result = prompt(message: "\(step.rawValue). " + step.question + " (leave blank for \(defaultValue)).")
Force unwrapping should be avoided.
return answer == nil || answer == "" ? nil : answer!
Force unwrapping should be avoided.
let enumerator = fileManager.enumerator(at: URL(fileURLWithPath: currentFolder), includingPropertiesForKeys: [.nameKey, .isDirectoryKey])!
Line should be 90 characters or less: currently 96 characters
return userDataManager.currentUser != nil && sessionManager.currentSession?.isValid ?? false
Line should be 90 characters or less: currently 91 characters
static let shared = AppNavigator(isLoggedIn: SessionManager.shared.currentSession != nil)
Line should be 90 characters or less: currently 138 characters
let enumerator = fileManager.enumerator(at: URL(fileURLWithPath: currentFolder), includingPropertiesForKeys: [.nameKey, .isDirectoryKey])!
Line should be 90 characters or less: currently 94 characters
let image = MultipartMedia(fileName: "\(email)_image", key: "user[avatar]", data: picData)
Force tries should be avoided.
try! updatedContent.write(to: self, atomically: true, encoding: .utf8)