twada/espower

View on GitHub

Showing 47 of 47 total issues

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

      {
        pattern: 'assert.deepStrictEqual(actual, expected, [message])',
        params: [
          { name: 'actual', options: { maxDepth: 2 } },
          { name: 'expected', options: { maxDepth: 2 } },
Severity: Major
Found in lib/default-options.js and 3 other locations - About 1 hr to fix
lib/default-options.js on lines 14..21
lib/default-options.js on lines 22..29
lib/default-options.js on lines 38..45

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

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

      enter: function (currentNode, parentNode) {
        if (/Function/.test(currentNode.type)) {
          scopeStack.push(scopeManager.acquire(currentNode));
        }
        const controller = this;
Severity: Minor
Found in lib/instrumentor.js - About 1 hr to fix

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

    const createPatternMatchers = (options) => {
      return options.patterns.map((p, index) => {
        const pattern = typeof p === 'string' ? p : p.pattern;
        const parsed = signature.parse(pattern);
        let matcher;
    Severity: Minor
    Found in lib/create-pattern-matchers.js - About 1 hr to fix

      Function appendMessage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        appendMessage (controller) {
          const currentNode = controller.current();
          if (this.messageUpdated) {
            // AssertionMessage is already merged with existing message argument
            return currentNode;
      Severity: Minor
      Found in lib/assertion-visitor.js - About 1 hr to fix

        Function exports has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function () {
          const _s = '\n\n      ';
        
          class AssertionMessage {
            /**
        Severity: Minor
        Found in templates/assertion-message.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

          arrowFunctionExpression (params, body, expression = false) {
            return this.createNode({
              type: syntax.ArrowFunctionExpression,
              params,
              body,
        Severity: Major
        Found in lib/create-node-with-loc.js and 2 other locations - About 50 mins to fix
        lib/create-node-with-loc.js on lines 79..86
        lib/create-node-with-loc.js on lines 120..127

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

        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

          memberExpression (object, property, computed = false) {
            return this.createNode({
              type: syntax.MemberExpression,
              object,
              property,
        Severity: Major
        Found in lib/create-node-with-loc.js and 2 other locations - About 50 mins to fix
        lib/create-node-with-loc.js on lines 111..118
        lib/create-node-with-loc.js on lines 120..127

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

        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

          unaryExpression (operator, argument, prefix = true) {
            return this.createNode({
              type: syntax.UnaryExpression,
              operator,
              argument,
        Severity: Major
        Found in lib/create-node-with-loc.js and 2 other locations - About 50 mins to fix
        lib/create-node-with-loc.js on lines 79..86
        lib/create-node-with-loc.js on lines 111..118

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

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

          matchArgument (currentNode, parentNode) {
            /* istanbul ignore next */
            if (isCalleeOfParent(currentNode, parentNode)) {
              return null;
            }
        Severity: Minor
        Found in lib/sig-matcher.js - About 45 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

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

              {
                pattern: 'assert.throws(fn, [error], [message])',
                params: [
                  { name: 'fn', block: true },
                  { name: 'error', block: true },
        Severity: Major
        Found in lib/default-options.js and 3 other locations - About 40 mins to fix
        lib/default-options.js on lines 54..61
        lib/default-options.js on lines 62..69
        lib/default-options.js on lines 70..77

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

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

              {
                pattern: 'assert.doesNotThrow(fn, [error], [message])',
                params: [
                  { name: 'fn', block: true },
                  { name: 'error', block: true },
        Severity: Major
        Found in lib/default-options.js and 3 other locations - About 40 mins to fix
        lib/default-options.js on lines 46..53
        lib/default-options.js on lines 62..69
        lib/default-options.js on lines 70..77

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

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

              {
                pattern: 'assert.rejects(asyncFn, [error], [message])',
                params: [
                  { name: 'asyncFn', block: true },
                  { name: 'error', block: true },
        Severity: Major
        Found in lib/default-options.js and 3 other locations - About 40 mins to fix
        lib/default-options.js on lines 46..53
        lib/default-options.js on lines 54..61
        lib/default-options.js on lines 70..77

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

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

              {
                pattern: 'assert.doesNotReject(asyncFn, [error], [message])',
                params: [
                  { name: 'asyncFn', block: true },
                  { name: 'error', block: true },
        Severity: Major
        Found in lib/default-options.js and 3 other locations - About 40 mins to fix
        lib/default-options.js on lines 46..53
        lib/default-options.js on lines 54..61
        lib/default-options.js on lines 62..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 49.

        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 espower = (ast, options) => {
          const instrumentor = new Instrumentor(Object.assign(defaultOptions(), options));
          return instrumentor.instrument(ast);
        };
        Severity: Minor
        Found in index.js and 1 other location - About 35 mins to fix
        index.js on lines 40..43

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

        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 createVisitor = (ast, options) => {
          const instrumentor = new Instrumentor(Object.assign(defaultOptions(), options));
          return instrumentor.createVisitor(ast);
        };
        Severity: Minor
        Found in index.js and 1 other location - About 35 mins to fix
        index.js on lines 25..28

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

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

        const findEspathOfAncestorNode = (targetNode, controller) => {
          // iterate child to root
          let child, parent;
          const path = controller.path();
          const parents = controller.parents();
        Severity: Minor
        Found in lib/create-node.js - About 35 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

        Avoid too many return statements within this function.
        Open

              return this.objectExpression(props);
        Severity: Major
        Found in lib/create-node-with-loc.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return result;
          Severity: Major
          Found in lib/create-node-with-loc.js - About 30 mins to fix

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

            const isPathIdentical = (path1, path2) => {
              return path1 && path2 && path1.join('/') === path2.join('/');
            };
            Severity: Minor
            Found in lib/argument-modification.js and 1 other location - About 30 mins to fix
            lib/assertion-visitor.js on lines 302..304

            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

                        return assertionVisitor.leaveArgument(controller);
            Severity: Major
            Found in lib/instrumentor.js - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language