Showing 279 of 850 total issues
Function testVerifyLinuxTestCount
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testVerifyLinuxTestCount() {
verifyCount(MiscellaneousTests.self)
verifyCount(TestBridgingHTTPStatusCode.self)
verifyCount(TestBridgingRequestError.self)
verifyCount(TestCodablePathParams.self)
Function setupRouter
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static func setupRouter() -> Router {
let router = Router()
router.get("/1/(plus)+") {_, response, next in
do {
Function getPart
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private func getPart(_ componentPart: Data) -> Part? {
guard let found = componentPart.range(of: endHeaderData, in: 0 ..< componentPart.count) else {
return nil
}
Function buildRegex
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
internal func buildRegex(fromPattern: String?, allowPartialMatch: Bool = false) -> (NSRegularExpression?, Bool, [String]?) {
guard let pattern = fromPattern else {
return (nil, false, nil)
}
Function constructTupleArrayOutResultHandler
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static func constructTupleArrayOutResultHandler<Id: Identifier, OutputType: Codable>(successStatus: HTTPStatusCode = .OK, response: RouterResponse, completion: @escaping () -> Void) -> IdentifierCodableArrayResultClosure<Id, OutputType> {
return { codableOutput, error in
var status = successStatus
if let error = error {
status = httpStatusCode(from: error)
Function testFormat
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
func testFormat() {
performServerTest(router) { expectation in
self.performRequest("get", path:"/format", callback: {response in
XCTAssertNotNil(response, "ERROR!!! ClientRequest response object was nil")
XCTAssertEqual(response?.statusCode, HTTPStatusCode.OK, "HTTP Status code was \(String(describing: response?.statusCode))")
- 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 testMergeParams
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
func testMergeParams() {
let simpleHandler = { (req: RouterRequest, res: RouterResponse, next: () -> Void) throws in
next()
}
- 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 testRangeRequestsWithMultipleRanges
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
func testRangeRequestsWithMultipleRanges() {
performServerTest(router) { expectation in
self.performRequest("get", path: "/qwer/index.html", callback: { response in
defer {
expectation.fulfill()
- 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 testPostRequestUrlEncoded
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
func testPostRequestUrlEncoded() {
performServerTest(router) { expectation in
self.performRequest("post", path: "/bodytest", callback: {response in
XCTAssertNotNil(response, "ERROR!!! ClientRequest response object was nil")
XCTAssertNotNil(response?.headers["Date"], "There was No Date header in the response")
- 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 testJsonp
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
func testJsonp() {
performServerTest(router) { expectation in
self.performRequest("get", path: "/jsonp?callback=testfn", callback: { response in
XCTAssertNotNil(response, "ERROR!!! ClientRequest response object was nil")
XCTAssertEqual(response?.statusCode, HTTPStatusCode.OK, "HTTP Status code was \(String(describing: response?.statusCode))")
- 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 getParser
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
class func getParser(contentType: String) -> BodyParserProtocol? {
// Handle Content-Type with parameters. For example, treat:
// "application/x-www-form-urlencoded; charset=UTF-8" as
// "application/x-www-form-urlencoded"
var contentTypeWithoutParameters = contentType
- 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 getPart
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private func getPart(_ componentPart: Data) -> Part? {
guard let found = componentPart.range(of: endHeaderData, in: 0 ..< componentPart.count) 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 handleMiddleware
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private func handleMiddleware<T1: TypeSafeMiddleware, T2: TypeSafeMiddleware, T3: TypeSafeMiddleware>(
_ middlewareOneType: T1.Type,
_ middlewareTwoType: T2.Type,
_ middlewareThreeType: T3.Type,
request: RouterRequest,
- 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 startServer
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private func startServer(router: ServerDelegate, options: ServerOptions?) -> Int? {
// Servers with options (live for duration of one test)
if options != nil {
let server = doStartServer(router: router, options: options)
return server?.port
- 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 selectResponseEncoder
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private func selectResponseEncoder(_ request: RouterRequest) -> (MediaType, BodyEncoder) {
let acceptHeader = request.headers["accept"]
if encoders.count == 1 ||
acceptHeader == nil ||
acceptHeader == "*" ||
- 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 constructResultHandler
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static func constructResultHandler(response: RouterResponse, completion: @escaping () -> Void) -> ResultClosure {
return { error in
if let error = error {
response.status(httpStatusCode(from: error))
do {
- 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 performServerTest
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
func performServerTest(_ router: ServerDelegate, options: ServerOptions? = nil, sslOption: SSLOption = SSLOption.both, socketTypeOption: SocketTypeOption = SocketTypeOption.both, timeout: TimeInterval = 10,
line: Int = #line, asyncTasks: (XCTestExpectation) -> Void...) {
Function performServerTest
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
func performServerTest(_ router: ServerDelegate, options: ServerOptions? = nil, sslOption: SSLOption = SSLOption.both, socketTypeOption: SocketTypeOption = SocketTypeOption.both, timeout: TimeInterval = 10,
line: Int = #line, asyncTasks: [(XCTestExpectation) -> Void]) {
Function assertParseError
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func assertParseError(_ size: UInt64, _ headerValue: String, error: RangeHeader.Error, combine: Bool = false , file: StaticString = #file, line: UInt = #line) {
Avoid deeply nested control flow statements. Open
for part in parts[1..<parts.count] {
let pieces = part.components(separatedBy: "=")
let piece = pieces[0].lowercased()
switch piece {
case "secure", "httponly":