filestack/filestack-swift

View on GitHub

Showing 260 of 260 total issues

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

extension SubmitPartRegularUploadOperation {
    override func main() {
        let uploadURL = URL(string: "multipart/upload", relativeTo: Constants.uploadURL)!
        let headers = ["Content-Type": "application/json"]

Sources/FilestackSDK/Internal/Operations/SubmitChunkUploadOperation.swift on lines 52..70

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 131.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

extension SubmitChunkUploadOperation {
    override func main() {
        let uploadURL = URL(string: "multipart/upload", relativeTo: Constants.uploadURL)!
        let headers = ["Content-Type": "application/json"]

Sources/FilestackSDK/Internal/Operations/SubmitPartRegularUploadOperation.swift on lines 51..69

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 131.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    @objc func getTags(queue: DispatchQueue? = .main,
                       completionHandler: @escaping (JSONResponse) -> Void) {
        guard let request = CDNService.shared.getImageTaggingRequest(type: "tags", handle: handle, security: security) else {
            return
        }
Severity: Major
Found in Sources/FilestackSDK/Public/Models/FileLink.swift and 1 other location - About 2 hrs to fix
Sources/FilestackSDK/Public/Models/FileLink.swift on lines 110..123

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 129.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    @objc func getSafeForWork(queue: DispatchQueue? = .main,
                              completionHandler: @escaping (JSONResponse) -> Void) {
        guard let request = CDNService.shared.getImageTaggingRequest(type: "sfw", handle: handle, security: security) else {
            return
        }
Severity: Major
Found in Sources/FilestackSDK/Public/Models/FileLink.swift and 1 other location - About 2 hrs to fix
Sources/FilestackSDK/Public/Models/FileLink.swift on lines 91..104

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 129.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    @discardableResult
    @objc public func uploadMultipleData(using multipleData: [NSData],
                                         options: UploadOptions = .defaults,
                                         queue: DispatchQueue = .main,
                                         uploadProgress: ((Progress) -> Void)? = nil,
Severity: Major
Found in Sources/FilestackSDK/Public/Extensions/Client+ObjC.swift and 1 other location - About 1 hr to fix
Sources/FilestackSDK/Public/Extensions/Client+ObjC.swift on lines 67..78

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 122.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    @discardableResult
    @objc public func uploadMultipleURLs(using localURLs: [NSURL],
                                         options: UploadOptions = .defaults,
                                         queue: DispatchQueue = .main,
                                         uploadProgress: ((Progress) -> Void)? = nil,
Severity: Major
Found in Sources/FilestackSDK/Public/Extensions/Client+ObjC.swift and 1 other location - About 1 hr to fix
Sources/FilestackSDK/Public/Extensions/Client+ObjC.swift on lines 133..144

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 122.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        @discardableResult
        @objc public func uploadData(using data: NSData,
                                     options: UploadOptions = .defaults,
                                     queue: DispatchQueue = .main,
                                     uploadProgress: ((Progress) -> Void)? = nil,
    Severity: Major
    Found in Sources/FilestackSDK/Public/Extensions/Client+ObjC.swift and 1 other location - About 1 hr to fix
    Sources/FilestackSDK/Public/Extensions/Client+ObjC.swift on lines 34..45

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 110.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        @discardableResult
        @objc public func uploadURL(using localURL: NSURL,
                                    options: UploadOptions = .defaults,
                                    queue: DispatchQueue = .main,
                                    uploadProgress: ((Progress) -> Void)? = nil,
    Severity: Major
    Found in Sources/FilestackSDK/Public/Extensions/Client+ObjC.swift and 1 other location - About 1 hr to fix
    Sources/FilestackSDK/Public/Extensions/Client+ObjC.swift on lines 100..111

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 110.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                uploadTask = UploadService.shared.upload(data: data, to: url, method: "PUT", headers: headers, uploadProgress: { (progress) in
                    self.progress.totalUnitCount = Int64(self.data.size ?? 0)
                    self.progress.completedUnitCount = Int64(Double(self.progress.totalUnitCount) * progress.fractionCompleted)
                }) { (_, response, error) in
                    self.uploadTask = nil
        Sources/FilestackSDK/Internal/Operations/SubmitPartRegularUploadOperation.swift on lines 108..122

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 107.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                uploadTask = UploadService.shared.upload(data: data, to: url, method: "PUT", headers: headers, uploadProgress: { (progress) in
                    self.progress.totalUnitCount = Int64(data.size ?? 0)
                    self.progress.completedUnitCount = Int64(Double(self.progress.totalUnitCount) * progress.fractionCompleted)
                }) { (_, response, error) in
                    self.uploadTask = nil
        Sources/FilestackSDK/Internal/Operations/SubmitChunkUploadOperation.swift on lines 109..123

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 107.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            func testPartialBlurTransformationUrl() {
                let firstObj = CGRect(x: 10, y: 20, width: 30, height: 40)
                let secondObj = CGRect(x: 11, y: 21, width: 31, height: 41)
                transformable.add(transform: PartialBlurTransform(objects: [firstObj, secondObj]))
        
        
        Severity: Major
        Found in Tests/FilestackSDKTests/TransformableTests.swift and 1 other location - About 1 hr to fix
        Tests/FilestackSDKTests/TransformableTests.swift on lines 207..217

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 105.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            func testPartialPixelateTransformationUrl() {
                let firstObj = CGRect(x: 10, y: 20, width: 30, height: 40)
                let secondObj = CGRect(x: 11, y: 21, width: 31, height: 41)
                transformable.add(transform: PartialPixelateTransform(objects: [firstObj, secondObj]))
        
        
        Severity: Major
        Found in Tests/FilestackSDKTests/TransformableTests.swift and 1 other location - About 1 hr to fix
        Tests/FilestackSDKTests/TransformableTests.swift on lines 195..205

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 105.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

              Severity
              Category
              Status
              Source
              Language