zhuhaow/NEKit

View on GitHub

Showing 70 of 607 total issues

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

      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

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

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

          override func spec() {
              let testCases: [(String, Bool, String?, String?, Int?, String)] = [
                  ("http://google.com/ncr", true, "http", "google.com", nil, "ncr"),
                  ("http://google.com/", true, "http", "google.com", nil, ""),
                  ("http://google.com:8080/", true, "http", "google.com", 8080, ""),
      Severity: Minor
      Found in test/Utils/HTTPURLSpec.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          open func update(_ data: inout Data) {
              guard data.count > 0 else {
                  return
              }
      
      
      Severity: Minor
      Found in src/Crypto/SodiumStreamCrypto.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 addAndScan has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          open func addAndScan(_ data: Data) -> (Data?, Data)? {
              guard finished == false else {
                  return nil
              }
      
      
      Severity: Minor
      Found in src/Utils/StreamScanner.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 _quotientAndRemainderFullWidth has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          internal func _quotientAndRemainderFullWidth(dividingBy dividend: (high: UInt128, low: UInt128)) -> (quotient: UInt128, remainder: UInt128) {
              let divisor = self
              let numeratorBitsToWalk: UInt128
              
              if dividend.high > 0 {
      Severity: Minor
      Found in src/Utils/UInt128.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 didRead has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public func didRead(data: Data, from socket: SocketProtocol) {
              if let socket = socket as? ProxySocket {
                  observer?.signal(.proxySocketReadData(data, from: socket, on: self))
                  
                  guard !isCancelled else {
      Severity: Minor
      Found in src/Tunnel/Tunnel.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 didWrite has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public func didWrite(data: Data?, by socket: SocketProtocol) {
              if let socket = socket as? ProxySocket {
                  observer?.signal(.proxySocketWroteData(data, by: socket, on: self))
                  
                  guard !isCancelled else {
      Severity: Minor
      Found in src/Tunnel/Tunnel.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