zhuhaow/NEKit

View on GitHub

Showing 70 of 607 total issues

Function readAndProcessPackets has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    func readAndProcessPackets() {
        NetworkInterface.TunnelProvider.packetFlow.readPacketsWithCompletionHandler() {
            var outputPackets = [IPMutablePacket]()
            let packets = $0.0.map { data in
                IPMutablePacket(payload: data)
Severity: Minor
Found in src/IPStack/Router.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

Function didRead has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public override func didRead(data: Data, from socket: RawTCPSocketProtocol) {
        super.didRead(data: data, from: socket)

        switch internalStatus {
        case .readingMethodResponse:
Severity: Minor
Found in src/Socket/AdapterSocket/SOCKS5Adapter.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

Function didReceive has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public func didReceive(session: ConnectSession, from: ProxySocket) {
        guard !isCancelled else {
            return
        }
        
Severity: Minor
Found in src/Tunnel/Tunnel.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

Function didBecomeReadyToForwardWith has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public func didBecomeReadyToForwardWith(socket: SocketProtocol) {
        guard let adapterSocket = socket as? AdapterSocket else {
            return
        }

Severity: Minor
Found in src/Socket/AdapterSocket/SpeedAdapter.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

Function parseSpeedAdapterFactory has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    static func parseSpeedAdapterFactory(_ config: Yaml, factoryDict: [String:AdapterFactory]) throws -> SpeedAdapterFactory {
        var factories: [(AdapterFactory, Int)] = []
        guard let adapters = config["adapters"].array else {
            throw ConfigurationParserError.adapterParsingError(errorInfo: "Speed Adatper should specify a set of adapters (adapters).")
        }
Severity: Minor
Found in src/Config/AdapterFactoryParser.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

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

            public override func output(data: Data) {
                if sendHeader {
                    outputStreamProcessor.output(data: data)
                } else {
                    var fakeRequestDataLength = inputStreamProcessor.key.count + HTTPProtocolObfuscater.headerLength
Severity: Minor
Found in src/Socket/AdapterSocket/Shadowsocks/ProtocolObfuscater.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 openSocketWith has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    override public func openSocketWith(session: ConnectSession) {
        for (adapter, _) in adapters {
            adapter.observer = nil
        }

Severity: Minor
Found in src/Socket/AdapterSocket/SpeedAdapter.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 readData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    override public func readData() {
        guard !isCancelled else {
            return
        }
        
Severity: Minor
Found in src/Socket/ProxySocket/HTTPProxySocket.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 parseDomainListRule has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    static func parseDomainListRule(_ config: Yaml, adapterFactoryManager: AdapterFactoryManager) throws -> DomainListRule {
        guard let adapter_id = config["adapter"].stringOrIntString else {
            throw ConfigurationParserError.ruleParsingError(errorInfo: "An adapter id (adapter_id) is required.")
        }

Severity: Minor
Found in src/Config/RuleParser.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 didRead has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    override public func didRead(data: Data, from: RawTCPSocketProtocol) {
        super.didRead(data: data, from: from)
        
        let result: HTTPStreamScanner.Result
        do {
Severity: Minor
Found in src/Socket/ProxySocket/HTTPProxySocket.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 match has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    func match(_ session: ConnectSession) -> AdapterFactory! {
        if session.matchedRule != nil {
            observer?.signal(.ruleMatched(session, rule: session.matchedRule!))
            return session.matchedRule!.match(session)
        }
Severity: Minor
Found in src/Rule/RuleManager.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

Avoid too many return statements within this function.
Open

        return true
Severity: Major
Found in src/Messages/ConnectSession.swift - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                    return socket === sock
    Severity: Major
    Found in src/IPStack/UDPDirectStack.swift - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return result
      Severity: Major
      Found in src/IPStack/UDPDirectStack.swift - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return (b, e)
        Severity: Major
        Found in src/Utils/IPMask.swift - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return true
          Severity: Major
          Found in src/IPStack/DNS/DNSServer.swift - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return nil
            Severity: Major
            Found in src/Utils/IPMask.swift - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return (baseIP, baseIP)
              Severity: Major
              Found in src/Utils/IPMask.swift - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return (IPAddress(ipv6InNetworkOrder: 0), IPAddress(ipv6InNetworkOrder: UInt128.max))
                Severity: Major
                Found in src/Utils/IPMask.swift - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return false
                  Severity: Major
                  Found in src/IPStack/DNS/DNSServer.swift - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language