fonoster/routr

View on GitHub

Showing 71 of 133 total issues

Method start has a Cognitive Complexity of 65 (exceeds 20 allowed). Consider refactoring.
Open

  @Throws(IOException::class, InterruptedException::class)
  fun start() {
    LOG.debug("Starting Restful service server")
    val mainCtx = createJSContext(REST_RUNNER)
    val rawConfig = mainCtx.eval("js", "JSON.stringify(getConfig())").toString()
Severity: Minor
Found in src/main/kotlin/io/routr/core/RestServer.kt - About 7 hrs 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 processRoute has 120 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async processRoute (transaction, request, route, routeInfo) {
    LOG.debug('Incoming request <== \n' + request)
    try {
      // Request origin transport
      const originTransport = request
Severity: Major
Found in mod/core/processor/request_handler.js - About 4 hrs to fix

    Method start has 92 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      @Throws(IOException::class, InterruptedException::class)
      fun start() {
        LOG.debug("Starting Restful service server")
        val mainCtx = createJSContext(REST_RUNNER)
        val rawConfig = mainCtx.eval("js", "JSON.stringify(getConfig())").toString()
    Severity: Major
    Found in src/main/kotlin/io/routr/core/RestServer.kt - About 3 hrs to fix

      Function exports has 90 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = upSince => {
        const config = {
          system: {
            upSince,
            version,
      Severity: Major
      Found in mod/core/config/config_defaults.js - About 3 hrs to fix

        Function sendResponse has 90 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async sendResponse (event) {
            LOG.debug(
              `core.processor.ResponseProcessor.sendResponse [Inconming response <=]`
            )
            LOG.debug(event.getResponse())
        Severity: Major
        Found in mod/core/processor/response_processor.js - About 3 hrs to fix

          File request_utils.js has 314 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          const LocatorUtils = require('@routr/location/utils')
          const { isLocalnet } = require('@routr/core/ip_util')
          const { equalsIgnoreCase, fixPort } = require('@routr/utils/misc_utils')
          const { RoutingType } = require('@routr/core/routing_type')
          const config = require('@routr/core/config_util')()
          Severity: Minor
          Found in mod/core/processor/request_utils.js - About 3 hrs to fix

            File files_datasource.js has 281 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /**
             * @author Pedro Sanders
             * @since v1
             */
            const CoreUtils = require('@routr/core/utils')
            Severity: Minor
            Found in mod/data_api/files_datasource.js - About 2 hrs to fix

              File request_handler.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /**
               * @author Pedro Sanders
               * @since v1
               */
              const { connectionException } = require('@routr/utils/exception_helpers')
              Severity: Minor
              Found in mod/core/processor/request_handler.js - About 2 hrs to fix

                Function exports has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports = (registry, sipStack, gatewaysAPI) => {
                  const SipListener = Java.extend(Java.type('javax.sip.SipListener'))
                  const store = new StoreAPI(SDSelector.getDriver())
                  return new SipListener({
                    processResponse: event => {
                Severity: Major
                Found in mod/registry/sip_listener.js - About 2 hrs to fix

                  Function process has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async process (event) {
                      const request = event.getRequest()
                      let transaction = event.getServerTransaction()
                  
                      if (
                  Severity: Major
                  Found in mod/core/processor/request_processor.js - About 2 hrs to fix

                    Function doProcess has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      doProcess (transaction) {
                        this.quanrentineHosts = this.quanrentineHosts.filter(quarentine)
                    
                        LOG.debug(
                          'List of gateways in quarantine: ' +
                    Severity: Major
                    Found in mod/core/processor/registry_handler.js - About 2 hrs to fix

                      Function getRoutingType has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        getRoutingType () {
                          let routingType = RoutingType.UNKNOWN
                          const callerType = this.getCallerType()
                          const calleetype = this.getCalleeType()
                          const belongToSameDomain = this.isSameDomain()
                      Severity: Major
                      Found in mod/core/processor/route_info.js - About 2 hrs to fix

                        Function processResponse has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            processResponse: event => {
                              const response = event.getResponse()
                              const gwURI = response
                                .getHeader(FromHeader.NAME)
                                .getAddress()
                        Severity: Major
                        Found in mod/registry/sip_listener.js - About 2 hrs to fix

                          Function listener has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            get listener () {
                              return new SipListener({
                                processRequest: event => {
                                  try {
                                    this.requestProcessor.process(event)
                          Severity: Major
                          Found in mod/core/processor/processor.js - About 2 hrs to fix

                            Function cancelTransaction has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              cancelTransaction (transaction) {
                                const storage = this.getStorage()
                                const iterator = storage.iterator()
                            
                                while (iterator.hasNext()) {
                            Severity: Major
                            Found in mod/core/context_storage.js - About 2 hrs to fix

                              Function createFromFile has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                static createFromFile (req, api) {
                                  if (
                                    !isEmpty(req.contentType()) &&
                                    req.contentType().indexOf('multipart/form-data') !== -1
                                  ) {
                              Severity: Major
                              Found in mod/rest/utils.js - About 2 hrs to fix

                                Function exports has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                module.exports = config => {
                                  const Properties = Java.type('java.util.Properties')
                                  const FileInputStream = Java.type('java.io.FileInputStream')
                                  const properties = new Properties()
                                  // for more options see:
                                Severity: Major
                                Found in mod/core/server_properties.js - About 2 hrs to fix

                                  Function exports has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  module.exports = (
                                    gateway,
                                    contactAddr,
                                    viaAddr,
                                    callId,
                                  Severity: Major
                                  Found in mod/registry/request_builder.js - About 2 hrs to fix

                                    Function resourceConstraintValidation has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      resourceConstraintValidation () {
                                        // Ensure GW for gwRef
                                        let response = this.withCollection('numbers').find()
                                    
                                        if (response.status === Status.OK) {
                                    Severity: Minor
                                    Found in mod/data_api/files_datasource.js - About 1 hr to fix

                                      Function createFromFile has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                        static createFromFile (req, api) {
                                          if (
                                            !isEmpty(req.contentType()) &&
                                            req.contentType().indexOf('multipart/form-data') !== -1
                                          ) {
                                      Severity: Minor
                                      Found in mod/rest/utils.js - 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