zhuhaow/NEKit

View on GitHub

Showing 607 of 607 total issues

Function didRead has 34 lines of code (exceeds 25 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 1 hr to fix

    Function getCrypto has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            private func getCrypto(_ operation: CryptoOperation) -> StreamCryptoProtocol {
                switch algorithm {
                case .AES128CFB, .AES192CFB, .AES256CFB:
                    switch operation {
                    case .decrypt:
    Severity: Minor
    Found in src/Socket/AdapterSocket/Shadowsocks/CryptoStreamProcessor.swift - About 1 hr to fix

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

                  it("can be initailized with CIDR IP representation") {
                      for sample in cidrWrongSamples {
                          expect {try IPRange(withCIDRString: sample.0)}.to(throwError(sample.1))
                      }
      
      
      Severity: Major
      Found in test/Utils/IPRangeSpec.swift and 1 other location - About 1 hr to fix
      test/Utils/IPRangeSpec.swift on lines 51..59

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 86.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

                  it("can be initailized with IP range representation") {
                      for sample in rangeWrongSamples {
                          expect {try IPRange(withRangeString: sample.0)}.to(throwError(sample.1))
                      }
      
      
      Severity: Major
      Found in test/Utils/IPRangeSpec.swift and 1 other location - About 1 hr to fix
      test/Utils/IPRangeSpec.swift on lines 41..49

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 86.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

          open func didReceive(rawResponse: Data) {
              guard let message = DNSMessage(payload: rawResponse) else {
                  DDLogError("Failed to parse response from remote DNS server.")
                  return
              }
      Severity: Minor
      Found in src/IPStack/DNS/DNSServer.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 parseServerAdapterFactory has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          static func parseServerAdapterFactory(_ config: Yaml, type: HTTPAuthenticationAdapterFactory.Type) throws -> ServerAdapterFactory {
              guard let host = config["host"].string else {
                  throw ConfigurationParserError.adapterParsingError(errorInfo: "Host (host) is required.")
              }
      
      
      Severity: Minor
      Found in src/Config/AdapterFactoryParser.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 spec has 31 lines of code (exceeds 25 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 1 hr to fix

        Function outputSession has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            fileprivate func outputSession(_ session: DNSSession) {
                guard let result = session.matchResult else {
                    return
                }
        
        
        Severity: Minor
        Found in src/IPStack/DNS/DNSServer.swift - About 1 hr to fix

          Function checkReadData has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              fileprivate func checkReadData() {
                  if pendingReadData.count > 0 {
                      queueCall {
                          guard self.reading else {
                              // no queued read request
          Severity: Minor
          Found in src/RawSocket/TUNTCPSocket.swift - About 1 hr to fix

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

                override public func disconnect(becauseOf error: Error? = nil) {
                    super.disconnect(becauseOf: error)
            
                    _shouldConnect = false
                    pendingCount = 0
            Severity: Major
            Found in src/Socket/AdapterSocket/SpeedAdapter.swift and 1 other location - About 1 hr to fix
            src/Socket/AdapterSocket/SpeedAdapter.swift on lines 51..62

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 81.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                override public func forceDisconnect(becauseOf error: Error? = nil) {
                    super.forceDisconnect(becauseOf: error)
            
                    _shouldConnect = false
                    pendingCount = 0
            Severity: Major
            Found in src/Socket/AdapterSocket/SpeedAdapter.swift and 1 other location - About 1 hr to fix
            src/Socket/AdapterSocket/SpeedAdapter.swift on lines 38..49

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 81.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                public override func forceDisconnect(becauseOf error: Error? = nil) {
                    guard !isCancelled else {
                        return
                    }
            
            
            Severity: Major
            Found in src/Socket/AdapterSocket/RejectAdapter.swift and 1 other location - About 1 hr to fix
            src/Socket/AdapterSocket/RejectAdapter.swift on lines 22..32

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 80.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                public override func disconnect(becauseOf error: Error? = nil) {
                    guard !isCancelled else {
                        return
                    }
            
            
            Severity: Major
            Found in src/Socket/AdapterSocket/RejectAdapter.swift and 1 other location - About 1 hr to fix
            src/Socket/AdapterSocket/RejectAdapter.swift on lines 37..47

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 80.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function parseAdapterFactoryManager has 29 lines of code (exceeds 25 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 1 hr to fix

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

                  public func dividedReportingOverflow(by rhs: UInt128) -> (partialValue: UInt128, overflow: Bool) {
                      guard rhs != 0 else {
                          return (self, true)
                      }
                      
              Severity: Major
              Found in src/Utils/UInt128.swift and 1 other location - About 1 hr to fix
              src/Utils/UInt128.swift on lines 368..375

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 79.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

                  public func remainderReportingOverflow(dividingBy rhs: UInt128) -> (partialValue: UInt128, overflow: Bool) {
                      guard rhs != 0 else {
                          return (self, true)
                      }
                      
              Severity: Major
              Found in src/Utils/UInt128.swift and 1 other location - About 1 hr to fix
              src/Utils/UInt128.swift on lines 355..362

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 79.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

                  func buildMessage() -> Bool {
                      payload = Data(count: bytesLength)
                      if transactionID == 0 {
                          transactionID = UInt16(arc4random_uniform(UInt32(UInt16.max)))
                      }
              Severity: Minor
              Found in src/IPStack/DNS/DNSMessage.swift - About 1 hr to fix

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

                    open func disconnect(becauseOf error: Error? = nil) {
                        guard !isCancelled else {
                            return
                        }
                
                
                Severity: Major
                Found in src/Socket/ProxySocket/ProxySocket.swift and 1 other location - About 1 hr to fix
                src/Socket/ProxySocket/ProxySocket.swift on lines 108..118

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 76.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                import Foundation
                
                /// The SOCKS5 proxy server.
                public final class GCDSOCKS5ProxyServer: GCDProxyServer {
                    /**
                Severity: Major
                Found in src/ProxyServer/GCDSOCKS5ProxyServer.swift and 1 other location - About 1 hr to fix
                src/ProxyServer/GCDHTTPProxyServer.swift on lines 1..24

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 76.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                import Foundation
                
                /// The HTTP proxy server.
                public final class GCDHTTPProxyServer: GCDProxyServer {
                    /**
                Severity: Major
                Found in src/ProxyServer/GCDHTTPProxyServer.swift and 1 other location - About 1 hr to fix
                src/ProxyServer/GCDSOCKS5ProxyServer.swift on lines 1..24

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 76.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Severity
                Category
                Status
                Source
                Language