JohnCoates/Aerial

View on GitHub
Aerial/Source/Controllers/CustomVideoController.swift

Summary

Maintainability
D
2 days
Test Coverage

File CustomVideoController.swift has 438 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Foundation
import AppKit
import AVKit

class CustomVideoController: NSWindowController, NSWindowDelegate, NSDraggingDestination {
Severity: Minor
Found in Aerial/Source/Controllers/CustomVideoController.swift - About 6 hrs to fix

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

        func processPathForVideos(url: URL) {
            debugLog("processing url for videos : \(url) ")
            let folderName = url.lastPathComponent
            // let manifestInstance = ManifestLoader.instance
    
    
    Severity: Minor
    Found in Aerial/Source/Controllers/CustomVideoController.swift - About 1 hr to fix

      Function outlineView has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          func outlineView(_ outlineView: NSOutlineView, shouldSelectItem item: Any) -> Bool {
              debugLog("selected \(item)")
      
              if let source = item as? Source {
                  topPathControl.isHidden = false
      Severity: Minor
      Found in Aerial/Source/Controllers/CustomVideoController.swift - About 1 hr to fix

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

            @IBAction func menuRemoveVideoClick(_ sender: NSMenuItem) {
                if let asset = sender.representedObject as? Asset {
                    let manifestInstance = ManifestLoader.instance
        
                    if let cvf = manifestInstance.customVideoFolders {
        Severity: Minor
        Found in Aerial/Source/Controllers/CustomVideoController.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 outlineView has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            func outlineView(_ outlineView: NSOutlineView, shouldSelectItem item: Any) -> Bool {
                debugLog("selected \(item)")
        
                if let source = item as? Source {
                    topPathControl.isHidden = false
        Severity: Minor
        Found in Aerial/Source/Controllers/CustomVideoController.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 surl.isDirectory {
                                    debugLog("processing dir")
                                    self.processPathForVideos(url: surl)
                                }
        Severity: Major
        Found in Aerial/Source/Controllers/CustomVideoController.swift - About 45 mins to fix

          Function tableViewSelectionDidChange has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              func tableViewSelectionDidChange(_ notification: Notification) {
                  if let asset = currentAsset {
                      if poiTableView.selectedRow >= 0 {
                          removePoi.isEnabled = true
          
          
          Severity: Minor
          Found in Aerial/Source/Controllers/CustomVideoController.swift - About 35 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 processPathForVideos has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              func processPathForVideos(url: URL) {
                  debugLog("processing url for videos : \(url) ")
                  let folderName = url.lastPathComponent
                  // let manifestInstance = ManifestLoader.instance
          
          
          Severity: Minor
          Found in Aerial/Source/Controllers/CustomVideoController.swift - About 35 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 addPoiValidate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              @IBAction func addPoiValidate(_ sender: NSButton) {
                  if let asset = currentAsset {
                      if timeTextField.stringValue != "" && descriptionTextField.stringValue != "" {
                          if asset.pointsOfInterest[timeTextField.stringValue] == nil {
                              asset.pointsOfInterest[timeTextField.stringValue] = descriptionTextField.stringValue
          Severity: Minor
          Found in Aerial/Source/Controllers/CustomVideoController.swift - About 35 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 tableView has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
                  if let asset = currentAsset {
                      var text: String
                      if tableColumn!.identifier.rawValue == "timeColumn" {
                          let keys = asset.pointsOfInterest.keys.map { Int($0)!}.sorted()
          Severity: Minor
          Found in Aerial/Source/Controllers/CustomVideoController.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

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

                      for lurl in urls {
                          if lurl.path.lowercased().hasSuffix(".mp4") || lurl.path.lowercased().hasSuffix(".mov") {
                              assets.append(VideoAsset(accessibilityLabel: folderName,
                                                       id: NSUUID().uuidString,
                                                       title: lurl.lastPathComponent,
          Severity: Major
          Found in Aerial/Source/Controllers/CustomVideoController.swift and 1 other location - About 1 hr to fix
          Aerial/Source/Models/Sources/SourceList.swift on lines 308..326

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

          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 getResolution(asset: AVAsset) -> CGSize {
                  guard let track = asset.tracks(withMediaType: AVMediaType.video).first else { return CGSize.zero }
                  let size = track.naturalSize.applying(track.preferredTransform)
                  return CGSize(width: abs(size.width), height: abs(size.height))
              }
          Severity: Major
          Found in Aerial/Source/Controllers/CustomVideoController.swift and 1 other location - About 1 hr to fix
          Aerial/Source/Models/ManifestLoader.swift on lines 492..496

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

          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

              @IBAction func timeStepperChange(_ sender: NSStepper) {
                  if let player = editPlayerView.player {
                      player.seek(to: CMTime(seconds: Double(sender.intValue), preferredTimescale: 1))
                  }
              }
          Severity: Minor
          Found in Aerial/Source/Controllers/CustomVideoController.swift and 1 other location - About 45 mins to fix
          Aerial/Source/Controllers/CustomVideoController.swift on lines 308..312

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

          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

              @IBAction func timeTextChange(_ sender: NSTextField) {
                  if let player = editPlayerView.player {
                      player.seek(to: CMTime(seconds: Double(sender.intValue), preferredTimescale: 1))
                  }
              }
          Severity: Minor
          Found in Aerial/Source/Controllers/CustomVideoController.swift and 1 other location - About 45 mins to fix
          Aerial/Source/Controllers/CustomVideoController.swift on lines 302..306

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

          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

              @IBAction func folderNameChange(_ sender: NSTextField) {
                  if let folder = currentFolder {
                      folder.label = sender.stringValue
                      folderOutlineView.reloadData()
                  }
          Severity: Minor
          Found in Aerial/Source/Controllers/CustomVideoController.swift and 1 other location - About 30 mins to fix
          Aerial/Source/Controllers/CustomVideoController.swift on lines 255..260

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

          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

              @IBAction func videoNameChange(_ sender: NSTextField) {
                  if let asset = currentAsset {
                      asset.accessibilityLabel = sender.stringValue
                      folderOutlineView.reloadData()
                  }
          Severity: Minor
          Found in Aerial/Source/Controllers/CustomVideoController.swift and 1 other location - About 30 mins to fix
          Aerial/Source/Controllers/CustomVideoController.swift on lines 132..137

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

          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

          There are no issues that match your filters.

          Category
          Status