fonoster/routr

View on GitHub

Showing 133 of 133 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        "restart-server" -> {
          val timer = Timer()
          timer.schedule(
              object : TimerTask() {
                override fun run() {
Severity: Major
Found in src/main/kotlin/io/routr/core/GRPCServer.kt and 1 other location - About 1 hr to fix
src/main/kotlin/io/routr/core/GRPCServer.kt on lines 58..69

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 123.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    this.jedisPool = new JedisPool(
      this.buildPoolConfig(),
      this.parameters.host,
      parseInt(this.parameters.port),
      parseInt(this.parameters.timeout),
Severity: Major
Found in mod/data_api/redis_store.js and 1 other location - About 1 hr to fix
mod/data_api/redis_datasource.js on lines 47..53

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 66.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function configureRoute has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const configureRoute = (request, originInterfaceAddr, targetInterfaceAddr) => {
  const requestOut = request.clone()
  const routeHeader = request.getHeader(RouteHeader.NAME)
  if (routeHeader) {
    const host = routeHeader
Severity: Minor
Found in mod/core/processor/request_utils.js - About 1 hr to fix

    Function getWithMetadata has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      getWithMetadata (list) {
        const date = new Date(this.config.system.upSince).toISOString()
        list.forEach(obj => {
          obj.metadata.createdOn = date
          obj.metadata.modifiedOn = date
    Severity: Minor
    Found in mod/data_api/files_datasource.js - About 1 hr to fix

      Function buildSipProvider has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        buildSipProvider (sipStack, transport) {
          let sipProvider
      
          for (const key in transport) {
            const curTransport = transport[key]
      Severity: Minor
      Found in mod/core/server.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

      Function getRoutingType has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        getRoutingType () {
          let routingType = RoutingType.UNKNOWN
          const callerType = this.getCallerType()
          const calleetype = this.getCalleeType()
          const belongToSameDomain = this.isSameDomain()
      Severity: Minor
      Found in mod/core/processor/route_info.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

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

            expect(defaults)
              .to.have.property('spec')
              .to.have.property('localnets')
              .to.be.a('array')
              .lengthOf(0)
      Severity: Major
      Found in mod/core/config.unit.test.js and 2 other locations - About 1 hr to fix
      mod/core/config.unit.test.js on lines 72..76
      mod/core/config.unit.test.js on lines 78..82

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 63.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

            expect(config)
              .to.have.property('spec')
              .to.have.property('localnets')
              .to.be.a('array')
              .lengthOf(1)
      Severity: Major
      Found in mod/core/config.unit.test.js and 2 other locations - About 1 hr to fix
      mod/core/config.unit.test.js on lines 78..82
      mod/core/config.unit.test.js on lines 104..108

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 63.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

            expect(config)
              .to.have.property('spec')
              .to.have.property('transport')
              .to.be.a('array')
              .lengthOf(3)
      Severity: Major
      Found in mod/core/config.unit.test.js and 2 other locations - About 1 hr to fix
      mod/core/config.unit.test.js on lines 72..76
      mod/core/config.unit.test.js on lines 104..108

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 63.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function findEndpoint has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        findEndpoint (addressOfRecord) {
          LOG.debug(
            `location.Locator.findEndpoint [lookup route for aor ${addressOfRecord}]`
          )
      
      
      Severity: Minor
      Found in mod/location/locator.js - About 1 hr to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            if (
              callee &&
              callee.spec &&
              callee.spec.credentials &&
              callee.spec.credentials.secret
        Severity: Major
        Found in mod/core/processor/request_processor.js and 1 other location - About 1 hr to fix
        mod/registry/registry.js on lines 55..62

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 62.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            if (
              gatewayCopy &&
              gatewayCopy.spec &&
              gatewayCopy.spec.credentials &&
              gatewayCopy.spec.credentials.secret
        Severity: Major
        Found in mod/registry/registry.js and 1 other location - About 1 hr to fix
        mod/core/processor/request_processor.js on lines 46..53

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 62.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function addEndpoint has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          addEndpoint (addressOfRecord, route) {
            // This must be done here before we convert contactURI into a string
            route.contactURI = route.contactURI.toString()
        
            LOG.debug(
        Severity: Minor
        Found in mod/location/locator.js - About 1 hr to fix

          Function subscribeToPostal has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            subscribeToPostal () {
              const aorAsString = a => LocatorUtils.aorAsString(a)
              postal.subscribe({
                channel: 'locator',
                topic: 'endpoint.remove',
          Severity: Minor
          Found in mod/location/locator.js - About 1 hr to fix

            Function configureContact has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const configureContact = request => {
              const requestOut = request.clone()
            
              const contactHeader = requestOut.getHeader(ContactHeader.NAME)
            
            
            Severity: Minor
            Found in mod/core/processor/request_utils.js - About 1 hr to fix

              Function staticConfigValidation has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                staticConfigValidation () {
                  for (const cnt in RESOURCES) {
                    try {
                      const res = FilesUtil.readFile(
                        `${this.filesPath}/${RESOURCES[cnt]}.yml`
              Severity: Minor
              Found in mod/data_api/files_datasource.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

              Function connectionException has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports.connectionException = (e, host, transaction, route) => {
                const { sendResponse } = require('@routr/core/processor/processor_utils')
                let isInternal = false
                if (
                  e instanceof Java.type('javax.sip.TransactionUnavailableException') ||
              Severity: Minor
              Found in mod/utils/exception_helpers.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

              Function exports has a Cognitive Complexity of 11 (exceeds 5 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: Minor
              Found in mod/registry/sip_listener.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

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

                find (filter = '*', page = 1, itemsPerPage = Long.MAX_VALUE) {
                  if (!isEmpty(filter) && filter !== '*') {
                    filter = `*.[?(${filter})]`
                  }
              
              
              Severity: Minor
              Found in mod/data_api/files_datasource.js - About 1 hr to fix

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

                  constructor (request, dataAPIs) {
                    const fromHeader = request.getHeader(FromHeader.NAME)
                    const toHeader = request.getHeader(ToHeader.NAME)
                    this.request = request
                    this._callerUser = fromHeader
                Severity: Minor
                Found in mod/core/processor/route_info.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language