JohnCoates/Aerial

View on GitHub

Showing 376 of 1,136 total issues

Avoid too many return statements within this function.
Open

            return Aerial.helper.getAccentedSymbol("slider.horizontal.3")
Severity: Major
Found in Aerial/Source/Models/Sources/Sidebar.swift - About 30 mins to fix

    Function setStates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        func setStates() {
            locationMode.selectItem(at: PrefsInfo.weather.locationMode.rawValue)
            degreePopup.selectItem(at: PrefsInfo.weather.degree.rawValue)
            iconsPopup.selectItem(at: PrefsInfo.weather.icons.rawValue)
            weatherModePopup.selectItem(at: PrefsInfo.weather.mode.rawValue)
    Severity: Minor
    Found in Aerial/Source/Views/PrefPanel/InfoWeatherView.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

    Function getOppoMargin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        func getOppoMargin(corner: InfoCorner) -> CGFloat {
            // Handle the special cases of having something in the center
            if offsets.maxWidth[.topCenter]! > 0 && (corner == .topLeft || corner == .topRight) {
                return (baseLayer.visibleRect.size.width + offsets.maxWidth[.topCenter]!) / 2
            }
    Severity: Minor
    Found in Aerial/Source/Views/Layers/AnimationTextLayer.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

    Function addPlayerFades has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        func addPlayerFades(view: AerialView, player: AVPlayer, video: AerialVideo) {
            if !Aerial.helper.underCompanion {
                // We only fade in/out if we have duration
                if video.duration > 0 && AerialView.shouldFade && !shouldLoop {
                    let playbackSpeed = Double(PlaybackSpeed.forVideo(video.id))
    Severity: Minor
    Found in Aerial/Source/Views/AerialView+Player.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

    Function redrawCorner has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        func redrawCorner(corner: InfoCorner) {
            // first clear the offset on that corner
            offsets.corner[corner] = 0
    
            // Then move all our layers on that corner
    Severity: Minor
    Found in Aerial/Source/Views/Layers/LayerManager.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

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

        func tableView(_ tableView: NSTableView, acceptDrop info: NSDraggingInfo, row: Int, dropOperation: NSTableView.DropOperation) -> Bool {
    
            var oldIndexes = [Int]()
            info.enumerateDraggingItems(options: [], for: tableView, classes: [NSPasteboardItem.self], searchOptions: [:]) { dragItem, _, _ in
                if let str = (dragItem.item as! NSPasteboardItem).string(forType: self.dragDropType), let index = Int(str) {
    Severity: Minor
    Found in Aerial/Source/Views/PrefPanel/InfoTableSource.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

    Function getSymbol has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        func getSymbol(condition: Int, isNight: Bool) -> String {
            if isNight && nightSymbols[condition] != nil {
                return nightSymbols[condition]!
            } else {
                if mainSymbols[condition] != nil {
    Severity: Minor
    Found in Aerial/Source/Views/Layers/Weather/ConditionSymbolLayer.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

    Function imageButtonClick has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        @IBAction func imageButtonClick(_ sender: NSButton) {
            let path = hiddenPath.stringValue
            
            if sender.state == .on {
                sender.image = Aerial.helper.getSymbol("checkmark.circle.fill")

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

        override func setupForVideo(video: AerialVideo, player: AVPlayer) {
            // Only run this once
            if !wasSetup {
                wasSetup = true
    
    
    Severity: Minor
    Found in Aerial/Source/Views/Layers/CountdownLayer.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

    Function test has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        func test() {
            nightSymbols.forEach { (key: Int, value: String) in
                let imagePath = Bundle(for: PanelWindowController.self).path(
                forResource: getSymbol(condition: key, isNight: true),
                ofType: "pdf")
    Severity: Minor
    Found in Aerial/Source/Views/Layers/Weather/ConditionSymbolLayer.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

    Function updateStatus has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        func updateStatus() {
            let percent = Battery.getRemainingPercent()
    
            if PrefsInfo.battery.disableWhenFull {
                if percent == 100 {
    Severity: Minor
    Found in Aerial/Source/Views/Layers/BatteryIconLayer.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

    Function getCurrentSleepTime has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        func getCurrentSleepTime() -> Int {
            // pmset -g | grep "^[ ]*sleep" | awk '{ print $2 }'
    
            let pipe1 = Pipe()
            let pmset = Process()
    Severity: Minor
    Found in Aerial/Source/Models/Time/TimeManagement.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

    Function setupPlayer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        func setupPlayer() {
            if let player = previewView.player {
                if let video = currentVideo {
                    player.pause()
    
    
    Severity: Minor
    Found in Resources/MainUI/First time setup/VideoFormatViewController.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

    Function reloadPath has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        func reloadPath(path: String) {
            if let foundMode = VideoList.instance.modeFromPath(path) {
                switchMainTo(filter: foundMode)
    
                rotationPopupChange(rotationPopup)
    Severity: Minor
    Found in Resources/MainUI/VideosViewController.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

    Function mainImageClick has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        @IBAction func mainImageClick(_ sender: NSButton) {
            let path = hiddenPath.stringValue
            
            if checkImageButton.state == .on {
                checkImageButton.state = .off

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

        func cleanupSharedViews() {
            if AerialView.singlePlayerAlreadySetup {
                if let index = AerialView.sharedPlayerIndex {
                    if AerialView.instanciatedViews[index].wasStopped {
                        AerialView.singlePlayerAlreadySetup = false
    Severity: Minor
    Found in Aerial/Source/Views/AerialView.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

    Function fetchData has a Cognitive Complexity of 6 (exceeds 5 allowed). 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: Minor
    Found in Aerial/Source/Models/API/Forecast.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

    Function fetchData has a Cognitive Complexity of 6 (exceeds 5 allowed). 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: Minor
    Found in Aerial/Source/Models/API/OpenWeather.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

    Function loadMetaManifest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        static func loadMetaManifest(url: URL) -> [Source]? {
            // Let's make sure we have the required files
            if !areManifestPresent(url: url) && !url.absoluteString.starts(with: "http") {
                return nil
            }
    Severity: Minor
    Found in Aerial/Source/Models/Sources/SourceList.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

    Function fetchData has a Cognitive Complexity of 6 (exceeds 5 allowed). 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: Minor
    Found in Aerial/Source/Models/API/GeoCoding.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

    Severity
    Category
    Status
    Source
    Language