meteor/meteor

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

Summary

Maintainability
D
1 day
Test Coverage

Function checkForUpdatesWithBaseURL has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

  func checkForUpdatesWithBaseURL(_ baseURL: URL) {
    let manifestURL = URL(string: "manifest.json", relativeTo: baseURL)!

    NSLog("Start downloading asset manifest from: \(manifestURL)")

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

  func checkForUpdatesWithBaseURL(_ baseURL: URL) {
    let manifestURL = URL(string: "manifest.json", relativeTo: baseURL)!

    NSLog("Start downloading asset manifest from: \(manifestURL)")

    Function downloadAssetBundle has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      private func downloadAssetBundle(_ assetBundle: AssetBundle, withBaseURL baseURL: URL) {
        var missingAssets = Set<Asset>()
    
        for asset in assetBundle.ownAssets {
          // Workaround for https://github.com/meteor/cordova-plugin-meteor-webapp/issues/56

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

      private func downloadAssetBundle(_ assetBundle: AssetBundle, withBaseURL baseURL: URL) {
        var missingAssets = Set<Asset>()
    
        for asset in assetBundle.ownAssets {
          // Workaround for https://github.com/meteor/cordova-plugin-meteor-webapp/issues/56

      Function loadDownloadedAssetBundles has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        private func loadDownloadedAssetBundles() {
          let items: [URL]
          items = try! fileManager.contentsOfDirectory(at: versionsDirectoryURL,
            includingPropertiesForKeys: [URLResourceKey.isDirectoryKey],
            options: [.skipsHiddenFiles])

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

        private func moveExistingDownloadDirectoryIfNeeded() {
          if fileManager.fileExists(atPath: downloadDirectoryURL.path) {
            let partialDownloadDirectoryURL = self.versionsDirectoryURL.appendingPathComponent("PartialDownload")
            do {
              if fileManager.fileExists(atPath: partialDownloadDirectoryURL.path) {

      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

      Avoid too many return statements within this function.
      Open

                return

        Avoid too many return statements within this function.
        Open

                  return

          Avoid too many return statements within this function.
          Open

                    return

            Avoid too many return statements within this function.
            Open

                      return

              Avoid too many return statements within this function.
              Open

                        return

                Avoid too many return statements within this function.
                Open

                          return

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

                    private func cachedAssetForAsset(_ asset: Asset) -> Asset? {
                      for assetBundle in downloadedAssetBundlesByVersion.values {
                        if let cachedAsset = assetBundle.cachedAssetForURLPath(asset.urlPath, hash: asset.hash) {
                          return cachedAsset
                        }

                  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