Showing 279 of 850 total issues
Function serveNonDirectoryFile
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private func serveNonDirectoryFile(_ filePath: String, response: RouterResponse) {
if !isValidFilePath(filePath) {
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
RouterResponse
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
public class RouterResponse {
// MARK: Properties
struct State {
Function testBuildRegexFromPattern
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testBuildRegexFromPattern() {
var regex: NSRegularExpression?
var isSimpleString = false
var strings: [String]?
Function handle
has a Cognitive Complexity of 18 (exceeds 5 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]
}
- 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 performSimpleMatch
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private func performSimpleMatch(path: String, request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) {
guard let pattern = pattern else {
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"
Further reading
Function testCustomCoderGet
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testCustomCoderGet() {
struct SimpleQuery: QueryParams {
let string: String
}
let jsonEncoder: () -> BodyEncoder = {
Function testMergeParams
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testMergeParams() {
let simpleHandler = { (req: RouterRequest, res: RouterResponse, next: () -> Void) throws in
next()
}
Function testParameters
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testParameters() {
let router = Router()
router.parameter("user") { request, response, value, next in
XCTAssertNotNil(value)
Function handleMatch
has a Cognitive Complexity of 17 (exceeds 5 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 {
- 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
File KituraTestBuilder.swift
has 260 lines of code (exceeds 250 allowed). Consider refactoring. Open
import XCTest
import Kitura
@testable import KituraNet
@testable import KituraContracts
Function testJsonp
has 56 lines of code (exceeds 25 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))")
File Router.swift
has 260 lines of code (exceeds 250 allowed). Consider refactoring. Open
import KituraNet
import LoggerAPI
import Foundation
import KituraTemplateEngine
import KituraContracts
Function testCustomCoder
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testCustomCoder() {
struct SimpleQuery: QueryParams {
let string: String
}
let jsonEncoder: () -> BodyEncoder = {
Function parse
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
static func parse(size: UInt64, headerValue: String, shouldCombine: Bool = true) throws -> RangeHeader {
guard let index = headerValue.range(of: "=")?.lowerBound else {
// malformed
throw RangeHeader.Error.malformed
Function constructIdentOutResultHandler
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static func constructIdentOutResultHandler<IdType: Identifier, OutputType: Codable>(successStatus: HTTPStatusCode = .OK, response: RouterResponse, completion: @escaping () -> Void) -> IdentifierCodableResultClosure<IdType, OutputType> {
return { id, codableOutput, error in
var status = successStatus
if let error = error {
status = httpStatusCode(from: error)
- 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 initialize
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
initialize: function initialize(o, datasets) {
var www;
datasets = _.isArray(datasets) ? datasets : [].slice.call(arguments, 1);
o = o || {};
www = WWW(o.classNames);
Function initialize
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
initialize: function initialize(o, datasets) {
var www;
datasets = _.isArray(datasets) ? datasets : [].slice.call(arguments, 1);
o = o || {};
www = WWW(o.classNames);
Function testPostRequestUrlEncoded
has 48 lines of code (exceeds 25 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")
Function testSimpleMatches
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
func testSimpleMatches() {
var router = Router()
router.all("/test", 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 testSimplePaths
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
func testSimplePaths() {
var router = Router()
router.all("", 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"