Showing 29 of 70 total issues
Function request
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
func request<T: Codable>(url: String, method: HTTPMethod = .get, parameters: Parameters = [:], encoding: URLEncoding = .queryString, includeHeaders: Bool = true, expectedType: T.Type, completion: @escaping (Result<T>) -> Void) {
guard self.applicationID != nil, self.secret != nil else {
completion(.failure(UnsplashError.credentialsError))
return
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function viewDidLoad
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
override func viewDidLoad() {
super.viewDidLoad()
setupView()
// get photos closure
Function loadView
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
override func loadView() {
super.loadView()
imageView.heroID = imageHeroID
imageView.image = preloadedImage
Function request
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
func request<T: Codable>(url: String, method: HTTPMethod = .get, parameters: Parameters = [:], encoding: URLEncoding = .queryString, includeHeaders: Bool = true, expectedType: T.Type, completion: @escaping (Result<T>) -> Void) {
guard self.applicationID != nil, self.secret != nil else {
completion(.failure(UnsplashError.credentialsError))
return
}
Function update
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public func update(_ user: User, completion: @escaping (UserResult) -> Void) {
let requiredScope: Unsplash.PermissionScope = .writeUser
guard self.manager.scopes.contains(requiredScope) else {
completion(.failure(UnsplashError.scopeRequiredError(requiredScope)))
return
Function randomPhotos
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public func randomPhotos(collectionIds: [UInt32]? = nil, featured: Bool? = nil, username: String? = nil, query: String? = nil, width: UInt32? = nil, height: UInt32? = nil, orientation: Unsplash.Orientation? = nil, count: UInt32 = 1, completion: @escaping (PhotoListResult) -> Void) {
var parameters: Parameters = [:]
if let collectionIds = collectionIds {
parameters["collections"] = collectionIds.map({ "\($0)" }).joined(separator: ",")
}
Function randomPhotos
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
public func randomPhotos(collectionIds: [UInt32]? = nil, featured: Bool? = nil, username: String? = nil, query: String? = nil, width: UInt32? = nil, height: UInt32? = nil, orientation: Unsplash.Orientation? = nil, count: UInt32 = 1, completion: @escaping (PhotoListResult) -> Void) {
Function tableView
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "ProfileCell", for: indexPath)
cell.selectionStyle = .none
cell.backgroundColor = UIColor.clear
Function randomPhoto
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public func randomPhoto(collectionIds: [UInt32]? = nil, featured: Bool? = nil, username: String? = nil, query: String? = nil, width: UInt32? = nil, height: UInt32? = nil, orientation: Unsplash.Orientation? = nil, completion: @escaping (PhotoResult) -> Void) {
Function by
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public func by(_ username: String, page: Int? = nil, perPage: Int? = nil, orderBy: Unsplash.OrderBy? = .popular, stats: Bool? = false, resolution: Unsplash.StatisticsResolution? = nil, quantity: UInt32 = 30, completion: @escaping (PhotoListResult) -> Void) {
Function likeAction
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
@IBAction func likeAction(_ sender: LGButton) {
guard sender.tag < photos.count else {
return
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function randomPhotos
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public func randomPhotos(collectionIds: [UInt32]? = nil, featured: Bool? = nil, username: String? = nil, query: String? = nil, width: UInt32? = nil, height: UInt32? = nil, orientation: Unsplash.Orientation? = nil, count: UInt32 = 1, completion: @escaping (PhotoListResult) -> Void) {
var parameters: Parameters = [:]
if let collectionIds = collectionIds {
parameters["collections"] = collectionIds.map({ "\($0)" }).joined(separator: ",")
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function viewDidLoad
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
override func viewDidLoad() {
super.viewDidLoad()
setupView()
// get photos closure
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function search
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
func search(of type: SearchType, query: String, page: UInt32? = nil, perPage: UInt32? = nil, collections: [String]? = nil, orientation: Orientation? = nil, completion: @escaping (SearchResult) -> Void) {
Function request
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
func request<T: Codable>(url: String, method: HTTPMethod = .get, parameters: Parameters = [:], encoding: URLEncoding = .queryString, includeHeaders: Bool = true, expectedType: T.Type, completion: @escaping (Result<T>) -> Void) {
Function get
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public func get(page: Int? = nil, perPage: Int? = nil, orderBy: Unsplash.OrderBy? = .popular, stats: Bool? = false, resolution: Unsplash.StatisticsResolution? = nil, quantity: UInt32 = 30, completion: @escaping (PhotoListResult) -> Void) {
Function encode
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(total, forKey: .total)
try container.encode(totalPages, forKey: .totalPages)
do {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function photos
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public func photos(query: String, page: UInt32? = nil, perPage: UInt32? = nil, collections: [String]? = nil, orientation: Unsplash.Orientation? = nil, completion: @escaping (SearchResult) -> Void) {
Function update
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public func update(_ user: User, completion: @escaping (UserResult) -> Void) {
let requiredScope: Unsplash.PermissionScope = .writeUser
guard self.manager.scopes.contains(requiredScope) else {
completion(.failure(UnsplashError.scopeRequiredError(requiredScope)))
return
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function photos
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public func photos(page: Int? = nil, perPage: Int? = nil, orderBy: Unsplash.OrderBy? = .popular, curated: Bool = false, completion: @escaping (PhotoListResult) -> Void) {