filestack/filestack-swift

View on GitHub

Showing 260 of 260 total issues

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

import Foundation

/// Represents an image transform aspect type.
@objc(FSTransformAspectMode)
public enum TransformAspectMode: UInt, CustomStringConvertible {
Severity: Major
Found in Sources/FilestackSDK/Public/Enums/TransformAspectMode.swift and 1 other location - About 1 hr to fix
Sources/FilestackSDK/Public/Enums/StorageLocation.swift on lines 9..42

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 95.

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

import Foundation

/// Represents a cloud storage location type.
///
/// See [CloudStorage](https://www.filestack.com/docs/cloud-storage/) for more information
Severity: Major
Found in Sources/FilestackSDK/Public/Enums/StorageLocation.swift and 1 other location - About 1 hr to fix
Sources/FilestackSDK/Public/Enums/TransformAspectMode.swift on lines 9..39

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 95.

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 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

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

          func testSmartCropTransformationWithModeAutoURL() {
              transformable.add(transform: SmartCropTransform()
                                  .mode(.auto)
                                  .fillColor(.white)
                                  .width(512)
      Severity: Major
      Found in Tests/FilestackSDKTests/TransformableTests.swift and 1 other location - About 1 hr to fix
      Tests/FilestackSDKTests/TransformableTests.swift on lines 501..515

      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 94.

      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 testSmartCropTransformationWithModeFaceURL() {
              transformable.add(transform: SmartCropTransform()
                                  .mode(.face)
                                  .fillColor(.white)
                                  .width(512)
      Severity: Major
      Found in Tests/FilestackSDKTests/TransformableTests.swift and 1 other location - About 1 hr to fix
      Tests/FilestackSDKTests/TransformableTests.swift on lines 469..483

      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 94.

      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 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

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

        import Foundation
        
        /// Detects your document in the image, transforms it to fully fit the image, and preprocesses it using de-noising
        /// and distortion reduction in order to increase the accuracy of OCR engine in text extraction.
        ///
        Sources/FilestackSDK/Public/Transforms/FallbackTransform.swift on lines 9..39
        Sources/FilestackSDK/Public/Transforms/MinifyCSSTransform.swift on lines 9..39

        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 91.

        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 3 locations. Consider refactoring.
        Open

        import Foundation
        
        /// Returns default file if the source of the transformation does not work or the transformation fails.
        public class FallbackTransform: Transform {
            // MARK: - Lifecycle
        Sources/FilestackSDK/Public/Transforms/DocumentDetectionTransform.swift on lines 9..42
        Sources/FilestackSDK/Public/Transforms/MinifyCSSTransform.swift on lines 9..39

        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 91.

        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 3 locations. Consider refactoring.
        Open

        import Foundation
        
        /// Minifies your CSS files.
        public class MinifyCSSTransform: Transform {
            // MARK: - Lifecycle
        Sources/FilestackSDK/Public/Transforms/DocumentDetectionTransform.swift on lines 9..42
        Sources/FilestackSDK/Public/Transforms/FallbackTransform.swift on lines 9..39

        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 91.

        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

                stub(condition: cdnStubConditions) { _ in
                    let stubPath = Helpers.url(forResource: "sample", withExtension: "jpg", subdirectory: "Fixtures")!.path
        
                    let httpHeaders: [AnyHashable: Any] = [
                        "Content-Type": "image/jpeg",
        Severity: Major
        Found in Tests/FilestackSDKTests/FileLinkTests.swift and 1 other location - About 1 hr to fix
        Tests/FilestackSDKTests/FileLinkTests.swift on lines 372..381

        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 89.

        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

                stub(condition: cdnStubConditions) { _ in
                    let stubPath = Helpers.url(forResource: "sample", withExtension: "jpg", subdirectory: "Fixtures")!.path
        
                    let httpHeaders: [AnyHashable: Any] = [
                        "Content-Type": "image/jpeg",
        Severity: Major
        Found in Tests/FilestackSDKTests/FileLinkTests.swift and 1 other location - About 1 hr to fix
        Tests/FilestackSDKTests/FileLinkTests.swift on lines 194..203

        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 89.

        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 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

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

        import Foundation
        
        /// Represents an image transform fit type.
        @objc(FSTransformFit)
        public enum TransformFit: UInt, CustomStringConvertible {
        Severity: Major
        Found in Sources/FilestackSDK/Public/Enums/TransformFit.swift and 1 other location - About 1 hr to fix
        Sources/FilestackSDK/Public/Enums/TransformNoiseMode.swift on lines 10..37

        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 83.

        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

        import Foundation
        
        /// Represents an image transform noise reduction type.
        @objc(FSTransformNoiseMode)
        public enum TransformNoiseMode: UInt, CustomStringConvertible {
        Severity: Major
        Found in Sources/FilestackSDK/Public/Enums/TransformNoiseMode.swift and 1 other location - About 1 hr to fix
        Sources/FilestackSDK/Public/Enums/TransformFit.swift on lines 9..36

        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 83.

        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 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
                  Severity
                  Category
                  Status
                  Source
                  Language