filestack/filestack-swift

View on GitHub

Showing 70 of 260 total issues

File TransformableTests.swift has 1267 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import OHHTTPStubs
import OHHTTPStubsSwift
import XCTest

@testable import FilestackSDK
Severity: Major
Found in Tests/FilestackSDKTests/TransformableTests.swift - About 3 days to fix

    TransformableTests has 117 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class TransformableTests: XCTestCase {
        private let processStubConditions = isScheme(Constants.cdnURL.scheme!) && isHost(Constants.cdnURL.host!)
        private let client = Client(apiKey: "My-API-KEY")
    
        private var transformable: Transformable!
    Severity: Major
    Found in Tests/FilestackSDKTests/TransformableTests.swift - About 2 days to fix

      File FileLinkTests.swift has 496 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import OHHTTPStubs
      import OHHTTPStubsSwift
      import XCTest
      @testable import FilestackSDK
      
      
      Severity: Minor
      Found in Tests/FilestackSDKTests/FileLinkTests.swift - About 7 hrs to fix

        File UploadTests.swift has 431 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import OHHTTPStubs
        import OHHTTPStubsSwift
        import XCTest
        @testable import FilestackSDK
        
        
        Severity: Minor
        Found in Tests/FilestackSDKTests/UploadTests.swift - About 6 hrs to fix

          Function submitChunk has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              func submitChunk(chunkOffset: UInt64, chunkSize: Int, retries: Int = Defaults.maxRetries) -> SubmitChunkUploadOperation? {
                  guard !isCancelled else { return nil }
          
                  guard retries > 0 else {
                      finish(with: .failure(.custom("Exceeded max retries trying to submit data chunk.")))

          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 testChainedTransformationsURLWithExternalURL has 88 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              func testChainedTransformationsURLWithExternalURL() {
                  let security = Seeds.Securities.basic
                  let client = Client(apiKey: "MY-API-KEY", security: security)
          
                  let transformable = client.transformable(externalURL: URL(string: "https://SOME-EXTERNAL-URL/photo.jpg")!)
          Severity: Major
          Found in Tests/FilestackSDKTests/TransformableTests.swift - About 3 hrs to fix

            Function testChainedTransformationsURL has 87 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                func testChainedTransformationsURL() {
                    let security = Seeds.Securities.basic
                    let client = Client(apiKey: "MY-API-KEY", security: security)
            
                    let transformable = client.transformable(handle: "MY-HANDLE")
            Severity: Major
            Found in Tests/FilestackSDKTests/TransformableTests.swift - About 3 hrs to fix

              FileLinkTests has 25 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class FileLinkTests: XCTestCase {
                  private let cdnStubConditions = isScheme(Constants.cdnURL.scheme!) && isHost(Constants.cdnURL.host!)
                  private let apiStubConditions = isScheme(Constants.apiURL.scheme!) && isHost(Constants.apiURL.host!)
              
                  private let downloadsDirectoryURL = try! FileManager.default.url(for: .downloadsDirectory,
              Severity: Minor
              Found in Tests/FilestackSDKTests/FileLinkTests.swift - About 2 hrs to fix

                Function enqueue has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    func enqueue(operations: [SubmitPartUploadOperation]) {
                        var partsAndEtags: [Int: String] = [:]
                
                        var completeCount = 0
                
                

                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 tasksToURLFragment has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    func tasksToURLFragment() -> String {
                        let tasks: [String] = transformationTasks.map {
                            if let options = $0.options {
                                let params: [String] = options.map {
                                    switch $0.value {
                Severity: Minor
                Found in Sources/FilestackSDK/Public/Models/Transformable.swift - About 2 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 download has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    @objc func download(destinationURL: URL,
                                        parameters: [String: Any]? = nil,
                                        queue: DispatchQueue? = .main,
                                        downloadProgress: ((Progress) -> Void)? = nil,
                                        completionHandler: @escaping (DownloadResponse) -> Void) {
                Severity: Minor
                Found in Sources/FilestackSDK/Public/Models/FileLink.swift - About 1 hr to fix

                  Function testStoreImageTransformation has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      func testStoreImageTransformation() {
                          stub(condition: processStubConditions) { _ in
                  
                              let json: [String: Any] = [
                                  "container": "filestack-web-demo",
                  Severity: Minor
                  Found in Tests/FilestackSDKTests/TransformableTests.swift - About 1 hr to fix

                    Function testVideoConvertTransformationURL has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        func testVideoConvertTransformationURL() {
                            transformable.add(transform: AVTransform()
                                .preset("h264")
                                .force(false)
                                .width(1080)
                    Severity: Minor
                    Found in Tests/FilestackSDKTests/TransformableTests.swift - About 1 hr to fix

                      Function upload has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          func upload() {
                              guard let uploadables = uploadables else { return }
                      
                              config.currentUploaders.append(self)
                              state = .inProgress
                      Severity: Minor
                      Found in Sources/FilestackSDK/Internal/Uploaders/MultipartUpload.swift - About 1 hr to fix

                        Function testGetMetadata has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            func testGetMetadata() {
                                stub(condition: cdnStubConditions) { _ in
                                    let headers = ["Content-Type": "application/json"]
                        
                                    let returnedJSON: [String: Any] = [
                        Severity: Minor
                        Found in Tests/FilestackSDKTests/FileLinkTests.swift - About 1 hr to fix

                          Function testDownloadExistingContent has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              func testDownloadExistingContent() {
                                  stub(condition: cdnStubConditions) { _ in
                                      let stubPath = Helpers.url(forResource: "sample", withExtension: "jpg", subdirectory: "Fixtures")!.path
                          
                                      let httpHeaders: [AnyHashable: Any] = [
                          Severity: Minor
                          Found in Tests/FilestackSDKTests/FileLinkTests.swift - About 1 hr to fix

                            Function upload has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                func upload() {
                                    // Step 1) Execute start operation
                                    executeStartOperation { (result) in
                                        switch result {
                                        case let .success(descriptor):
                            Severity: Minor
                            Found in Sources/FilestackSDK/Internal/Operations/UploadOperation.swift - About 1 hr 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 submitChunk has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                func submitChunk(chunkOffset: UInt64, chunkSize: Int, retries: Int = Defaults.maxRetries) -> SubmitChunkUploadOperation? {
                                    guard !isCancelled else { return nil }
                            
                                    guard retries > 0 else {
                                        finish(with: .failure(.custom("Exceeded max retries trying to submit data chunk.")))

                              Function testMultiPartUploadWithWorkflowsAndUploadTags has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  func testMultiPartUploadWithWorkflowsAndUploadTags() {
                                      var hitCount = 0
                                      let workflows = ["workflow-1", "workflow-2", "workflow-3"]
                                      let uploadTags = ["key1": "value1", "key2": "value2"]
                                      let storeOptions = StorageOptions(location: .s3, workflows: workflows)
                              Severity: Minor
                              Found in Tests/FilestackSDKTests/UploadTests.swift - About 1 hr to fix

                                Function store has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    @objc
                                    @discardableResult
                                    func store(using options: StorageOptions,
                                               base64Decode: Bool = false,
                                               queue: DispatchQueue? = .main,
                                Severity: Minor
                                Found in Sources/FilestackSDK/Public/Models/Transformable.swift - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language