adboco/Unsplasher-SDK

View on GitHub

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
        }
Severity: Minor
Found in Unsplasher/Unsplash/Requests/Requests.swift - About 3 hrs to fix

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
Severity: Minor
Found in Example/ViewController.swift - About 1 hr to fix

    Function loadView has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        override func loadView() {
            super.loadView()
            
            imageView.heroID = imageHeroID
            imageView.image = preloadedImage
    Severity: Minor
    Found in Example/PhotoViewController.swift - About 1 hr to fix

      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
              }
      Severity: Minor
      Found in Unsplasher/Unsplash/Requests/Requests.swift - About 1 hr to fix

        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
        Severity: Minor
        Found in Unsplasher/Unsplash/Requests/CurrentUserRequests.swift - About 1 hr to fix

          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: ",")
                  }
          Severity: Minor
          Found in Unsplasher/Unsplash/Requests/PhotoRequests.swift - About 1 hr to fix

            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) {
            Severity: Major
            Found in Unsplasher/Unsplash/Requests/PhotoRequests.swift - About 1 hr to fix

              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
                      
              Severity: Minor
              Found in Example/ProfileViewController.swift - About 1 hr to fix

                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) {
                Severity: Major
                Found in Unsplasher/Unsplash/Requests/PhotoRequests.swift - About 1 hr to fix

                  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) {
                  Severity: Major
                  Found in Unsplasher/Unsplash/Requests/UserRequests.swift - About 1 hr to fix

                    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
                            }
                            
                    Severity: Minor
                    Found in Example/ViewController.swift - About 55 mins to fix

                    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: ",")
                            }
                    Severity: Minor
                    Found in Unsplasher/Unsplash/Requests/PhotoRequests.swift - About 55 mins to fix

                    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
                    Severity: Minor
                    Found in Example/ViewController.swift - About 55 mins to fix

                    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) {
                    Severity: Major
                    Found in Unsplasher/Unsplash/Requests/Requests.swift - About 50 mins to fix

                      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) {
                      Severity: Major
                      Found in Unsplasher/Unsplash/Requests/Requests.swift - About 50 mins to fix

                        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) {
                        Severity: Major
                        Found in Unsplasher/Unsplash/Requests/CurrentUserRequests.swift - About 50 mins to fix

                          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 {
                          Severity: Minor
                          Found in Unsplasher/Model/Searches.swift - About 45 mins to fix

                          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) {
                          Severity: Minor
                          Found in Unsplasher/Unsplash/Requests/SearchRequests.swift - About 45 mins to fix

                            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
                            Severity: Minor
                            Found in Unsplasher/Unsplash/Requests/CurrentUserRequests.swift - About 45 mins to fix

                            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) {
                            Severity: Minor
                            Found in Unsplasher/Unsplash/Requests/PhotoRequests.swift - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language