Showing 70 of 607 total issues
Function readCallback
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private func readCallback(data: Data?) {
guard !cancelled else {
return
}
- Read upRead up
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 getNamefromData
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
static func getNamefromData(_ data: Data, offset: Int, base: Int = 0) -> (String, Int) {
let scanner = BinaryDataScanner(data: data, littleEndian: false)
scanner.skip(to: offset)
var len: UInt8 = 0
- Read upRead up
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 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 {
Function getNamefromData
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
static func getNamefromData(_ data: Data, offset: Int, base: Int = 0) -> (String, Int) {
let scanner = BinaryDataScanner(data: data, littleEndian: false)
scanner.skip(to: offset)
var len: UInt8 = 0
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:
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
}
- Read upRead up
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.")
}
- Read upRead up
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 outputSession
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
fileprivate func outputSession(_ session: DNSSession) {
guard let result = session.matchResult else {
return
}
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
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, ""),
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
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)))
}
Function rewritePacket
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public func rewritePacket(packet: IPMutablePacket) -> IPMutablePacket? {
// Support only TCP as for now
guard packet.proto == .TCP else {
return nil
}
- Read upRead up
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 rewritePacket
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public func rewritePacket(packet: IPMutablePacket) -> IPMutablePacket? {
// Support only TCP as for now
guard packet.proto == .TCP else {
return nil
}
Function didReceive
has 26 lines of code (exceeds 25 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
}
Function readAndProcessPackets
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
func readAndProcessPackets() {
NetworkInterface.TunnelProvider.packetFlow.readPacketsWithCompletionHandler() {
var outputPackets = [IPMutablePacket]()
let packets = $0.0.map { data in
IPMutablePacket(payload: data)
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)
- Read upRead up
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 findSocket
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
fileprivate func findSocket(connectInfo: ConnectInfo?, socket: NWUDPSocket?) -> (ConnectInfo, NWUDPSocket)? {
var result: (ConnectInfo, NWUDPSocket)?
queue.sync {
if connectInfo != nil {
- Read upRead up
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 input
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public override func input(data: Data) throws {
if readingFakeHeader {
buffer.append(data: data)
if buffer.get(to: Utils.HTTPData.DoubleCRLF) != nil {
readingFakeHeader = false
- Read upRead up
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 getCrypto
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private func getCrypto(_ operation: CryptoOperation) -> StreamCryptoProtocol {
switch algorithm {
case .AES128CFB, .AES192CFB, .AES256CFB:
switch operation {
case .decrypt:
- Read upRead up
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"