JohnCoates/Aerial

View on GitHub
Aerial/Source/Models/Sources/Source.swift

Summary

Maintainability
F
5 days
Test Coverage

File Source.swift has 477 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Foundation

// 10 has a different format
// 11 is similar to 12+, but does not include pointsOfInterests
// 12/13 share a same format, and we use that format for local videos too
Severity: Minor
Found in Aerial/Source/Models/Sources/Source.swift - About 7 hrs to fix

    Function readOldJSONFromData has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        func readOldJSONFromData(_ data: Data) -> [AerialVideo] {
            var processedVideos: [AerialVideo] = []
    
            do {
                let poiStringProvider = PoiStringProvider.sharedInstance
    Severity: Minor
    Found in Aerial/Source/Models/Sources/Source.swift - About 3 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

    Function parseVideoManifest has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        func parseVideoManifest(_ data: Data) -> [AerialVideo] {
            if let videoManifest = try? newJSONDecoder().decode(VideoManifest.self, from: data) {
                var processedVideos: [AerialVideo] = []
    
                for asset in videoManifest.assets {
    Severity: Minor
    Found in Aerial/Source/Models/Sources/Source.swift - About 3 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

    Function parseOldVideoManifest has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        func parseOldVideoManifest(_ data: Data) -> [AerialVideo] {
            do {
                let oldVideoManifest = try newJSONDecoder().decode(OldVideoManifest.self, from: data)
                var processedVideos: [AerialVideo] = []
    
    
    Severity: Minor
    Found in Aerial/Source/Models/Sources/Source.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

    Source has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

    struct Source: Codable {
        var name: String
        var description: String
        var manifestUrl: String
        var type: SourceType
    Severity: Minor
    Found in Aerial/Source/Models/Sources/Source.swift - About 2 hrs to fix

      Function readOldJSONFromData has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          func readOldJSONFromData(_ data: Data) -> [AerialVideo] {
              var processedVideos: [AerialVideo] = []
      
              do {
                  let poiStringProvider = PoiStringProvider.sharedInstance
      Severity: Major
      Found in Aerial/Source/Models/Sources/Source.swift - About 2 hrs to fix

        Function parseVideoManifest has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            func parseVideoManifest(_ data: Data) -> [AerialVideo] {
                if let videoManifest = try? newJSONDecoder().decode(VideoManifest.self, from: data) {
                    var processedVideos: [AerialVideo] = []
        
                    for asset in videoManifest.assets {
        Severity: Minor
        Found in Aerial/Source/Models/Sources/Source.swift - About 1 hr to fix

          Function parseOldVideoManifest has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              func parseOldVideoManifest(_ data: Data) -> [AerialVideo] {
                  do {
                      let oldVideoManifest = try newJSONDecoder().decode(OldVideoManifest.self, from: data)
                      var processedVideos: [AerialVideo] = []
          
          
          Severity: Minor
          Found in Aerial/Source/Models/Sources/Source.swift - About 1 hr to fix

            Function getSubcategoryFor has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                func getSubcategoryFor(_ asset: MacAsset, manifest: MacManifest) -> String {
                    for category in manifest.categories {
                        if category.subcategories != nil {
                            for subcategory in category.subcategories! {
                                if subcategory.id == asset.subcategories.first {
            Severity: Minor
            Found in Aerial/Source/Models/Sources/Source.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

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

                func getVideos() -> [AerialVideo] {
                    if isCached() {
                        do {
                            let cacheFileUrl = URL(fileURLWithPath: Cache.supportPath.appending("/" + name + "/entries.json"))
                            let jsondata = try Data(contentsOf: cacheFileUrl)
            Severity: Minor
            Found in Aerial/Source/Models/Sources/Source.swift - About 55 mins 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

            Function lastUpdated has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                func lastUpdated() -> String {
                    if isCached() {
                        var date: Date?
                        if !isCachable && type == .local {
                            date = (try? FileManager.default.attributesOfItem(atPath:
            Severity: Minor
            Found in Aerial/Source/Models/Sources/Source.swift - About 45 mins 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

            Avoid deeply nested control flow statements.
            Open

                                        if foundDupe?.urls[.v1080pH264] == "" {
                                            foundDupe?.urls[.v1080pH264] = url
                                        }
            Severity: Major
            Found in Aerial/Source/Models/Sources/Source.swift - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          if dupe.urls[.v1080pH264] == "" {
                                              dupe.urls[.v1080pH264] = asset.url
                                          }
              Severity: Major
              Found in Aerial/Source/Models/Sources/Source.swift - About 45 mins to fix

                Avoid too many return statements within this function.
                Open

                                    return parseVideoManifest(jsondata)
                Severity: Major
                Found in Aerial/Source/Models/Sources/Source.swift - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return []
                  Severity: Major
                  Found in Aerial/Source/Models/Sources/Source.swift - About 30 mins to fix

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

                        func parseMacManifest(_ data: Data) -> [AerialVideo] {
                            if let videoManifest = try? newJSONDecoder().decode(MacManifest.self, from: data) {
                                var processedVideos: [AerialVideo] = []
                    
                                for asset in videoManifest.assets {
                    Severity: Minor
                    Found in Aerial/Source/Models/Sources/Source.swift - About 25 mins 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

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

                        func getUnprocessedAssets() -> [VideoAsset] {
                            if isCached() {
                                do {
                                    let cacheFileUrl = URL(fileURLWithPath: Cache.supportPath.appending("/" + name + "/entries.json"))
                                    let jsondata = try Data(contentsOf: cacheFileUrl)
                    Severity: Minor
                    Found in Aerial/Source/Models/Sources/Source.swift - About 25 mins 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

                    Force casts should be avoided
                    Open

                                        let id = item["id"] as! String

                    forced-type-cast

                    Avoid using the forced form of the type cast operator (as!) because Swift is not able to determine at compile time if the type conversion will succeed. In the event of an unsuccessful conversion, a runtime error will be triggered. The conditional form of the type cast operator (as?) is safer and should be used when possible.

                    Preferred

                    if let movie = item as? Movie {
                        print("Movie: '\(movie.name)', dir. \(movie.director)")
                    }

                    Not Preferred

                    let movie = item as! Movie
                    print("Movie: '\(movie.name)', dir. \(movie.director)")

                    Force casts should be avoided
                    Open

                                    let assets = batch["assets"] as! [NSDictionary]

                    forced-type-cast

                    Avoid using the forced form of the type cast operator (as!) because Swift is not able to determine at compile time if the type conversion will succeed. In the event of an unsuccessful conversion, a runtime error will be triggered. The conditional form of the type cast operator (as?) is safer and should be used when possible.

                    Preferred

                    if let movie = item as? Movie {
                        print("Movie: '\(movie.name)', dir. \(movie.director)")
                    }

                    Not Preferred

                    let movie = item as! Movie
                    print("Movie: '\(movie.name)', dir. \(movie.director)")

                    Force casts should be avoided
                    Open

                                        let timeOfDay = item["timeOfDay"] as! String

                    forced-type-cast

                    Avoid using the forced form of the type cast operator (as!) because Swift is not able to determine at compile time if the type conversion will succeed. In the event of an unsuccessful conversion, a runtime error will be triggered. The conditional form of the type cast operator (as?) is safer and should be used when possible.

                    Preferred

                    if let movie = item as? Movie {
                        print("Movie: '\(movie.name)', dir. \(movie.director)")
                    }

                    Not Preferred

                    let movie = item as! Movie
                    print("Movie: '\(movie.name)', dir. \(movie.director)")

                    Force casts should be avoided
                    Open

                                                                               options: options) as! [NSDictionary]

                    forced-type-cast

                    Avoid using the forced form of the type cast operator (as!) because Swift is not able to determine at compile time if the type conversion will succeed. In the event of an unsuccessful conversion, a runtime error will be triggered. The conditional form of the type cast operator (as?) is safer and should be used when possible.

                    Preferred

                    if let movie = item as? Movie {
                        print("Movie: '\(movie.name)', dir. \(movie.director)")
                    }

                    Not Preferred

                    let movie = item as! Movie
                    print("Movie: '\(movie.name)', dir. \(movie.director)")

                    Force casts should be avoided
                    Open

                                        let url = item["url"] as! String

                    forced-type-cast

                    Avoid using the forced form of the type cast operator (as!) because Swift is not able to determine at compile time if the type conversion will succeed. In the event of an unsuccessful conversion, a runtime error will be triggered. The conditional form of the type cast operator (as?) is safer and should be used when possible.

                    Preferred

                    if let movie = item as? Movie {
                        print("Movie: '\(movie.name)', dir. \(movie.director)")
                    }

                    Not Preferred

                    let movie = item as! Movie
                    print("Movie: '\(movie.name)', dir. \(movie.director)")

                    Force casts should be avoided
                    Open

                                        let name = item["accessibilityLabel"] as! String

                    forced-type-cast

                    Avoid using the forced form of the type cast operator (as!) because Swift is not able to determine at compile time if the type conversion will succeed. In the event of an unsuccessful conversion, a runtime error will be triggered. The conditional form of the type cast operator (as?) is safer and should be used when possible.

                    Preferred

                    if let movie = item as? Movie {
                        print("Movie: '\(movie.name)', dir. \(movie.director)")
                    }

                    Not Preferred

                    let movie = item as! Movie
                    print("Movie: '\(movie.name)', dir. \(movie.director)")

                    Force casts should be avoided
                    Open

                                        let type = item["type"] as! String

                    forced-type-cast

                    Avoid using the forced form of the type cast operator (as!) because Swift is not able to determine at compile time if the type conversion will succeed. In the event of an unsuccessful conversion, a runtime error will be triggered. The conditional form of the type cast operator (as?) is safer and should be used when possible.

                    Preferred

                    if let movie = item as? Movie {
                        print("Movie: '\(movie.name)', dir. \(movie.director)")
                    }

                    Not Preferred

                    let movie = item as! Movie
                    print("Movie: '\(movie.name)', dir. \(movie.director)")

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

                                for asset in videoManifest.assets {
                                    let video = AerialVideo(id: asset.id,
                                        name: asset.accessibilityLabel,
                                        secondaryName: getSecondaryNameFor(asset),
                                        type: "video",
                    Severity: Major
                    Found in Aerial/Source/Models/Sources/Source.swift and 1 other location - About 1 hr to fix
                    Aerial/Source/Models/Sources/Source.swift on lines 444..475

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

                    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

                                    if !isDupe {
                                        let video = AerialVideo(id: asset.id,
                                            name: asset.accessibilityLabel,
                                            secondaryName: getSecondaryNameFor(asset),
                                            type: "video",
                    Severity: Major
                    Found in Aerial/Source/Models/Sources/Source.swift and 1 other location - About 1 hr to fix
                    Aerial/Source/Models/Sources/Source.swift on lines 415..428

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

                    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

                                } else {
                                    date = (try? FileManager.default.attributesOfItem(atPath:
                                    Cache.supportPath.appending("/" + name + "/entries.json")))?[.creationDate] as? Date
                                }
                    Severity: Minor
                    Found in Aerial/Source/Models/Sources/Source.swift and 1 other location - About 50 mins to fix
                    Aerial/Source/Models/Sources/Source.swift on lines 70..73

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

                    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

                                if !isCachable && type == .local {
                                    date = (try? FileManager.default.attributesOfItem(atPath:
                                    Cache.supportPath.appending("/" + name + "/entries.json")))?[.modificationDate] as? Date
                                } else {
                    Severity: Minor
                    Found in Aerial/Source/Models/Sources/Source.swift and 1 other location - About 50 mins to fix
                    Aerial/Source/Models/Sources/Source.swift on lines 73..76

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

                    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

                                            if let val = SourceInfo.mergeInfo[id] {
                                                url1080pHEVC = val["url-1080-SDR"]!
                                                url1080pHDR = val["url-1080-HDR"]!
                                                url4KHEVC = val["url-4K-SDR"]!
                                                url4KHDR = val["url-4K-HDR"]!
                    Severity: Minor
                    Found in Aerial/Source/Models/Sources/Source.swift and 1 other location - About 45 mins to fix
                    Aerial/Source/Models/Sources/Source.swift on lines 351..356

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

                    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

                            if let val = SourceInfo.mergeInfo[asset.id] {
                                url1080pHEVC = val["url-1080-SDR"]!
                                url1080pHDR = val["url-1080-HDR"]!
                                url4KHEVC = val["url-4K-SDR"]!
                                url4KHDR = val["url-4K-HDR"]!
                    Severity: Minor
                    Found in Aerial/Source/Models/Sources/Source.swift and 1 other location - About 45 mins to fix
                    Aerial/Source/Models/Sources/Source.swift on lines 239..244

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

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

                                        if foundVideo?.urls[.v4KHDR] == "" {
                                            foundVideo?.urls[.v4KHDR] = assetURLs[.v4KHDR]
                                        }
                    Severity: Major
                    Found in Aerial/Source/Models/Sources/Source.swift and 4 other locations - About 35 mins to fix
                    Aerial/Source/Models/Sources/Source.swift on lines 463..465
                    Aerial/Source/Models/Sources/Source.swift on lines 466..468
                    Aerial/Source/Models/Sources/Source.swift on lines 469..471
                    Aerial/Source/Models/Sources/Source.swift on lines 472..474

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

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

                                        if foundVideo?.urls[.v1080pHEVC] == "" {
                                            foundVideo?.urls[.v1080pHEVC] = assetURLs[.v1080pHEVC]
                                        }
                    Severity: Major
                    Found in Aerial/Source/Models/Sources/Source.swift and 4 other locations - About 35 mins to fix
                    Aerial/Source/Models/Sources/Source.swift on lines 460..462
                    Aerial/Source/Models/Sources/Source.swift on lines 463..465
                    Aerial/Source/Models/Sources/Source.swift on lines 466..468
                    Aerial/Source/Models/Sources/Source.swift on lines 472..474

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

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

                                        if foundVideo?.urls[.v4KHEVC] == "" {
                                            foundVideo?.urls[.v4KHEVC] = assetURLs[.v4KHEVC]
                                        }
                    Severity: Major
                    Found in Aerial/Source/Models/Sources/Source.swift and 4 other locations - About 35 mins to fix
                    Aerial/Source/Models/Sources/Source.swift on lines 460..462
                    Aerial/Source/Models/Sources/Source.swift on lines 466..468
                    Aerial/Source/Models/Sources/Source.swift on lines 469..471
                    Aerial/Source/Models/Sources/Source.swift on lines 472..474

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

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

                                        if foundVideo?.urls[.v1080pHDR] == "" {
                                            foundVideo?.urls[.v1080pHDR] = assetURLs[.v1080pHDR]
                                        }
                    Severity: Major
                    Found in Aerial/Source/Models/Sources/Source.swift and 4 other locations - About 35 mins to fix
                    Aerial/Source/Models/Sources/Source.swift on lines 460..462
                    Aerial/Source/Models/Sources/Source.swift on lines 463..465
                    Aerial/Source/Models/Sources/Source.swift on lines 469..471
                    Aerial/Source/Models/Sources/Source.swift on lines 472..474

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

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

                                        if foundVideo?.urls[.v1080pH264] == "" {
                                            foundVideo?.urls[.v1080pH264] = assetURLs[.v1080pH264]
                                        }
                    Severity: Major
                    Found in Aerial/Source/Models/Sources/Source.swift and 4 other locations - About 35 mins to fix
                    Aerial/Source/Models/Sources/Source.swift on lines 460..462
                    Aerial/Source/Models/Sources/Source.swift on lines 463..465
                    Aerial/Source/Models/Sources/Source.swift on lines 466..468
                    Aerial/Source/Models/Sources/Source.swift on lines 469..471

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

                    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

                    Multiline comment should end with whitespace
                    Open

                                        }*/

                    comment-whitespace

                    Prefer at least one whitespace character after a comment opening symbol (//, ///, /*, or /**) and at least one whitespace character before a comment closing symbol (*/).

                    Preferred

                    // This is a comment
                    
                    /// This is a documentation comment
                    
                    /* This is a
                    multi-line comment */
                    
                    /* This is a
                    multi-line comment
                    */
                    
                    /** This is a
                    documentation multi-line
                    comment
                    */

                    Not Preferred

                    //This is a comment
                    
                    ///This is a documentation comment
                    
                    /*This is a
                    multi-line comment*/
                    
                    /**This is a multi-line
                    documentation comment */

                    Line should not have any trailing whitespace
                    Open

                            

                    trailing-whitespace

                    Flag whitespace after the last non-whitespace character on each line until the newline.

                    Preferred

                    let number = 42¬

                    Not Preferred

                    let number = 42••¬

                    Multiline comment should start with whitespace
                    Open

                                        /*var poi: [String: String]?

                    comment-whitespace

                    Prefer at least one whitespace character after a comment opening symbol (//, ///, /*, or /**) and at least one whitespace character before a comment closing symbol (*/).

                    Preferred

                    // This is a comment
                    
                    /// This is a documentation comment
                    
                    /* This is a
                    multi-line comment */
                    
                    /* This is a
                    multi-line comment
                    */
                    
                    /** This is a
                    documentation multi-line
                    comment
                    */

                    Not Preferred

                    //This is a comment
                    
                    ///This is a documentation comment
                    
                    /*This is a
                    multi-line comment*/
                    
                    /**This is a multi-line
                    documentation comment */

                    Line should not have any trailing whitespace
                    Open

                        

                    trailing-whitespace

                    Flag whitespace after the last non-whitespace character on each line until the newline.

                    Preferred

                    let number = 42¬

                    Not Preferred

                    let number = 42••¬

                    Line should not have any trailing whitespace
                    Open

                        

                    trailing-whitespace

                    Flag whitespace after the last non-whitespace character on each line until the newline.

                    Preferred

                    let number = 42¬

                    Not Preferred

                    let number = 42••¬

                    Line should not have any trailing whitespace
                    Open

                        

                    trailing-whitespace

                    Flag whitespace after the last non-whitespace character on each line until the newline.

                    Preferred

                    let number = 42¬

                    Not Preferred

                    let number = 42••¬

                    Line should not have any trailing whitespace
                    Open

                        

                    trailing-whitespace

                    Flag whitespace after the last non-whitespace character on each line until the newline.

                    Preferred

                    let number = 42¬

                    Not Preferred

                    let number = 42••¬

                    Line should not have any trailing whitespace
                    Open

                        

                    trailing-whitespace

                    Flag whitespace after the last non-whitespace character on each line until the newline.

                    Preferred

                    let number = 42¬

                    Not Preferred

                    let number = 42••¬

                    Line should not have any trailing whitespace
                    Open

                        

                    trailing-whitespace

                    Flag whitespace after the last non-whitespace character on each line until the newline.

                    Preferred

                    let number = 42¬

                    Not Preferred

                    let number = 42••¬

                    Colon at column 88 should have exactly one space after it
                    Open

                                            return PoiStringProvider.sharedInstance.getLocalizedNameKey(key:subcategory.localizedNameKey)

                    colon-whitespace

                    There should be no whitespace preceding the colon, exactly one whitespace after the colon for: * var, class, struct, protocol, extension, func, and tuple declarations * dict literals and types * case statements

                    However, for conditional expressions there should be a single whitespace before and after the colon.

                    Variable declarations

                    Preferred

                    var x: Int = 2

                    Not Preferred

                    var x : Int
                    var y:   String

                    Dictionary literals and types

                    Preferred

                    var x = [ 'key1': 1, 'key2': 2 ]
                    var y: [ Int: String ]

                    Not Preferred

                    var x = [ 'key1' : 1, 'key2':  3]
                    var y: [ Int :    String ]

                    Case statements

                    Preferred

                    switch character {
                    case "a": doSomething(a);
                    default: alert();
                    }

                    Not Preferred

                    switch character {
                    case "a" : doSomething(a);
                    default:     alert();
                    }

                    Class, Struct, Protocol, and Extension declarations

                    Preferred

                    class ClassName: BaseClass {
                    }
                    
                    struct StructName: BaseStruct {
                    }
                    
                    protocol ProtocolName: AnotherProtocol {
                    }
                    
                    extension TypeName: ProtocolName {
                    }

                    Not Preferred

                    class ClassName : BaseClass {
                    }
                    
                    struct StructName:  BaseStruct {
                    }
                    
                    protocol ProtocolName:AnotherProtocol {
                    }
                    
                    extension TypeName : ProtocolName {
                    }

                    Tuple declarations

                    Preferred

                    var y = (key: 1, value: 2)

                    Not Preferred

                    var y = (key:1, value : 2)

                    Function declarations

                    Preferred

                    func someFunction<t: someclass u: someprotocol>(someT: T, someU: U) {
                    }</t:>

                    Not Preferred

                    func someFunction<t : someclass u:someprotocol>(someT: T, someU: U) {
                    }</t>

                    Conditional expressions

                    Preferred

                    var x = condition ? a : b

                    Not Preferred

                    var x = condition ? a: b
                    var x = condition ? a   : b

                    Line should not have any trailing whitespace
                    Open

                        

                    trailing-whitespace

                    Flag whitespace after the last non-whitespace character on each line until the newline.

                    Preferred

                    let number = 42¬

                    Not Preferred

                    let number = 42••¬

                    Line should not have any trailing whitespace
                    Open

                        

                    trailing-whitespace

                    Flag whitespace after the last non-whitespace character on each line until the newline.

                    Preferred

                    let number = 42¬

                    Not Preferred

                    let number = 42••¬

                    There are no issues that match your filters.

                    Category
                    Status