dsl-toolkit/dsl-toolkit

View on GitHub

Showing 14 of 40 total issues

Function extractCallbackData has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

function extractCallbackData () {
  let baseKindArguments = Array.from(arguments)
  const argumentsLastIndex = baseKindArguments.length >= 2 ? baseKindArguments.length - 1 : false
  const argumentsOneBeforeLastIndex = baseKindArguments.length >= 3 ? argumentsLastIndex - 1 : false
  let trueCaseFunction = false
Severity: Minor
Found in packages/dsl-framework/src/core/command-parser/extractCallbackData.js - About 4 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 exports has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = (results, factories, services, parameters, composedStore) =>
  new Proxy(results, {
    get: (obj, prop) => {
      if(prop instanceof Promise){
        
Severity: Minor
Found in packages/demeter-di/src/proxy/containerProxyFactory.js - About 3 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 exports has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = (notHiddenVariablesReaches) => (baseProxy, containerKindData, registeredKeys) => new Proxy(baseProxy,{
    get: (obj, prop) => {
      const hidden = prop?.startsWith('_')
      !hidden && (()=>notHiddenVariablesReaches[prop] = notHiddenVariablesReaches[prop] ?
      notHiddenVariablesReaches[prop] + 1 : 1)()
Severity: Minor
Found in packages/demeter-di/src/proxy/hidden-tags-proxy/index.js - About 3 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 exports has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = (baseObject, returnObject) => {
  return kind =>
    function () {
      const {
        baseKindArguments,
Severity: Minor
Found in packages/dsl-framework/src/core/command-parser/get-base-kind.js - About 2 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 update has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

const update = async (dependencies) => {
  if (dependencies) {
    const currentBranch = require('./lib/get-current-branch')()
    const dependencyNames = Object.keys(dependencies)
    let allFine = true
Severity: Minor
Found in oldPackages/refresh-me/src/index.js - About 2 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

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

      const parameterNames = createDetails[2]
        ? arrayDsl(createDetails[2]).arrify()
        : parseScript(factoryDefinition.toString()).body[0].expression.params.map(e => e.name)
Severity: Major
Found in packages/demeter-di/src/container-methods/create.js and 1 other location - About 2 hrs to fix
packages/demeter-di/src/container-methods/compose.js on lines 14..15

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

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

      const parameterNames = composeDetails[2] ? arrayDsl(composeDetails[2]).arrify()
      : parseScript(service.toString()).body[0].expression.params.map(e => e.name)
Severity: Major
Found in packages/demeter-di/src/container-methods/compose.js and 1 other location - About 2 hrs to fix
packages/demeter-di/src/container-methods/create.js on lines 13..15

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

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

const update = async (dependencies) => {
  if (dependencies) {
    const currentBranch = require('./lib/get-current-branch')()
    const dependencyNames = Object.keys(dependencies)
    let allFine = true
Severity: Minor
Found in oldPackages/refresh-me/src/index.js - About 1 hr to fix

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

    function extractCallbackData () {
      let baseKindArguments = Array.from(arguments)
      const argumentsLastIndex = baseKindArguments.length >= 2 ? baseKindArguments.length - 1 : false
      const argumentsOneBeforeLastIndex = baseKindArguments.length >= 3 ? argumentsLastIndex - 1 : false
      let trueCaseFunction = false

      Function get has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          get: (obj, prop) => {
            const hidden = prop?.startsWith('_')
            !hidden && (()=>notHiddenVariablesReaches[prop] = notHiddenVariablesReaches[prop] ?
            notHiddenVariablesReaches[prop] + 1 : 1)()
            if (hidden) {
      Severity: Minor
      Found in packages/demeter-di/src/proxy/hidden-tags-proxy/index.js - About 1 hr to fix

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

            init: () => {
              const baseKind = getBaseKind(baseObject, returnObject)
        
              baseObject.has = baseKind('some')
              baseObject.get = baseKind('filter')
        Severity: Minor
        Found in packages/dsl-framework/src/core/command-parser/index.js - About 1 hr to fix

          Avoid too many return statements within this function.
          Open

                    return usedSoFar.map((usedKey) => allKeys.indexOf(usedKey) < 0 ? usedKey : false)
                      .filter((k) => k !== false)}}
          Severity: Major
          Found in packages/demeter-di/src/proxy/hidden-tags-proxy/index.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    if (!thisIsAFactory || !thisIsAService) return obj[prop]
            Severity: Major
            Found in packages/demeter-di/src/proxy/containerProxyFactory.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return obj[prop]}})
              Severity: Major
              Found in packages/demeter-di/src/proxy/hidden-tags-proxy/index.js - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language