meteor/meteor

View on GitHub
npm-packages/cordova-plugin-meteor-webapp/src/ios/AssetBundleDownloader.swift

Summary

Maintainability
C
1 day
Test Coverage

File AssetBundleDownloader.swift has 266 lines of code (exceeds 250 allowed). Consider refactoring.
Open

protocol AssetBundleDownloaderDelegate: class {
  func assetBundleDownloaderDidFinish(_ assetBundleDownloader: AssetBundleDownloader)
  func assetBundleDownloader(_ assetBundleDownloader: AssetBundleDownloader, didFailWithError error: Error)
}

    Function resume has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      func resume() {
        queue.async {
          if self.backgroundTask == UIBackgroundTaskIdentifier.invalid {
            NSLog("Start downloading assets from bundle with version: \(self.assetBundle.version)")
    
    

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

      func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {
        if let asset = assetsDownloadingByTaskIdentifier.removeValue(forKey: downloadTask.taskIdentifier) {
          if status == .canceling { return }
    
          // We don't have a hash for the index page, so we have to parse the runtime config

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

      func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
        if let error = error {
          if let asset = assetsDownloadingByTaskIdentifier.removeValue(forKey: task.taskIdentifier) {
            if task is URLSessionDownloadTask && status != .canceling {
              NSLog("Download of asset: \(asset) did fail with error: \(error)")

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

      func resume() {
        queue.async {
          if self.backgroundTask == UIBackgroundTaskIdentifier.invalid {
            NSLog("Start downloading assets from bundle with version: \(self.assetBundle.version)")
    
    

      Function verifyRuntimeConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        private func verifyRuntimeConfig(_ runtimeConfig: AssetBundle.RuntimeConfig) throws {
          let expectedVersion = assetBundle.version
          if let actualVersion = runtimeConfig.autoupdateVersionCordova,
            expectedVersion != actualVersion {
              throw WebAppError.downloadFailure(reason: "Version mismatch for index page, expected: \(expectedVersion), actual: \(actualVersion)", underlyingError: nil)

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

        private func downloadURLForAsset(_ asset: Asset) -> URL? {
          var urlPath = asset.urlPath
      
          // Remove leading / from URL path because the path should be relative to the base URL
          if urlPath.hasPrefix("/") {

      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

      There are no issues that match your filters.

      Category
      Status