Showing 279 of 850 total issues
Function testSimpleSub
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func testSimpleSub() {
performServerTest(router, asyncTasks: { expectation in
self.performRequest("get", path:"/sub", 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 testRouteFunc
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func testRouteFunc() {
performServerTest(router, asyncTasks: { expectation in
self.performRequest("get", path: "/route", 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 testStaticFileServerRedirectPreservingQueryParams
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func testStaticFileServerRedirectPreservingQueryParams() {
performServerTest(router) { expectation in
self.performRequest("get", path: "/queryparams?a=b&c=d", followRedirects: false, 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 testRawDataPost
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func testRawDataPost() {
performServerTest(router) { expectation in
self.performRequest("post",
path: "/bodytest",
callback: { response in
- 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 runTestParameters
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private func runTestParameters(pathParameter: String, queryParameter: String,
expectedReturnedPathParameter: String? = nil,
expectedReturnedQueryParameter: String? = nil) {
let expectedReturnedPathParameter = expectedReturnedPathParameter ?? pathParameter
let expectedReturnedQueryParameter = expectedReturnedQueryParameter ?? queryParameter
- 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 testSubSubs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func testSubSubs() {
performServerTest(router, asyncTasks: { expectation in
self.performRequest("get", path:"/sub/sub2", 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 testRouteWithPercentEncoding
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func testRouteWithPercentEncoding() {
let router = Router()
router.get("/say hello", handler: makeHandler(helloworld + " with whitespace"))
router.get("/say%20hello", handler: makeHandler(helloworld + " with %20"))
router.get("/say+hello", handler: makeHandler(helloworld + " with +"))
- 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 testSimpleCustomMatches
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func testSimpleCustomMatches() {
var router = Router()
router.all("/:id(\\d+)", handler: handler)
- 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 testConnectionRejection
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func testConnectionRejection() {
let numClients = 5 // Number of clients to connect
let maxClients = 2 // Maximum number of concurrent clients
// Create client status objects and expectations
- 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 testConnectionRejectionCustomResponse
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func testConnectionRejectionCustomResponse() {
let numClients = 5 // Number of clients to connect
let maxClients = 2 // Maximum number of concurrent clients
// Create client status objects and expectations
- 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 testExternSub
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func testExternSub() {
router.all("/extern", middleware: ExternSubrouter.getRouter())
performServerTest(router, asyncTasks: { expectation in
self.performRequest("get", path:"/extern", callback: {response in
- 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 end
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public func end() throws {
guard !state.invokedEnd else {
Log.warning("RouterResponse end() invoked more than once for \(self.request.urlURL)")
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 readCodableOrSetResponseStatus
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static func readCodableOrSetResponseStatus<InputType: Codable>(_ inputCodableType: InputType.Type, from request: RouterRequest, response: RouterResponse) -> InputType? {
guard request.decoder != nil else {
response.status(.unsupportedMediaType)
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 parse
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func parse(_ data: Data) -> ParsedBody? {
var parts: [Part] = []
// split the body into component parts separated by the boundary, drop the preamble part
let componentParts = data.components(separatedBy: boundaryData).dropFirst()
- 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 getAbsolutePath
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static func getAbsolutePath(for path: String) -> String {
var path = path
if path.hasSuffix(separator) && path != separator {
path = String(path.dropLast())
}
- 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 trimASCIIWhitespace
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func trimASCIIWhitespace() -> Substring {
// Trim whitespace (Space or TAB) from the front of a string
let trimmedPrefix = self.drop(while: { $0 == " " || $0 == "\u{0009}" })
// If the string is now empty, return early
guard !trimmedPrefix.isEmpty else {
- 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 buildRegex
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
internal func buildRegex(fromPattern: String?, allowPartialMatch: Bool = false) -> (NSRegularExpression?, Bool, [String]?) {
guard let pattern = fromPattern else {
return (nil, false, 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 handle
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
open func handle(request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) {
defer {
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 performRenderServerTest
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private func performRenderServerTest(withRouter router: Router, onPath path: String) {
performServerTest(router) { expectation in
self.performRequest("get", path: path, callback: { response in
guard let response = response else {
XCTFail("Got nil 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"