JohnCoates/Aerial

View on GitHub

Showing 1,136 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 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 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

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

    func startOffsetFromResponse(_ response: URLResponse) -> Int? {
        // get range response
        var regex: NSRegularExpression!
        do {
            // Check to see if the server returned a valid byte-range
Severity: Major
Found in Aerial/Source/Models/Cache/VideoDownload.swift and 1 other location - About 3 hrs to fix
Aerial/Source/Models/Cache/VideoLoader.swift on lines 205..239

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

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

    func startOffsetFromResponse(_ response: URLResponse) -> Int? {

        // get range response
        var regex: NSRegularExpression!
        do {
Severity: Major
Found in Aerial/Source/Models/Cache/VideoLoader.swift and 1 other location - About 3 hrs to fix
Aerial/Source/Models/Cache/VideoDownload.swift on lines 289..320

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

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

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

                  switch pos {
                  case 1:
                      return "ar"
                  case 2:
                      return "zh_CN"
          Severity: Major
          Found in Aerial/Source/Models/Cache/PoiStringProvider.swift and 1 other location - About 3 hrs to fix
          Aerial/Source/Models/Cache/PoiStringProvider.swift on lines 263..304

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

          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

                  switch PrefsAdvanced.ciOverrideLanguage {
                  case "ar":  // Arabic
                      return 1
                  case "zh_CN":  // Chinese Simplified
                      return 2
          Severity: Major
          Found in Aerial/Source/Models/Cache/PoiStringProvider.swift and 1 other location - About 3 hrs to fix
          Aerial/Source/Models/Cache/PoiStringProvider.swift on lines 309..350

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

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

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

                    if let img = img {
                        if !square {
                            frame.size.height = CGFloat(size)
                            frame.size.width = CGFloat(size) * img.size.width / img.size.height
                        } else {
            Aerial/Source/Views/Layers/Weather/ConditionSymbolLayer.swift on lines 103..118

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

            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

            Severity
            Category
            Status
            Source
            Language