filestack/filestack-swift

View on GitHub

Showing 70 of 260 total issues

Function upload has a Cognitive Complexity of 11 (exceeds 5 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

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

    @discardableResult
    func upload(data: Data,
                to url: URL,
                method: String,
                headers: [String: String]? = nil,
Severity: Minor
Found in Sources/FilestackSDK/Internal/Services/UploadService.swift - About 1 hr to fix

    Function handleResponse has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        func handleResponse(response: JSONResponse) {
            // Ensure that there's a response and JSON payload or fail.
            guard let json = response.json else {
                finish(with: .failure(.custom("Unable to obtain JSON from /multipart/start response.")))
                return
    Severity: Minor
    Found in Sources/FilestackSDK/Internal/Operations/StartUploadOperation.swift - About 1 hr to fix

      Function testMinifyJSTransformationWithOptionalsURL has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          func testMinifyJSTransformationWithOptionalsURL() {
              transformable.add(transform: MinifyJSTransform()
                  .booleans(true)
                  .builtIns(false)
                  .consecutiveAdds(true)
      Severity: Minor
      Found in Tests/FilestackSDKTests/TransformableTests.swift - About 1 hr to fix

        Function testGetImageTaggingResponse has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Function testObserversOnCancelledOperation has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              func testObserversOnCancelledOperation() throws {
                  let queue = serialOperationQueue()
                  let semaphore = DispatchSemaphore(value: 0)
          
                  let operation = WorkOperation<Bool>() { work in
          Severity: Minor
          Found in Tests/FilestackSDKTests/BaseOperationTests.swift - About 1 hr to fix

            Function testGetExistingContent has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                func testGetExistingContent() {
                    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 store has 9 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public func store(fileName: String? = nil,
                                    location: StorageLocation,
                                    path: String? = nil,
                                    container: String? = nil,
                                    region: String? = nil,

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

                    @discardableResult
                    func upload(data: Data,
                                to url: URL,
                                method: String,
                                headers: [String: String]? = nil,
                Severity: Minor
                Found in Sources/FilestackSDK/Internal/Services/UploadService.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 download has a Cognitive Complexity of 10 (exceeds 5 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

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

                    func testMultiFileUploadWithOneFile() {
                        var hitCount = 0
                        stubRegularMultipartRequest(hitCount: &hitCount)
                
                        let expectation = self.expectation(description: "request should succeed")
                Severity: Minor
                Found in Tests/FilestackSDKTests/UploadTests.swift - About 1 hr to fix

                  Function stubMultipartCompleteRequest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      func stubMultipartCompleteRequest(requestTime: TimeInterval = 0,
                                                        responseTime: TimeInterval = 0,
                                                        workflows: [String]? = nil,
                                                        uploadTags: [String: String]? = nil) {
                          let uploadMultipartCompleteStubConditions = isScheme(Constants.uploadURL.scheme!) &&
                  Severity: Minor
                  Found in Tests/FilestackSDKTests/UploadTests.swift - About 1 hr to fix

                    Function testUploadFileAtTemporaryLocation has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        func testUploadFileAtTemporaryLocation() {
                            var hitCount = 0
                    
                            stubRegularMultipartRequest(hitCount: &hitCount)
                    
                    
                    Severity: Minor
                    Found in Tests/FilestackSDKTests/UploadTests.swift - About 1 hr to fix

                      Function uploadDataChunk has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          func uploadDataChunk(using response: JSONResponse) {
                              guard !isCancelled else { return }
                      
                              if let apiErrorDescription = error(from: response) {
                                  finish(with: .failure(.api(apiErrorDescription)))

                        Function testAudioConvertTransformationURL has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

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

                          Function testGetContentWithParametersAndSecurity has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              func testGetContentWithParametersAndSecurity() {
                                  stub(condition: cdnStubConditions) { _ in
                                      HTTPStubsResponse(data: Data(), statusCode: 200, headers: nil)
                                  }
                          
                          
                          Severity: Minor
                          Found in Tests/FilestackSDKTests/FileLinkTests.swift - About 1 hr to fix

                            Function enqueue has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

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

                              Function uploadDataChunk has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  func uploadDataChunk(using response: JSONResponse) {
                                      guard !isCancelled else { return }
                              
                                      if let apiErrorDescription = error(from: response) {
                                          finish(with: .failure(.api(apiErrorDescription)))

                                Function testRegularMultiPartUpload has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    func testRegularMultiPartUpload() {
                                        var hitCount = 0
                                
                                        stubRegularMultipartRequest(hitCount: &hitCount)
                                
                                
                                Severity: Minor
                                Found in Tests/FilestackSDKTests/UploadTests.swift - About 1 hr to fix

                                  Function multiFileUpload has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      public func multiFileUpload(from localURLs: [URL],
                                                                  storeOptions: StorageOptions = StorageOptions(location: .s3, access: .private),
                                                                  useIntelligentIngestionIfAvailable: Bool = true,
                                                                  queue: DispatchQueue = .main,
                                                                  startUploadImmediately: Bool = true,
                                  Severity: Major
                                  Found in Sources/FilestackSDK/Public/Extensions/Client+Deprecated.swift - About 50 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language