filestack/filestack-swift

View on GitHub

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

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

                  let expectedURL = Constants.cdnURL
                      .appendingPathComponent("debug")
                      .appendingPathComponent("resize=width:50,height:25,fit:crop,align:bottom")
                      .appendingPathComponent("crop=dim:[20,30,150,250]")
                      .appendingPathComponent("flip")
          Severity: Major
          Found in Tests/FilestackSDKTests/TransformableTests.swift and 1 other location - About 3 hrs to fix
          Tests/FilestackSDKTests/TransformableTests.swift on lines 1280..1309

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

          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

                  let expectedURL = Constants.cdnURL
                      .appendingPathComponent("MY-API-KEY")
                      .appendingPathComponent("debug")
                      .appendingPathComponent("resize=width:50,height:25,fit:crop,align:bottom")
                      .appendingPathComponent("crop=dim:[20,30,150,250]")
          Severity: Major
          Found in Tests/FilestackSDKTests/TransformableTests.swift and 1 other location - About 3 hrs to fix
          Tests/FilestackSDKTests/TransformableTests.swift on lines 1153..1182

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

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

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

                import Foundation
                import UIKit
                
                /// Changes image brightness, saturation and hue.
                public class PartialBlurTransform: Transform {
                Sources/FilestackSDK/Public/Transforms/PartialPixelateTransform.swift on lines 9..54

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

                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
                import UIKit
                
                /// Changes image brightness, saturation and hue.
                public class PartialPixelateTransform: Transform {
                Sources/FilestackSDK/Public/Transforms/PartialBlurTransform.swift on lines 9..54

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

                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

                    func getRequest(handle: String,
                                    path: String?,
                                    parameters: [String: Any]?,
                                    security: Security?) -> URLRequest? {
                        let queryItems: [URLQueryItem]?
                Severity: Major
                Found in Sources/FilestackSDK/Internal/Services/CDNService.swift and 2 other locations - About 2 hrs to fix
                Sources/FilestackSDK/Internal/Services/APIService.swift on lines 25..44
                Sources/FilestackSDK/Internal/Services/APIService.swift on lines 46..65

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

                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

                    func deleteRequest(handle: String,
                                       path: String?,
                                       parameters: [String: Any]?,
                                       security: Security?) throws -> URLRequest? {
                        let queryItems: [URLQueryItem]?
                Severity: Major
                Found in Sources/FilestackSDK/Internal/Services/APIService.swift and 2 other locations - About 2 hrs to fix
                Sources/FilestackSDK/Internal/Services/APIService.swift on lines 46..65
                Sources/FilestackSDK/Internal/Services/CDNService.swift on lines 25..44

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

                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

                    func overwriteRequest(handle: String,
                                          path: String?,
                                          parameters: [String: Any]?,
                                          security: Security?) -> URLRequest? {
                        let queryItems: [URLQueryItem]?
                Severity: Major
                Found in Sources/FilestackSDK/Internal/Services/APIService.swift and 2 other locations - About 2 hrs to fix
                Sources/FilestackSDK/Internal/Services/APIService.swift on lines 25..44
                Sources/FilestackSDK/Internal/Services/CDNService.swift on lines 25..44

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

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

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

                import Foundation
                
                /// Represents an image transform page format type.
                @objc(FSTransformPageFormat)
                public enum TransformPageFormat: UInt, CustomStringConvertible {
                Severity: Major
                Found in Sources/FilestackSDK/Public/Enums/TransformPageFormat.swift and 1 other location - About 2 hrs to fix
                Sources/FilestackSDK/Public/Enums/TransformEnhancePreset.swift on lines 9..54

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

                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 enhance transformation preset.
                @objc(FSTransformEnhancePreset)
                public enum TransformEnhancePreset: UInt, CustomStringConvertible {
                Sources/FilestackSDK/Public/Enums/TransformPageFormat.swift on lines 9..51

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

                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 testCancellingStartedUploadWithoutUploadablesShouldCallCompletionHandler() {
                        let expectation = self.expectation(description: "request should succeed")
                        var response: [JSONResponse] = []
                
                        let uploadOptions = UploadOptions(preferIntelligentIngestion: true,
                Severity: Major
                Found in Tests/FilestackSDKTests/UploadTests.swift and 1 other location - About 2 hrs to fix
                Tests/FilestackSDKTests/UploadTests.swift on lines 165..186

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

                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 testCancellingNotStartedUploadWithoutUploadablesShouldCallCompletionHandler() {
                        let expectation = self.expectation(description: "request should succeed")
                        var response: [JSONResponse] = []
                
                        let uploadOptions = UploadOptions(preferIntelligentIngestion: true,
                Severity: Major
                Found in Tests/FilestackSDKTests/UploadTests.swift and 1 other location - About 2 hrs to fix
                Tests/FilestackSDKTests/UploadTests.swift on lines 142..163

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

                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

                Severity
                Category
                Status
                Source
                Language