Showing 279 of 850 total issues
Function EventBus
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
var EventBus = function() {
"use strict";
var namespace, deprecationMap;
namespace = "typeahead:";
deprecationMap = {
Function Typeahead
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Typeahead(o, www) {
var onFocused, onBlurred, onEnterKeyed, onTabKeyed, onEscKeyed, onUpKeyed, onDownKeyed, onLeftKeyed, onRightKeyed, onQueryChanged, onWhitespaceChanged;
o = o || {};
if (!o.input) {
$.error("missing input");
Function testCustomCoder
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testCustomCoder() {
let jsonEncoder: () -> BodyEncoder = {
let encoder = JSONEncoder()
encoder.dateEncodingStrategy = .secondsSince1970
return encoder
Function Typeahead
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Typeahead(o, www) {
var onFocused, onBlurred, onEnterKeyed, onTabKeyed, onEscKeyed, onUpKeyed, onDownKeyed, onLeftKeyed, onRightKeyed, onQueryChanged, onWhitespaceChanged;
o = o || {};
if (!o.input) {
$.error("missing input");
Function testBasicGetSingle
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testBasicGetSingle() {
router.get("/users") { (id: Int, respondWith: (User?, RequestError?) -> Void) in
print("GET on /users/\(id)")
guard let user = self.userStore[id] else {
XCTFail("ERROR!!! Couldn't find user with id \(id)")
Function process
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
func process(request: RouterRequest, response: RouterResponse, parameterWalker: RouterParameterWalker, next: @escaping () -> Void) {
guard let path = request.parsedURLPath.path else {
Log.error("Failed to process request (path is nil)")
next()
return
Function handle
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public func handle(request: ServerRequest, response: ServerResponse) {
var decoder: (() -> BodyDecoder)?
if let contentType = request.headers["Content-Type"]?[0], let mediaType = MediaType(contentTypeHeader: contentType) {
decoder = decoders[mediaType]
}
Function setupRouter
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static func setupRouter() -> Router {
let subsubRouter = Router()
subsubRouter.get("/") { _, response, next in
response.status(HTTPStatusCode.OK).send("hello from the sub sub")
next()
Function testCodableDeleteQueryParameters
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testCodableDeleteQueryParameters() {
/// 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 performRequest
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
func performRequest(_ method: String, path: String, port: Int? = nil, socketPath: String? = nil, useSSL: Bool? = nil, useUnixSocket: Bool? = nil, followRedirects: Bool = true,
callback: @escaping ClientRequest.Callback, headers: [String: String]? = nil,
requestModifier: ((ClientRequest) -> Void)? = nil) {
let port = port ?? self.port
Function testHeaders
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testHeaders() {
var headers = Headers(headers: HeadersContainer())
headers.append("plover", value: "xyzzy")
headers.append("kitura", value: "The greatest")
Function testPostJSONRequest
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testPostJSONRequest() {
let jsonToTest = SomeJSON()
performServerTest(router) { expectation in
self.performRequest("post", path: "/bodytest", callback: { response in
Function startUnixSocketServer
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private func startUnixSocketServer(router: ServerDelegate, options: ServerOptions?) -> String? {
// Servers with options (live for duration of one test)
if (options != nil) {
let server = doStartUnixSocketServer(router: router, options: options)
return server?.unixDomainSocketPath
Function handleMatch
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static func handleMatch(rawHeaderValue: String, type: String, matchAllPattern: String,
criteriaMatches: inout CriteriaMatches, headerOrder: Int) {
let parsedHeaderValue = parse(mediaType: rawHeaderValue)
let headerType = parsedHeaderValue.type
guard !headerType.isEmpty && parsedHeaderValue.qValue > 0.0 else {
Function run
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public func run() {
// Construct a list of async tasks that will perform each
// request in turn and test their associated assertions
let tasks = requests.map { request in
return { (expectation: XCTestExpectation) 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 testDataIsNotCorrupted
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
func testDataIsNotCorrupted() {
// Corrupted files will have more bytes or less bytes than required
// So we check the file is intact after reconstructing it (after various range requests)
performServerTest(router) { expectation in
self.performRequest("get", path: "/qwer/index.html", 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 runGetResponseTest
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private func runGetResponseTest(path: String, expectedResponseText: String? = nil,
expectedStatusCode: HTTPStatusCode = HTTPStatusCode.OK,
bodyChecker: BodyChecker? = nil,
withRouter: Router? = nil) {
performServerTest(withRouter ?? router) { expectation 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 performRequest
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
func performRequest(_ method: String, path: String, port: Int? = nil, socketPath: String? = nil, useSSL: Bool? = nil, useUnixSocket: Bool? = nil, followRedirects: Bool = true,
callback: @escaping ClientRequest.Callback, headers: [String: String]? = nil,
requestModifier: ((ClientRequest) -> Void)? = nil) {
Function getFilePath
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
func getFilePath(from request: RouterRequest) -> String? {
var filePath = servingFilesPath
guard let requestPath = request.parsedURLPath.path 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 process
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
func process(request: RouterRequest, response: RouterResponse, parameterWalker: RouterParameterWalker, next: @escaping () -> Void) {
guard let path = request.parsedURLPath.path else {
Log.error("Failed to process request (path is nil)")
next()
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"