JohnCoates/Aerial

View on GitHub

Showing 1,136 of 1,136 total issues

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

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

    static func generate(forVideo video: AerialVideo) {
        do {
            var asset: AVURLAsset
            if video.isAvailableOffline {
                // If a video is already cached, we may still need to use an online fetch as there's a bug
Severity: Minor
Found in Aerial/Source/Models/Cache/Thumbnails.swift - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function observeValue has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    internal override func observeValue(forKeyPath keyPath: String?,
                                        of object: Any?, change: [NSKeyValueChangeKey: Any]?,
                                        context: UnsafeMutableRawPointer?) {
        debugLog("🖼️ \(description) observeValue \(String(describing: keyPath)) \(playerLayer.isReadyForDisplay)")

Severity: Minor
Found in Aerial/Source/Views/AerialView.swift - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function setupPlayerLayer has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    func setupPlayerLayer(withPlayer player: AVPlayer) {
        let displayDetection = DisplayDetection.sharedInstance

        self.layer = CALayer()
        guard let layer = self.layer else {
Severity: Minor
Found in Aerial/Source/Views/AerialView+Player.swift - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function parseOldVideoManifest has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    func parseOldVideoManifest(_ data: Data) -> [AerialVideo] {
        do {
            let oldVideoManifest = try newJSONDecoder().decode(OldVideoManifest.self, from: data)
            var processedVideos: [AerialVideo] = []

Severity: Minor
Found in Aerial/Source/Models/Sources/Source.swift - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

    private static func fetchData(from urlString: String, completion: @escaping (Result<String, NetworkError>) -> Void) {
        // check the URL is OK, otherwise return with a failure
        guard let url = URL(string: urlString) else {
            completion(.failure(.badURL))
            return
Severity: Major
Found in Aerial/Source/Models/API/OneCall.swift and 3 other locations - About 2 hrs to fix
Aerial/Source/Models/API/Forecast.swift on lines 228..251
Aerial/Source/Models/API/GeoCoding.swift on lines 83..106
Aerial/Source/Models/API/OpenWeather.swift on lines 223..246

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

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 4 locations. Consider refactoring.
Open

    private static func fetchData(from urlString: String, completion: @escaping (Result<String, NetworkError>) -> Void) {
        // check the URL is OK, otherwise return with a failure
        guard let url = URL(string: urlString) else {
            completion(.failure(.badURL))
            return
Severity: Major
Found in Aerial/Source/Models/API/OpenWeather.swift and 3 other locations - About 2 hrs to fix
Aerial/Source/Models/API/Forecast.swift on lines 228..251
Aerial/Source/Models/API/GeoCoding.swift on lines 83..106
Aerial/Source/Models/API/OneCall.swift on lines 265..288

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

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 4 locations. Consider refactoring.
Open

    private static func fetchData(from urlString: String, completion: @escaping (Result<String, NetworkError>) -> Void) {
        // check the URL is OK, otherwise return with a failure
        guard let url = URL(string: urlString) else {
            completion(.failure(.badURL))
            return
Severity: Major
Found in Aerial/Source/Models/API/GeoCoding.swift and 3 other locations - About 2 hrs to fix
Aerial/Source/Models/API/Forecast.swift on lines 228..251
Aerial/Source/Models/API/OneCall.swift on lines 265..288
Aerial/Source/Models/API/OpenWeather.swift on lines 223..246

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

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 4 locations. Consider refactoring.
Open

    private static func fetchData(from urlString: String, completion: @escaping (Result<String, NetworkError>) -> Void) {
        // check the URL is OK, otherwise return with a failure
        guard let url = URL(string: urlString) else {
            completion(.failure(.badURL))
            return
Severity: Major
Found in Aerial/Source/Models/API/Forecast.swift and 3 other locations - About 2 hrs to fix
Aerial/Source/Models/API/GeoCoding.swift on lines 83..106
Aerial/Source/Models/API/OneCall.swift on lines 265..288
Aerial/Source/Models/API/OpenWeather.swift on lines 223..246

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

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

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

import Foundation

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

    VideoList has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class VideoList {
        enum FilterMode {
            case location, cache, time, scene, source, rotation, favorite, hidden
        }
    
    
    Severity: Minor
    Found in Aerial/Source/Models/Sources/VideoList.swift - About 2 hrs to fix

      Function showVideo has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          func showVideo(_ video: AerialVideo) {
              playbackSpeedLabel.isHidden = false
              playbackSpeedSlider.isHidden = false
      
              
      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 makeHourBlock has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          func makeHourBlock(hour: FList, size: Double) -> CALayer {
              let mainLayer = CALayer()
      
              let isNight = hour.sys!.pod! == "n" ? true : false
      
      
      Severity: Major
      Found in Aerial/Source/Views/Layers/Weather/ForecastLayer.swift - About 2 hrs to fix

        Function makeLegendBlock has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            func makeLegendBlock(size: Double) -> CALayer {
                let mainLayer = CALayer()
        
                // Make a vertically centered layer for t°
                let windLayer = CAVCTextLayer()
        Severity: Major
        Found in Aerial/Source/Views/Layers/Weather/ForecastLayer.swift - About 2 hrs to fix

          Source has 24 methods (exceeds 20 allowed). Consider refactoring.
          Open

          struct Source: Codable {
              var name: String
              var description: String
              var manifestUrl: String
              var type: SourceType
          Severity: Minor
          Found in Aerial/Source/Models/Sources/Source.swift - About 2 hrs to fix

            Function move has 66 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                func move(toCorner: InfoCorner, fullRedraw: Bool) {
                    if let currCorner = currentCorner, !fullRedraw {
                        // Are we on the same corner ?
                        if currCorner == toCorner {
                            // And same height ?
            Severity: Major
            Found in Aerial/Source/Views/Layers/AnimatableLayer.swift - About 2 hrs to fix

              Function setupPlayerLayer has 65 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  func setupPlayerLayer(withPlayer player: AVPlayer) {
                      let displayDetection = DisplayDetection.sharedInstance
              
                      self.layer = CALayer()
                      guard let layer = self.layer else {
              Severity: Major
              Found in Aerial/Source/Views/AerialView+Player.swift - About 2 hrs to fix

                Function iconFor has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    static func iconFor(_ path: String, name: String) -> NSImage? {
                        if path.starts(with: "videos:location") {
                            return Aerial.helper.getAccentedSymbol("mappin.and.ellipse")
                        } else if path.starts(with: "videos:cache") && name == VideoList.instance.cacheDownloaded {
                            return Aerial.helper.getAccentedSymbol("internaldrive")
                Severity: Major
                Found in Aerial/Source/Models/Sources/Sidebar.swift - About 2 hrs to fix

                  Function tableView has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
                          guard let path = path else {
                              return nil
                          }
                  
                  
                  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 updateVideoView has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      func updateVideoView() {
                          if let video = getSelectedVideo() {
                              debugLog("\"\(video.id)\": \"sunrise\", // \(video.name) - \(video.secondaryName)")
                              debugLog("\"\(video.id)\": \"sunset\", // \(video.name) - \(video.secondaryName)")
                              debugLog("\"\(video.id)\": \"night\", // \(video.name) - \(video.secondaryName)")
                  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

                  Severity
                  Category
                  Status
                  Source
                  Language