IBM-Swift/Kitura

View on GitHub

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 = {
Severity: Minor
Found in docs/js/typeahead.jquery.js - About 1 hr to fix

    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");
    Severity: Minor
    Found in docs/js/typeahead.jquery.js - About 1 hr to fix

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

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

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

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

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

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

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

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

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

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

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

                              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
                              Severity: Minor
                              Found in Tests/KituraTests/KituraTestBuilder.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

                              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
                              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

                              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
                              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

                              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) {
                              Severity: Major
                              Found in Tests/KituraTests/KituraTest.swift - About 1 hr to fix

                                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
                                            }
                                Severity: Minor
                                Found in Sources/Kitura/staticFileServer/FileServer.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

                                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
                                Severity: Minor
                                Found in Sources/Kitura/RouterElement.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