Showing 279 of 850 total issues
Function testAcceptTypes
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testAcceptTypes() {
router.get("/customPage") { request, response, next in
XCTAssertEqual(request.accepts(type: "html"), "html", "Accepts did not return expected value")
Function DefaultMenu
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
var DefaultMenu = function() {
"use strict";
var s = Menu.prototype;
function DefaultMenu() {
Menu.apply(this, [].slice.call(arguments, 0));
Function DefaultMenu
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
var DefaultMenu = function() {
"use strict";
var s = Menu.prototype;
function DefaultMenu() {
Menu.apply(this, [].slice.call(arguments, 0));
Function testFormat
has 41 lines of code (exceeds 25 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))")
Function testErrorOverridesBody
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testErrorOverridesBody() {
let status = Status("This should not be sent")
router.get("/status") { (id: Int, respondWith: (Status?, RequestError?) -> Void) in respondWith(status, .conflict) }
router.post("/status") { (status: Status, respondWith: (Status?, RequestError?) -> Void) in respondWith(status, .conflict) }
router.put("/status") { (id: Int, status: Status, respondWith: (Status?, RequestError?) -> Void) in respondWith(status, .conflict) }
Function addCookie
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public func addCookie(name: String, value: String, domain: String, path: String, otherAttributes: [AdditionalCookieAttribute]? = nil ) {
var cookieProperties = [HTTPCookiePropertyKey: Any]()
cookieProperties[HTTPCookiePropertyKey.name] = name
cookieProperties[HTTPCookiePropertyKey.value] = value
cookieProperties[HTTPCookiePropertyKey.domain] = domain
Function cookieToServer
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private func cookieToServer(separator: String, quoteValue: Bool) {
performServerTest(router, asyncTasks: { expectation in
let cookieMap = [" Plover ": " value with spaces ",
"Zxcv": "(E = mc^2)",
"value with one quote": "\"",
- 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 setParameters
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private func setParameters(forRequest request: RouterRequest, fromUrlPath urlPath: NSString, match: NSTextCheckingResult) {
var parameters = mergeParameters ? request.parameters : [:]
if let keys = keys {
for index in 0..<keys.count {
- 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 testSubdomains
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testSubdomains() {
performServerTest(router) { expectation in
self.performRequest("get", path: "/subdomains", callback: { response in
XCTAssertNotNil(response, "ERROR!!! ClientRequest response object was nil")
XCTAssertEqual(response?.statusCode, HTTPStatusCode.OK, "HTTP Status code was \(String(describing: response?.statusCode))")
Function testRangeRequestsWithMultipleRanges
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testRangeRequestsWithMultipleRanges() {
performServerTest(router) { expectation in
self.performRequest("get", path: "/qwer/index.html", callback: { response in
defer {
expectation.fulfill()
Function testBasicPatch
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testBasicPatch() {
router.patch("/users") { (id: Int, patchUser: OptionalUser, respondWith: (User?, RequestError?) -> Void) -> Void in
print("PATCH on /users/\(id)")
guard let existingUser = self.userStore[id] else {
respondWith(nil, .notFound)
Function cookieToServer
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private func cookieToServer(separator: String, quoteValue: Bool) {
performServerTest(router, asyncTasks: { expectation in
let cookieMap = [" Plover ": " value with spaces ",
"Zxcv": "(E = mc^2)",
"value with one quote": "\"",
Function testBasicGetIdentifiersArray
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testBasicGetIdentifiersArray() {
let intTuple: [(Int, User)] = [(1, User(id: 1, name: "Andy")), (2, User(id: 2, name: "Dave")), (3, User(id: 3, name: "Ian"))]
// expectedIntData = [["1": User(id: 1, name: "Andy")], ["2": User(id: 2, name: "Dave")], ["3": User(id: 3, name: "Ian")]]
let expectedIntData: [[String: User]] = intTuple.map({ [$0.value: $1] })
Function testCodableGetSingleQueryParameters
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testCodableGetSingleQueryParameters() {
let date: Date = Coder.defaultDateFormatter.date(from: Coder.defaultDateFormatter.string(from: Date()))!
let expectedQuery = MyQuery(intField: 23, optionalIntField: 282, stringField: "a string", intArray: [1, 2, 3], dateField: date, optionalDateField: date, nested: Nested(nestedIntField: 333, nestedStringField: "nested string"))
Function testCodableGetArrayQueryParameters
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testCodableGetArrayQueryParameters() {
/// Currently the milliseconds are cut off by our date formatter
/// This synchronizes it for testing with the codable route
let date: Date = Coder.defaultDateFormatter.date(from: Coder.defaultDateFormatter.string(from: Date()))!
Function testAcceptEncodingTypes
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testAcceptEncodingTypes() {
router.get("/customPage") { request, response, next in
XCTAssertEqual(request.accepts(header: "Accept-Encoding", type: "gzip"), "gzip", "Accepts did not return expected value")
XCTAssertEqual(request.accepts(header: "Accept-Encoding", types: "compress"), "compress", "Accepts did not return expected value")
XCTAssertEqual(request.accepts(header: "Accept-Encoding", types: ["compress", "gzip"]), "gzip", "Accepts did not return expected value")
Function testMultipartFormParsing
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
func testMultipartFormParsing() {
// ensure NSData.components works just like String.components
dataComponentsTest("AxAyAzA", separator: "A")
dataComponentsTest("HelloWorld", separator: "World")
- 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 testPostJSONRequest
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
func testPostJSONRequest() {
let jsonToTest = SomeJSON()
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 testNoCookies
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testNoCookies() {
performServerTest(router, asyncTasks: { expectation in
self.performRequest("get", path: "/1/cookiedump", callback: {response in
XCTAssertEqual(response?.statusCode, HTTPStatusCode.OK, "cookiedump route did not match single path request")
do {
Function EventBus
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
var EventBus = function() {
"use strict";
var namespace, deprecationMap;
namespace = "typeahead:";
deprecationMap = {