Showing 850 of 850 total issues
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 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 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 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 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"
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 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
Parentheses should not be preceded by whitespace Open
private init () {
- Exclude checks
Parameter clause in closure signature should be preceded by exactly one space Open
self.performRequest("get", path: "/qwer", callback: {response in
- Exclude checks
Parameter clause in closure signature should be preceded by exactly one space Open
router.get("/1/(plus)+") {_, response, next in
- Exclude checks
TODO comments should be formatted either as <todo: description> or <todo description></todo></todo:> Open
// swiftlint:enable todo
- Read upRead up
- Exclude checks
todo-syntax
TODO comments should be defined separately using non-nested single line comments. They should adhere to the <TODO: description>
or <TODO(developer-name): description>
syntax. Empty TODO comments will be flagged.
Preferred
// TODO: <insert mandatory todo comment>
// TODO(dev-name): <insert mandatory todo comment></insert></insert>
Not Preferred
// TODO:
/// TODO: Documentation comments should not have TODOs
//// TODO: Nested comments should not have TODOs
// //TODO: Nested comments should not have TODOs
// TODO: Nested comments should not have TODOs // some comment
//// TODO: Nested comments should not have TODOs
Parameter clause in closure signature should be preceded by exactly one space Open
router.get("/2/sendcookie") {request, response, next in
- Exclude checks
Closure is the function's final argument and may be passed as a trailing closure instead Open
}, { expectation in
- Read upRead up
- Exclude checks
trailing-closure
Closures that are the last argument of a function should be passed into the function using trailing closure syntax.
Preferred
reversed = names.sort { s1, s2 in return s1 > s2 }
Not Preferred
reversed = names.sort({ s1, s2 in return s1 > s2 })
Parameter clause in closure signature should be preceded by exactly one space Open
self.performRequest("get", path: "/3/question", callback: {response in
- Exclude checks
Global Constant should be either lowerCamelCase or UpperCamelCase Open
let percent_grade: Int
- Read upRead up
- Exclude checks
constant-naming
Global constants should follow either UpperCamelCase or lowerCamelCase naming conventions. Local constants should follow lowerCamelCase naming conventions.
Preferred
let MaxHeight = 42
let maxHeight = 42
Not Preferred
let max_height = 42
Parameter clause in closure signature should be preceded by exactly one space Open
self.performRequest("get", path:"/qwer", callback: {response in
- Exclude checks
Operator definitions should be followed by exactly one space Open
static func ==(lhs: Status, rhs: Status) -> Bool {
- Exclude checks
Parameter clause in closure signature should be preceded by exactly one space Open
self.performRequest("get", path: "/1/plus/plus", callback: {response in
- Exclude checks