JohnCoates/Aerial

View on GitHub

Showing 376 of 1,136 total issues

Function fetch has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

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

            do {
Severity: Minor
Found in Aerial/Source/Models/API/OneCall.swift - About 4 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 a Cognitive Complexity of 28 (exceeds 5 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: Minor
Found in Aerial/Source/Models/API/Forecast.swift - About 4 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 keyDown has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    override func keyDown(with event: NSEvent) {
        debugLog("🖼️ keyDown")

        if PrefsVideos.allowSkips {
            if event.keyCode == 124 {
Severity: Minor
Found in Aerial/Source/Views/AerialView.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 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 outlineView has 94 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {

        guard let columnIdentifier = tableColumn?.identifier.rawValue else {
            return nil
        }
Severity: Major
Found in Resources/MainUI/Settings panels/SourcesViewController.swift - About 3 hrs to fix

    Function makeDayBlock has 94 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        func makeDayBlock(slice: ArraySlice<FList>, size: Double) -> CALayer {
            // This is ugly but we try and do the  best from the data we get...
            var tmin, tmax: Double?
            var day: Int?
    
    
    Severity: Major
    Found in Aerial/Source/Views/Layers/Weather/ForecastLayer.swift - About 3 hrs to fix

      Function outlineView has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
      
              guard let columnIdentifier = tableColumn?.identifier.rawValue else {
                  return nil
              }
      Severity: Minor
      Found in Resources/MainUI/Settings panels/SourcesViewController.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 playNextVideo has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          func playNextVideo() {
              debugLog("🖼️ \(self) pnv")
      
              clearAllLayerAnimations()
      
      
      Severity: Minor
      Found in Aerial/Source/Views/AerialView.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

      AerialView has 30 methods (exceeds 20 allowed). Consider refactoring.
      Open

      @objc(AerialView)
      // swiftlint:disable:next type_body_length
      final class AerialView: ScreenSaverView, CAAnimationDelegate {
          var layerManager: LayerManager
          var playerLayer: AVPlayerLayer!
      Severity: Minor
      Found in Aerial/Source/Views/AerialView.swift - About 3 hrs to fix

        Function fetch has a Cognitive Complexity of 25 (exceeds 5 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: Minor
        Found in Aerial/Source/Models/API/OpenWeather.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

        VideosViewController has 29 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class VideosViewController: NSViewController {
            // Top rotation view
            @IBOutlet var rotationView: NSView!
            @IBOutlet var rotationPopup: NSPopUpButton!
            @IBOutlet var rotationImage: NSImageView!
        Severity: Minor
        Found in Resources/MainUI/VideosViewController.swift - About 3 hrs to fix

          Function shouldRestrictPlaybackToDayNightVideo has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              func shouldRestrictPlaybackToDayNightVideo() -> (Bool, String) {
                  debugLog("PrefsTime : \(PrefsTime.timeMode)")
                  // We override everything on dark mode if we need to
                  if PrefsTime.darkModeNightOverride && DarkMode.isEnabled() {
                      debugLog("Dark Mode override")
          Severity: Minor
          Found in Aerial/Source/Models/Time/TimeManagement.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 getInformation has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              static func getInformation() -> (Bool, sunrise: Date?, sunset: Date?, error: String?) {
                  // Sonoma workaround
                  if !Aerial.helper.underCompanion {
                      if #available(macOS 14.0, *) {
                          if CompanionBridge.nightShiftSunrise != nil {
          Severity: Minor
          Found in Aerial/Source/Models/Hardware/NightShift.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 playNextVideo has 80 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              func playNextVideo() {
                  debugLog("🖼️ \(self) pnv")
          
                  clearAllLayerAnimations()
          
          
          Severity: Major
          Found in Aerial/Source/Views/AerialView.swift - About 3 hrs to fix

            Function generate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

                static func generate(forVideo video: AerialVideo) {
                    do {
                        var asset: AVURLAsset
                        if video.isAvailableOffline {
                            // If a video is already cached, we may still need to use an online fetch as there's a bug
            Severity: Minor
            Found in Aerial/Source/Models/Cache/Thumbnails.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 observeValue has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                internal override func observeValue(forKeyPath keyPath: String?,
                                                    of object: Any?, change: [NSKeyValueChangeKey: Any]?,
                                                    context: UnsafeMutableRawPointer?) {
                    debugLog("🖼️ \(description) observeValue \(String(describing: keyPath)) \(playerLayer.isReadyForDisplay)")
            
            
            Severity: Minor
            Found in Aerial/Source/Views/AerialView.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 setupPlayerLayer has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                func setupPlayerLayer(withPlayer player: AVPlayer) {
                    let displayDetection = DisplayDetection.sharedInstance
            
                    self.layer = CALayer()
                    guard let layer = self.layer else {
            Severity: Minor
            Found in Aerial/Source/Views/AerialView+Player.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 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

            File SourceInfo.swift has 288 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import Foundation
            
            // swiftlint:disable:next type_body_length
            struct SourceInfo {
                // Those videos will be ignored
            Severity: Minor
            Found in Aerial/Source/Models/Sources/SourceInfo.swift - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language