aequitas/macos-menubar-wireguard

View on GitHub

Showing 13 of 51 total issues

Function parse has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

  internal func parse(line: String) throws -> ContentType? {
    var cache = ""
    var state = State.Variable
    let stack = Stack<State>()

Severity: Minor
Found in WireGuardStatusbar/INIParser.swift - About 7 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 parse has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  internal func parse(line: String) throws -> ContentType? {
    var cache = ""
    var state = State.Variable
    let stack = Stack<State>()

Severity: Major
Found in WireGuardStatusbar/INIParser.swift - About 3 hrs to fix

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

    func buildMenu(tunnels: Tunnels,
                   allTunnelDetails: Bool = false,
                   connectedTunnelDetails: Bool = true,
                   showInstallInstructions _: Bool = false) -> [NSMenuItem] {
        guard !tunnels.isEmpty else {
    Severity: Minor
    Found in WireGuardStatusbar/Menu.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 buildMenu has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    func buildMenu(tunnels: Tunnels,
                   allTunnelDetails: Bool = false,
                   connectedTunnelDetails: Bool = true,
                   showInstallInstructions _: Bool = false) -> [NSMenuItem] {
        guard !tunnels.isEmpty else {
    Severity: Minor
    Found in WireGuardStatusbar/Menu.swift - About 1 hr to fix

      Function addPathToQueue has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private func addPathToQueue(_ path: String, notifyingAbout notification: SKQueueNotification) -> SKQueuePath? {
          var pathEntry = watchedPaths[path]
      
          if pathEntry != nil {
            if pathEntry!.notification.contains(notification) {
      Severity: Minor
      Found in WireGuardStatusbarHelper/SKQueue.swift - About 1 hr to fix

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

            func tunnelNames() -> [String] {
                var tunnelNames = [String]()
        
                // get names of all tunnel configurations
                for configPath in configPaths {
        Severity: Minor
        Found in WireGuardStatusbarHelper/WireGuard.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 installOrUpdateHelper has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            func installOrUpdateHelper(onFailure: @escaping (String?) -> Void, onSuccess: @escaping () -> Void) {
                helperStatus { installed in
                    if !installed {
                        // Invalidate the connection to force a reconnect to the newly installed helper
                        self.xpcHelperConnection?.invalidate()
        Severity: Minor
        Found in WireGuardStatusbar/HelperXPC.swift - About 55 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 var sec = _sections[currentTitle] {
                      sec[variable] = value
                      _sections[currentTitle] = sec
                    } else {
                      var sec: [String: String] = [:]
        Severity: Major
        Found in WireGuardStatusbar/INIParser.swift - About 45 mins to fix

          Function ev_create has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func ev_create(ident: UInt, filter: Int16, flags: UInt16, fflags: UInt32, data: Int, udata: UnsafeMutableRawPointer) -> kevent {
          Severity: Minor
          Found in WireGuardStatusbarHelper/SKQueue.swift - About 45 mins to fix

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

              public func toStrings() -> [SKQueueNotificationString] {
                var s = [SKQueueNotificationString]()
                if contains(.Rename) { s.append(.Rename) }
                if contains(.Write) { s.append(.Write) }
                if contains(.Delete) { s.append(.Delete) }
            Severity: Minor
            Found in WireGuardStatusbarHelper/SKQueue.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 addPathToQueue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              private func addPathToQueue(_ path: String, notifyingAbout notification: SKQueueNotification) -> SKQueuePath? {
                var pathEntry = watchedPaths[path]
            
                if pathEntry != nil {
                  if pathEntry!.notification.contains(notification) {
            Severity: Minor
            Found in WireGuardStatusbarHelper/SKQueue.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 registerWireGuardStateWatch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                func registerWireGuardStateWatch() {
                    // register watchers to respond to changes in wireguard config/runtime state
                    // will trigger: receivedNotification
                    if queue == nil {
                        queue = SKQueue(delegate: self)!
            Severity: Minor
            Found in WireGuardStatusbarHelper/Helper.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 listener has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                func listener(_: NSXPCListener, shouldAcceptNewConnection connection: NSXPCConnection) -> Bool {
                    NSLog("Client connected")
                    onConnect()
            
                    // Set the protocol that the calling application conforms to.
            Severity: Minor
            Found in WireGuardStatusbarHelper/AppXPC.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