zhuhaow/NEKit

View on GitHub

Showing 607 of 607 total issues

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

func resetPayloadAt(_ at: Int, length: Int) {
payload.resetBytes(in: at..<at+length)
}
Severity: Minor
Found in src/IPStack/DNS/DNSMessage.swift and 1 other location - About 30 mins to fix
src/IPStack/Packet/IPPacket.swift on lines 327..329

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

guard data.count > 0 else {
QueueFactory.getQueue().async {
self.delegate?.didWrite(data: data, by: self)
}
return
Severity: Minor
Found in src/RawSocket/GCDTCPSocket.swift and 1 other location - About 30 mins to fix
src/RawSocket/NWTCPSocket.swift on lines 123..128

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

public override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
guard keyPath == "state" else {
return
}
Severity: Minor
Found in src/RawSocket/NWUDPSocket.swift and 1 other location - About 30 mins to fix
src/RawSocket/NWTCPSocket.swift on lines 219..242

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

guard data.count > 0 else {
QueueFactory.getQueue().async {
self.delegate?.didWrite(data: data, by: self)
}
return
Severity: Minor
Found in src/RawSocket/NWTCPSocket.swift and 1 other location - About 30 mins to fix
src/RawSocket/GCDTCPSocket.swift on lines 161..166

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

override public func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
guard keyPath == "state" else {
return
}
 
 
Severity: Minor
Found in src/RawSocket/NWTCPSocket.swift and 1 other location - About 30 mins to fix
src/RawSocket/NWUDPSocket.swift on lines 100..115

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 nil
    Severity: Major
    Found in src/IPStack/Router.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 true
        Severity: Major
        Found in src/Messages/ConnectSession.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

            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 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 packet
                Severity: Major
                Found in src/IPStack/Router.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 (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 nil
                      Severity: Major
                      Found in src/Utils/IPMask.swift - About 30 mins to fix

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

                        let upperLowerBits = UInt128._variadicAdditionWithOverflowCount(
                        bitSegment7.truncatedValue >> 32,
                        bitSegment6.truncatedValue,
                        bitSegment5.truncatedValue << 32,
                        lowerLowerBits.overflowCount)
                        Severity: Minor
                        Found in src/Utils/UInt128.swift and 1 other location - About 30 mins to fix
                        src/Utils/UInt128.swift on lines 317..321

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

                        let lowerUpperBits = UInt128._variadicAdditionWithOverflowCount(
                        bitSegment5.truncatedValue >> 32,
                        bitSegment4.truncatedValue,
                        bitSegment3.truncatedValue << 32,
                        upperLowerBits.overflowCount)
                        Severity: Minor
                        Found in src/Utils/UInt128.swift and 1 other location - About 30 mins to fix
                        src/Utils/UInt128.swift on lines 312..316

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

                        override open func matchDNS(_ session: DNSSession, type: DNSSessionMatchType) -> DNSSessionMatchResult {
                        guard type == .ip else {
                        return .unknown
                        }
                         
                         
                        Severity: Minor
                        Found in src/Rule/DNSFailRule.swift - About 25 mins to fix

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

                        static func parseAdapterFactoryManager(_ config: Yaml) throws -> AdapterFactoryManager {
                        var factoryDict: [String: AdapterFactory] = [:]
                        factoryDict["direct"] = DirectAdapterFactory()
                        guard let adapterConfigs = config.array else {
                        throw ConfigurationParserError.noAdapterDefined
                        Severity: Minor
                        Found in src/Config/AdapterFactoryParser.swift - About 25 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language