IBM-Swift/Kitura

View on GitHub

Showing 279 of 850 total issues

Function update has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            update: function update(query) {
                var that = this, canceled = false, syncCalled = false, rendered = 0;
                this.cancel();
                this.cancel = function cancel() {
                    canceled = true;
Severity: Minor
Found in docs/js/typeahead.jquery.js - About 1 hr to fix

    Function hightlight has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    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

          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
      Severity: Minor
      Found in Tests/KituraTests/TestStaticFileServer.swift - About 1 hr to fix

        Function hightlight has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                return function hightlight(o) {
                    var regex;
                    o = _.mixin({}, defaults, o);
                    if (!o.node || !o.pattern) {
                        return;
        Severity: Minor
        Found in docs/js/typeahead.jquery.js - About 1 hr to fix

          Function update has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          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

                private func performSimpleMatch(path: String, request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) {
                    guard let pattern = pattern else {
                        next()
                        return
                    }
            Severity: Minor
            Found in Sources/Kitura/RouterElement.swift - About 1 hr to fix

              Function testConnectionRejectionCustomResponse has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              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
              Severity: Minor
              Found in Tests/KituraTests/TestServerOptions.swift - About 1 hr to fix

                Function testHeaderModifiers has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    func testHeaderModifiers() {
                
                        router.get("/headerTest") { _, response, next in
                
                            response.headers.append("Content-Type", value: "text/html")
                Severity: Minor
                Found in Tests/KituraTests/TestResponse.swift - About 1 hr to fix

                  Function testBasicPut has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  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)
                  Severity: Minor
                  Found in Tests/KituraTests/TestCodableRouter.swift - About 1 hr to fix

                    Function testBasicDeleteSingle has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    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)
                    Severity: Minor
                    Found in Tests/KituraTests/TestCodableRouter.swift - About 1 hr to fix

                      Function performServerTest has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      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 {
                      Severity: Minor
                      Found in Tests/KituraTests/KituraTest.swift - About 1 hr to fix

                        Function getFilePath has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                func getFilePath(from request: RouterRequest) -> String? {
                                    var filePath = servingFilesPath
                                    guard let requestPath = request.parsedURLPath.path else {
                                        return nil
                                    }
                        Severity: Minor
                        Found in Sources/Kitura/staticFileServer/FileServer.swift - About 1 hr to fix

                          Function constructIdentOutResultHandler has 29 lines of code (exceeds 25 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)
                          Severity: Minor
                          Found in Sources/Kitura/CodableRouter.swift - About 1 hr to fix

                            Function handleHeaderLine has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            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
                            Severity: Minor
                            Found in Sources/Kitura/bodyParser/MultiPartBodyParser.swift - About 1 hr to fix

                              Function send has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              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
                                      }
                              Severity: Minor
                              Found in Sources/Kitura/RouterResponse.swift - About 1 hr to fix

                                Function testCodablePostSuccessStatuses has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                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)
                                Severity: Minor
                                Found in Tests/KituraTests/TestCodableRouter.swift - About 1 hr to fix

                                  Function Input has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                          function Input(o, www) {
                                              var id;
                                              o = o || {};
                                              if (!o.input) {
                                                  $.error("input is missing");
                                  Severity: Minor
                                  Found in docs/js/typeahead.jquery.js - About 1 hr to fix

                                    Function Input has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                    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

                                          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
                                      Severity: Minor
                                      Found in Sources/Kitura/staticFileServer/RangeHeader.swift - About 1 hr to fix

                                        Function assertMatch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                        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 {
                                        Severity: Minor
                                        Found in Tests/KituraTests/TestStaticFileServer.swift - About 1 hr to fix

                                        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

                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language