JohnCoates/Aerial

View on GitHub

Showing 1,136 of 1,136 total issues

Function isCornerAcceptable has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    func isCornerAcceptable(corner: Int) -> Bool {
        // Not the prettiest helper, this is a bit of a hack

        // If we have something in both topCenter and bottomCenter, we could infinite loop
        // So as a precaution we allow whatever was picked
Severity: Minor
Found in Aerial/Source/Views/Layers/LayerManager.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 setDimTimers has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    func setDimTimers() {
        if #available(OSX 10.12, *) {
            let timeManagement = TimeManagement.sharedInstance
            let startValue = min(PrefsDisplays.startDim, Double(brightnessToRestore!))

Severity: Minor
Found in Aerial/Source/Views/AerialView+Brightness.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 getSelectedVideo has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    func getSelectedVideo() -> AerialVideo? {
        if let path = path {
            if videoListTableView.selectedRow > -1 {
                if let mode = VideoList.instance.modeFromPath(path) {
                    let index = Int(path.split(separator: ":")[1])!
Severity: Minor
Found in Resources/MainUI/VideosViewController.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 getOldFilesEstimation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    func getOldFilesEstimation() -> (String, Int) {
        // loadedManifests contains the full deduplicated list of videos
        debugLog("Looking for outdated files")

        if loadedManifest.isEmpty {
Severity: Minor
Found in Aerial/Source/Models/ManifestLoader.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 downloadManifestsIfNeeded has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private func downloadManifestsIfNeeded() {
        let downloadManager = DownloadManager()

        var sourceQueue: [Source] = []

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

    static func removeUncachedCruft() {
        for source in SourceList.foundSources where !source.isCachable && source.type != .local {
            debugLog("Checking cruft in \(source.name)")

            let pathURL = URL(fileURLWithPath: supportPath.appending("/" + source.name))
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

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

        DistributedNotificationCenter.default().addObserver(forName: NSNotification.Name("com.glouel.aerial.location"), object: nil, queue: nil) { notification in
            debugLog("🌉😻 received location")
            debugLog(notification.debugDescription)
            
            if let lat = notification.userInfo?["latitude"] as? Double {
Severity: Major
Found in Aerial/Source/Models/CompanionBridge.swift and 1 other location - About 2 hrs to fix
Aerial/Source/Models/CompanionBridge.swift on lines 24..39

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

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

        DistributedNotificationCenter.default().addObserver(forName: NSNotification.Name("com.glouel.aerial.nightshift"), object: nil, queue: nil) { notification in
            debugLog("🌉😻 received nightshift")
            debugLog(notification.debugDescription)
            
            if let sunrise = notification.userInfo?["sunrise"] as? Date {
Severity: Major
Found in Aerial/Source/Models/CompanionBridge.swift and 1 other location - About 2 hrs to fix
Aerial/Source/Models/CompanionBridge.swift on lines 42..57

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

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

    func outlineView(_ outlineView: NSOutlineView, acceptDrop info: NSDraggingInfo, item: Any?, childIndex index: Int) -> Bool {

        if let items = info.draggingPasteboard.pasteboardItems {
            for item in items {
                if #available(OSX 10.13, *) {
Severity: Minor
Found in Aerial/Source/Controllers/CustomVideoController.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 testLocationButtonClick has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @IBAction func testLocationButtonClick(_ sender: NSButton) {
        // Clear out weather from existing location
        let cachedWeatherURL = URL(fileURLWithPath: Cache.supportPath, isDirectory: true).appendingPathComponent("Weather.json")
        let cachedWeatherForecastURL = URL(fileURLWithPath: Cache.supportPath, isDirectory: true).appendingPathComponent("Forecast.json")
        let fm = FileManager.default
Severity: Major
Found in Aerial/Source/Views/PrefPanel/InfoWeatherView.swift - About 2 hrs to fix

    Function calculate has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        fileprivate func calculate(_ sunriseSunset: SunriseSunset, for date: Date, and zenith: Zenith) -> Date? {
            guard let utcTimezone = TimeZone(identifier: "UTC") else { return nil }
    
            // Get the day of the year
            var calendar = Calendar(identifier: .gregorian)
    Severity: Major
    Found in Aerial/Source/Models/Time/Solar.swift - About 2 hrs to fix

      File TimeManagement.swift has 252 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import Foundation
      import Cocoa
      import CoreLocation
      import IOKit.ps
      
      
      Severity: Minor
      Found in Aerial/Source/Models/Time/TimeManagement.swift - About 2 hrs to fix

        Function shouldRestrictPlaybackToDayNightVideo has 51 lines of code (exceeds 25 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: Major
        Found in Aerial/Source/Models/Time/TimeManagement.swift - About 2 hrs to fix

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

          //
          //  Forecast.swift
          //  Aerial
          //
          //  Created by Guillaume Louel on 26/04/2021.
          Severity: Major
          Found in Aerial/Source/Models/API/Forecast.swift and 1 other location - About 2 hrs to fix
          Aerial/Source/Models/API/Forecast.swift on lines 1..252

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

          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 generate has 50 lines of code (exceeds 25 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 2 hrs to fix

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

                            fetchData(from: makeUrl(lat: lat, lon: lon)) { result in
                                switch result {
                                case .success(let jsonString):
                                    let jsonData = jsonString.data(using: .utf8)!
            
            
            Severity: Major
            Found in Aerial/Source/Models/API/OneCall.swift and 1 other location - About 1 hr to fix
            Aerial/Source/Models/API/OneCall.swift on lines 241..256

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

            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

                                fetchData(from: makeUrl(lat: geoLocation.lat, lon: geoLocation.lon)) { result in
                                    switch result {
                                    case .success(let jsonString):
                                        let jsonData = jsonString.data(using: .utf8)!
            
            
            Severity: Major
            Found in Aerial/Source/Models/API/OneCall.swift and 1 other location - About 1 hr to fix
            Aerial/Source/Models/API/OneCall.swift on lines 217..232

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

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

                func getTimeString() -> String {
                    if #available(OSX 10.12, *) {
                        // Handle locale
                        var locale = Locale(identifier: Locale.preferredLanguages[0])
                        if PrefsAdvanced.ciOverrideLanguage != "" {
            Severity: Minor
            Found in Aerial/Source/Views/Layers/TimerLayer.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 getCoordinates has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                func getCoordinates(failure: @escaping (_ error: String) -> Void,
                                    success: @escaping (_ response: CLLocationCoordinate2D) -> Void) {
                    // Sonoma workaround via CompanionBridge
                    if !Aerial.helper.underCompanion {
                        if #available(macOS 14.0, *) {
            Severity: Minor
            Found in Aerial/Source/Models/Locations.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 updateDuration has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                func updateDuration() {
                    // We need to retrieve video duration from the cached files.
                    // This is a workaround as currently, the VideoCache infrastructure
                    // relies on AVAsset with an external URL all the time, even when
                    // working on a cached copy which makes the native duration retrieval fail
            Severity: Minor
            Found in Aerial/Source/Models/AerialVideo.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

            Severity
            Category
            Status
            Source
            Language