fonoster/routr

View on GitHub

Showing 133 of 133 total issues

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

      get("/system/info") { req, res -> evalOperation("getSystemInfo", req, res, rawConfig) }
Severity: Major
Found in src/main/kotlin/io/routr/core/RestServer.kt and 7 other locations - About 35 mins to fix
src/main/kotlin/io/routr/core/RestServer.kt on lines 103..103
src/main/kotlin/io/routr/core/RestServer.kt on lines 104..104
src/main/kotlin/io/routr/core/RestServer.kt on lines 106..106
src/main/kotlin/io/routr/core/RestServer.kt on lines 109..109
src/main/kotlin/io/routr/core/RestServer.kt on lines 111..111
src/main/kotlin/io/routr/core/RestServer.kt on lines 112..112
src/main/kotlin/io/routr/core/RestServer.kt on lines 113..113

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

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 8 locations. Consider refactoring.
Open

      post("/system/status/:status") { req, res -> evalOperation("postSystemStatus", req, res, rawConfig) }
Severity: Major
Found in src/main/kotlin/io/routr/core/RestServer.kt and 7 other locations - About 35 mins to fix
src/main/kotlin/io/routr/core/RestServer.kt on lines 103..103
src/main/kotlin/io/routr/core/RestServer.kt on lines 104..104
src/main/kotlin/io/routr/core/RestServer.kt on lines 108..108
src/main/kotlin/io/routr/core/RestServer.kt on lines 109..109
src/main/kotlin/io/routr/core/RestServer.kt on lines 111..111
src/main/kotlin/io/routr/core/RestServer.kt on lines 112..112
src/main/kotlin/io/routr/core/RestServer.kt on lines 113..113

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

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 8 locations. Consider refactoring.
Open

      get("/registry") { req, res -> evalOperation("getRegistry", req, res, rawConfig) }
Severity: Major
Found in src/main/kotlin/io/routr/core/RestServer.kt and 7 other locations - About 35 mins to fix
src/main/kotlin/io/routr/core/RestServer.kt on lines 103..103
src/main/kotlin/io/routr/core/RestServer.kt on lines 104..104
src/main/kotlin/io/routr/core/RestServer.kt on lines 106..106
src/main/kotlin/io/routr/core/RestServer.kt on lines 108..108
src/main/kotlin/io/routr/core/RestServer.kt on lines 109..109
src/main/kotlin/io/routr/core/RestServer.kt on lines 112..112
src/main/kotlin/io/routr/core/RestServer.kt on lines 113..113

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

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

Avoid too many return statements within this function.
Open

        return CoreUtils.buildResponse(Status.BAD_REQUEST, e.toString())
Severity: Major
Found in mod/rest/utils.js - About 30 mins to fix

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

          originInterfaceAddr.host !== targetInterfaceAddr.host ||
          originInterfaceAddr.port !== targetInterfaceAddr.port ||
          originInterfaceAddr.transport !== targetInterfaceAddr.transport
    Severity: Minor
    Found in mod/core/processor/request_utils.js and 1 other location - About 30 mins to fix
    mod/core/processor/request_utils.js on lines 46..48

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

    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

    Avoid too many return statements within this function.
    Open

        if (hasOwnProperty.call(obj, key)) return false
    Severity: Major
    Found in mod/utils/obj_util.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

        return true
      Severity: Major
      Found in mod/utils/obj_util.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                  return CoreUtils.buildResponse(
                    Status.BAD_REQUEST,
                    null,
                    'SyntaxError: Invalid JSON'
                  )
        Severity: Major
        Found in mod/rest/utils.js - About 30 mins to fix

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

            originInterfaceAddr.host === targetInterfaceAddr.host &&
            originInterfaceAddr.port === targetInterfaceAddr.port &&
            originInterfaceAddr.transport === targetInterfaceAddr.transport
          Severity: Minor
          Found in mod/core/processor/request_utils.js and 1 other location - About 30 mins to fix
          mod/core/processor/request_utils.js on lines 234..236

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

          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 aorAsObj has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            static aorAsObj (addressOfRecord) {
              if (
                typeof addressOfRecord === 'string' ||
                addressOfRecord instanceof String
              ) {
          Severity: Minor
          Found in mod/location/utils.js - About 25 mins 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 existInAnotherDomain has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            existInAnotherDomain (agent) {
              const response = this.getAgents(
                `@.spec.credentials.username=='${agent.spec.credentials.username}'`
              )
              for (const x in response.data) {
          Severity: Minor
          Found in mod/data_api/agents_api.js - About 25 mins 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 getCalleeFromAddressInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            static getCalleeFromAddressInfo (request, addressInfo) {
              const callee = {}
              for (const x in addressInfo) {
                let info = addressInfo[x]
                if (!!request.getHeader(info)) {
          Severity: Minor
          Found in mod/core/processor/route_info.js - About 25 mins 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 formatNet has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          const formatNet = net => {
            if (net.split('/').length === 1) {
              if (isValidIpv4(net)) return `${net}/32`
              if (isValidIpv6(net)) return `${net}/128`
              throw 'Invalid address! Must be a valid Ipv4 or Ipv6'
          Severity: Minor
          Found in mod/core/ip_util.js - About 25 mins 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