Showing 279 of 850 total issues
Function update
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
update: function update(query) {
var that = this, canceled = false, syncCalled = false, rendered = 0;
this.cancel();
this.cancel = function cancel() {
canceled = true;
Function hightlight
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
return function hightlight(o) {
var regex;
o = _.mixin({}, defaults, o);
if (!o.node || !o.pattern) {
return;
Function testDataIsNotCorrupted
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function hightlight
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
return function hightlight(o) {
var regex;
o = _.mixin({}, defaults, o);
if (!o.node || !o.pattern) {
return;
Function update
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
update: function update(query) {
var that = this, canceled = false, syncCalled = false, rendered = 0;
this.cancel();
this.cancel = function cancel() {
canceled = true;
Function performSimpleMatch
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private func performSimpleMatch(path: String, request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) {
guard let pattern = pattern else {
next()
return
}
Function testConnectionRejectionCustomResponse
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function testHeaderModifiers
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
func testHeaderModifiers() {
router.get("/headerTest") { _, response, next in
response.headers.append("Content-Type", value: "text/html")
Function testBasicPut
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
func testBasicPut() {
router.put("/users") { (id: Int, user: User, respondWith: (User?, RequestError?) -> Void) in
print("PUT on /users/\(id)")
self.userStore[id] = user
respondWith(user, nil)
Function testBasicDeleteSingle
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
func testBasicDeleteSingle() {
router.delete("/users") { (id: Int, respondWith: (RequestError?) -> Void) in
print("DELETE on /users/\(id)")
guard let _ = self.userStore.removeValue(forKey: id) else {
respondWith(.notFound)
Function performServerTest
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
func performServerTest(_ router: ServerDelegate, options: ServerOptions? = nil, sslOption: SSLOption = SSLOption.both, socketTypeOption: SocketTypeOption = SocketTypeOption.both, timeout: TimeInterval = 10,
line: Int = #line, asyncTasks: [(XCTestExpectation) -> Void]) {
if sslOption != SSLOption.httpsOnly {
self.useSSL = false
if socketTypeOption != SocketTypeOption.unix {
Function getFilePath
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
func getFilePath(from request: RouterRequest) -> String? {
var filePath = servingFilesPath
guard let requestPath = request.parsedURLPath.path else {
return nil
}
Function constructIdentOutResultHandler
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
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)
Function handleHeaderLine
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private func handleHeaderLine(_ line: String, part: inout Part) {
if let labelRange = getLabelRange(of: "content-type:", in: line) {
part.type = String(line[line.index(after: labelRange.upperBound)...])
part.headers[.type] = line
return
Function send
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public func send<T : Encodable>(jsonp: T, callbackParameter: String = "callback") throws -> RouterResponse {
guard !state.invokedEnd else {
Log.warning("RouterResponse send(jsonp:) invoked after end() for \(self.request.urlURL)")
return self
}
Function testCodablePostSuccessStatuses
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
func testCodablePostSuccessStatuses() {
// Test POST success statuses other than .created
router.post("/ok") { (user: User, respondWith: (User?, RequestError?) -> Void) in
print("POST on /ok for user \(user)")
respondWith(user, .ok)
Function Input
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function Input(o, www) {
var id;
o = o || {};
if (!o.input) {
$.error("input is missing");
Function Input
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function Input(o, www) {
var id;
o = o || {};
if (!o.input) {
$.error("input is missing");
Function combinedRanges
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static func combinedRanges(ranges: [Range<UInt64>]) -> [Range<UInt64>] {
// map [Range]s to [IndexedRange]s and sort them by range.lowerBound
var index = 0
var ordered = ranges.map { range in
Function assertMatch
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
func assertMatch(_ target: String?, _ pattern: String, matchedGroups: inout [String], file: StaticString = #file, line: UInt = #line) {
guard let regex = try? NSRegularExpression(pattern: pattern, options: [])else {
return XCTFail("invalid pattern: \(pattern)", file: file, line: line)
}
guard let target = target 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"