JohnCoates/Aerial

View on GitHub

Showing 1,136 of 1,136 total issues

Function categorizedSourceList has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    static func categorizedSourceList() -> [SourceHeader] {
        var communities: [Source] = []
        var online: [Source] = []
        var local: [Source] = []
        var apple: [Source] = []
Severity: Minor
Found in Aerial/Source/Models/Sources/SourceList.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 findDuplicate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    func findDuplicate(id: String, url1080pH264: String) -> (Bool, AerialVideo?) {
        // We blacklist some duplicates
        if url1080pH264 != "" {
            if blacklist.contains((URL(string: url1080pH264)?.lastPathComponent)!) {
                return (true, nil)
Severity: Minor
Found in Aerial/Source/Models/ManifestLoader.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

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

            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/Models/Sources/SourceList.swift and 1 other location - About 1 hr to fix
Aerial/Source/Controllers/CustomVideoController.swift on lines 182..200

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

Function connection has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    func connection(_ connection: NSURLConnection, didReceive data: Data) {

        queue.async { () -> Void in
            self.fillInContentInformation(self.loadingRequest)

Severity: Minor
Found in Aerial/Source/Models/Cache/VideoLoader.swift - About 1 hr to fix

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

        init(withLayer: CALayer, isPreview: Bool, offsets: LayerOffsets, manager: LayerManager) {
            self.layerManager = manager
            self.isPreview = isPreview
            self.baseLayer = withLayer
            self.offsets = offsets
    Severity: Major
    Found in Aerial/Source/Views/Layers/AnimationLayer.swift and 1 other location - About 1 hr to fix
    Aerial/Source/Views/Layers/AnimationTextLayer.swift on lines 40..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 113.

    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

        init(withLayer: CALayer, isPreview: Bool, offsets: LayerOffsets, manager: LayerManager) {
            self.layerManager = manager
            self.isPreview = isPreview
            self.baseLayer = withLayer
            self.offsets = offsets
    Severity: Major
    Found in Aerial/Source/Views/Layers/AnimationTextLayer.swift and 1 other location - About 1 hr to fix
    Aerial/Source/Views/Layers/AnimationLayer.swift on lines 48..65

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

    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

            for video in processedVideos {
                if id == video.id {
                    return (true, video)
                } else if url1080pH264 != "" && video.urls[.v1080pH264] != "" {
                    if URL(string: url1080pH264)?.lastPathComponent == URL(string: video.urls[.v1080pH264]!)?.lastPathComponent {
    Severity: Major
    Found in Aerial/Source/Models/ManifestLoader.swift and 1 other location - About 1 hr to fix
    Aerial/Source/Models/Sources/SourceInfo.swift on lines 317..325

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

    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

            for video in VideoList.instance.videos {
                if id == video.id {
                    return (true, video)
                } else if url1080pH264 != "" && video.urls[.v1080pH264] != "" {
                    if URL(string: url1080pH264)?.lastPathComponent == URL(string: video.urls[.v1080pH264]!)?.lastPathComponent {
    Severity: Major
    Found in Aerial/Source/Models/Sources/SourceInfo.swift and 1 other location - About 1 hr to fix
    Aerial/Source/Models/ManifestLoader.swift on lines 914..922

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

    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

                for screen in screens where isScreenActive(id: screen.id) {
                    if screen.bottomLeftFrame.origin.x < minX {
                        minX = screen.bottomLeftFrame.origin.x
                    }
                    if screen.bottomLeftFrame.origin.y < minY {
    Severity: Major
    Found in Aerial/Source/Models/Hardware/DisplayDetection.swift and 1 other location - About 1 hr to fix
    Aerial/Source/Models/Hardware/DisplayDetection.swift on lines 285..298

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

    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

                for screen in screens {
                    if screen.bottomLeftFrame.origin.x < minX {
                        minX = screen.bottomLeftFrame.origin.x
                    }
                    if screen.bottomLeftFrame.origin.y < minY {
    Severity: Major
    Found in Aerial/Source/Models/Hardware/DisplayDetection.swift and 1 other location - About 1 hr to fix
    Aerial/Source/Models/Hardware/DisplayDetection.swift on lines 331..344

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

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

        func getLanguagePosition() -> Int {
            // The list is alphabetized based on their english name in the UI
            switch PrefsAdvanced.ciOverrideLanguage {
            case "ar":  // Arabic
                return 1
    Severity: Minor
    Found in Aerial/Source/Models/Cache/PoiStringProvider.swift - About 1 hr to fix

      Function getLanguageStringFromPosition has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          func getLanguageStringFromPosition(pos: Int) -> String {
              switch pos {
              case 1:
                  return "ar"
              case 2:
      Severity: Minor
      Found in Aerial/Source/Models/Cache/PoiStringProvider.swift - About 1 hr to fix

        Function filteredVideosFor has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private func filteredVideosFor(_ mode: FilterMode, section: Int) -> [AerialVideo] {
                switch mode {
                case .location:
                    let filter = sourcesFor(mode)[section].lowercased()
                    return videos
        Severity: Minor
        Found in Aerial/Source/Models/Sources/VideoList.swift - About 1 hr to fix

          Function detectDisplays has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              func detectDisplays() {
                  // Display detection is done in two passes :
                  // - Through CGDisplay, we grab all online screens (connected, but
                  //   may or may not be powered on !) and get most information needed
                  // - Through NSScreen to get the backingScaleFactor (retinaness of a screen)
          Severity: Minor
          Found in Aerial/Source/Models/Hardware/DisplayDetection.swift - About 1 hr to fix

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

                override func setupForVideo(video: AerialVideo, player: AVPlayer) {
                    // Only run this once
                    if !wasSetup {
                        wasSetup = true
            
            
            Severity: Major
            Found in Aerial/Source/Views/Layers/ClockLayer.swift and 1 other location - About 1 hr to fix
            Aerial/Source/Views/Layers/DateLayer.swift on lines 44..59

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

            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

                override func setupForVideo(video: AerialVideo, player: AVPlayer) {
                    // Only run this once
                    if !wasSetup {
                        wasSetup = true
            
            
            Severity: Major
            Found in Aerial/Source/Views/Layers/DateLayer.swift and 1 other location - About 1 hr to fix
            Aerial/Source/Views/Layers/ClockLayer.swift on lines 44..59

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

            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 getCoordinates has 40 lines of code (exceeds 25 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

              Function updateCacheBox has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  func updateCacheBox() {
                      let usedCache = Cache.size()
                      let packsSize = Cache.packsSize()
              
                      //print("pack size : \(packsSize)")
              Severity: Minor
              Found in Resources/MainUI/Settings panels/CacheViewController.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 collectionView has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  func collectionView(_ itemForRepresentedObjectAtcollectionView: NSCollectionView,
                                      itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
              
                      let item = playingCollectionView.makeItem(withIdentifier:
                                      NSUserInterfaceItemIdentifier(rawValue: "PlayingCollectionViewItem"), for: indexPath)
              Severity: Minor
              Found in Resources/MainUI/Settings panels/NowPlayingViewController.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