JohnCoates/Aerial

View on GitHub

Showing 1,136 of 1,136 total issues

Function filteredVideosFor has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    private func filteredVideosFor(_ mode: FilterMode, filter: [String]) -> [AerialVideo] {
        // Our preference filters contains ALL sorts of filters (location, time) that are
        // saved for better user experience. So we need to filter the filters first !
        var filters: [String] = []

Severity: Minor
Found in Aerial/Source/Models/Sources/VideoList.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

Function updateLocalSource has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    static func updateLocalSource(source: Source, reload: Bool) {
        // We need the raw manifest to find the path inside
        let videos = source.getUnprocessedVideos()
        let originalAssets = source.getUnprocessedAssets()

Severity: Minor
Found in Aerial/Source/Models/Sources/SourceList.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

Function generatePlaylist has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    func generatePlaylist(isRestricted: Bool, restrictedTo: String, isVertical: Bool) {
        debugLog("generate playlist (isVertical: \(isVertical)")
        // Start fresh
        playlist = [AerialVideo]()
        playlistIsRestricted = isRestricted
Severity: Minor
Found in Aerial/Source/Models/Sources/VideoList.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

Function removeCruft has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    static func removeCruft() {
        // TODO: kind of a temporary safety
        if VideoList.instance.videos.count > 90 {
            // First let's look at the cache

Severity: Minor
Found in Aerial/Source/Models/Cache/Cache.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

Function randomVideo has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    func randomVideo(excluding: [AerialVideo], isVertical: Bool) -> (AerialVideo?, Bool) {
        var shouldLoop = false
        let timeManagement = TimeManagement.sharedInstance

        let (shouldRestrictByDayNight, restrictTo) = timeManagement.shouldRestrictPlaybackToDayNightVideo()
Severity: Minor
Found in Aerial/Source/Models/Sources/VideoList.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

Function isScreenActive has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    func isScreenActive(id: CGDirectDisplayID) -> Bool {
        let screen = findScreenWith(id: id)
        debugLog("ISA : \(screen)")
        
        switch PrefsDisplays.displayMode {
Severity: Minor
Found in Aerial/Source/Models/Hardware/DisplayDetection.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

Function getZeroedActiveSpannedRect has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    func getZeroedActiveSpannedRect() -> CGRect {
        if PrefsDisplays.displayMarginsAdvanced && !advancedMargins.displays.isEmpty, let advz = advancedZeroedScreenRect {
            // Now this is awkward... we precalculated this at detectdisplays->advancedZeroedOrigins
            return advz
        } else {
Severity: Minor
Found in Aerial/Source/Models/Hardware/DisplayDetection.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

Function getSuggestedFormat has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    func getSuggestedFormat() -> VideoFormat {
        switch isHEVCMain10HWDecodingAvailable() {
        case .supported:
            if #available(OSX 10.15, *) {
                return .v4KHDR
Severity: Minor
Found in Aerial/Source/Models/Hardware/HardwareDetection.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

Function getGlobalScreenRect has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    func getGlobalScreenRect() -> CGRect {
        if PrefsDisplays.displayMarginsAdvanced && !advancedMargins.displays.isEmpty, let adv = advancedScreenRect {
            // Now this is awkward... we precalculated this at detectdisplays->advancedZeroedOrigins
            return adv
        } else {
Severity: Minor
Found in Aerial/Source/Models/Hardware/DisplayDetection.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

Function fetch has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    static func fetch(completion: @escaping(Result<ForecastElement, NetworkError>) -> Void) {
        guard testJson == "" else {
            let jsonData = testJson.data(using: .utf8)!

            if let forecast = try? newJSONDecoder().decode(ForecastElement.self, from: jsonData) {
Severity: Major
Found in Aerial/Source/Models/API/Forecast.swift - About 2 hrs to fix

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

        static func getShortcodeLanguage() -> String {
            // Those are the languages supported by OpenWeather
            let weatherLanguages = ["af", "al", "ar", "az", "bg", "ca", "cz", "da", "de", "el", "en",
                                    "eu", "fa", "fi", "fr", "gl", "he", "hi", "hr", "hu", "id", "it",
                                    "ja", "kr", "la", "lt", "mk", "no", "nl", "pl", "pt", "pt_br", "ro",
    Severity: Major
    Found in Aerial/Source/Models/API/Forecast.swift and 2 other locations - About 2 hrs to fix
    Aerial/Source/Models/API/OneCall.swift on lines 149..170
    Aerial/Source/Models/API/OpenWeather.swift on lines 114..135

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

    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 FileManager.default.fileExists(atPath: directory) {
                let pathURL = URL(fileURLWithPath: directory)
    
                // check if the url is a directory
                if (try? pathURL.resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory == true {
    Severity: Major
    Found in Aerial/Source/Models/Cache/Cache.swift and 1 other location - About 2 hrs to fix
    Aerial/Source/Models/Cache/Cache.swift on lines 554..568

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

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

        static func getShortcodeLanguage() -> String {
            // Those are the languages supported by OpenWeather
            let weatherLanguages = ["af", "al", "ar", "az", "bg", "ca", "cz", "da", "de", "el", "en",
                                    "eu", "fa", "fi", "fr", "gl", "he", "hi", "hr", "hu", "id", "it",
                                    "ja", "kr", "la", "lt", "mk", "no", "nl", "pl", "pt", "pt_br", "ro",
    Severity: Major
    Found in Aerial/Source/Models/API/OneCall.swift and 2 other locations - About 2 hrs to fix
    Aerial/Source/Models/API/Forecast.swift on lines 119..140
    Aerial/Source/Models/API/OpenWeather.swift on lines 114..135

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

    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

        static func size() -> Double {
            let pathURL = URL(fileURLWithPath: path)
    
            // check if the url is a directory
            if (try? pathURL.resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory == true {
    Severity: Major
    Found in Aerial/Source/Models/Cache/Cache.swift and 1 other location - About 2 hrs to fix
    Aerial/Source/Models/Cache/Cache.swift on lines 571..585

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

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

        static func getShortcodeLanguage() -> String {
            // Those are the languages supported by OpenWeather
            let weatherLanguages = ["af", "al", "ar", "az", "bg", "ca", "cz", "da", "de", "el", "en",
                                    "eu", "fa", "fi", "fr", "gl", "he", "hi", "hr", "hu", "id", "it",
                                    "ja", "kr", "la", "lt", "mk", "no", "nl", "pl", "pt", "pt_br", "ro",
    Severity: Major
    Found in Aerial/Source/Models/API/OpenWeather.swift and 2 other locations - About 2 hrs to fix
    Aerial/Source/Models/API/Forecast.swift on lines 119..140
    Aerial/Source/Models/API/OneCall.swift on lines 149..170

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

    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 (PrefsVideos.videoFormat == .v1080pHDR || PrefsVideos.videoFormat == .v4KHDR) && video.source.name.starts(with: "tvOS") {
                        // We workaround here by grabbing online a 1080 SDR instead
                        let urlHEVC = video.urls[.v1080pHEVC]
                        let url264 = video.urls[.v1080pH264]
                        if urlHEVC != nil && urlHEVC != "" {
    Severity: Major
    Found in Aerial/Source/Models/Cache/Thumbnails.swift and 1 other location - About 2 hrs to fix
    Aerial/Source/Models/Cache/Thumbnails.swift on lines 65..79

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

    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 (PrefsVideos.videoFormat == .v1080pHDR || PrefsVideos.videoFormat == .v4KHDR) && video.source.name.starts(with: "tvOS") {
                        // We workaround here by grabbing online a 1080 SDR instead
                        let urlHEVC = video.urls[.v1080pHEVC]
                        let url264 = video.urls[.v1080pH264]
                        if urlHEVC != nil && urlHEVC != "" {
    Severity: Major
    Found in Aerial/Source/Models/Cache/Thumbnails.swift and 1 other location - About 2 hrs to fix
    Aerial/Source/Models/Cache/Thumbnails.swift on lines 47..63

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

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

        func showVideo(_ video: AerialVideo) {
            playbackSpeedLabel.isHidden = false
            playbackSpeedSlider.isHidden = false
    
            
    Severity: Major
    Found in Resources/MainUI/VideosViewController.swift - About 2 hrs to fix

      Function fetch has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static func fetch(completion: @escaping(Result<OWeather, NetworkError>) -> Void) {
              guard testJson == "" else {
                  let jsonData = testJson.data(using: .utf8)!
      
                  if var openWeather = try? newJSONDecoder().decode(OWeather.self, from: jsonData) {
      Severity: Major
      Found in Aerial/Source/Models/API/OpenWeather.swift - About 2 hrs to fix

        Function fetchOnlineManifest has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static func fetchOnlineManifest(url: URL) {
                if let source = loadManifest(url: url) {
                    debugLog("Source loaded")
                    // Then save !
                    let downloadManager = DownloadManager()
        Severity: Major
        Found in Aerial/Source/Models/Sources/SourceList.swift - About 2 hrs to fix
          Severity
          Category
          Status
          Source
          Language