enclose-io/compiler

View on GitHub
lts/lib/internal/streams/async_iterator.js

Summary

Maintainability
F
3 days
Test Coverage

Function createReadableStreamAsyncIterator has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const createReadableStreamAsyncIterator = (stream) => {
  const iterator = ObjectCreate(ReadableStreamAsyncIteratorPrototype, {
    [kStream]: { value: stream, writable: true },
    [kLastResolve]: { value: null, writable: true },
    [kLastReject]: { value: null, writable: true },
Severity: Minor
Found in lts/lib/internal/streams/async_iterator.js - About 1 hr to fix

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

      next() {
        // If we have detected an error in the meanwhile
        // reject straight away.
        const error = this[kError];
        if (error !== null) {
    Severity: Minor
    Found in lts/lib/internal/streams/async_iterator.js - About 1 hr to fix

      Function next has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        next() {
          // If we have detected an error in the meanwhile
          // reject straight away.
          const error = this[kError];
          if (error !== null) {
      Severity: Minor
      Found in lts/lib/internal/streams/async_iterator.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 promise;
      Severity: Major
      Found in lts/lib/internal/streams/async_iterator.js - About 30 mins to fix

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

          const iterator = ObjectCreate(ReadableStreamAsyncIteratorPrototype, {
            [kStream]: { value: stream, writable: true },
            [kLastResolve]: { value: null, writable: true },
            [kLastReject]: { value: null, writable: true },
            [kError]: { value: null, writable: true },
        Severity: Major
        Found in lts/lib/internal/streams/async_iterator.js and 1 other location - About 1 day to fix
        current/lib/internal/streams/async_iterator.js on lines 162..188

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

        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

          finished(stream, { writable: false }, (err) => {
            if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
              const reject = iterator[kLastReject];
              // Reject if we are waiting for data in the Promise returned by next() and
              // store the error.
        Severity: Major
        Found in lts/lib/internal/streams/async_iterator.js and 1 other location - About 1 day to fix
        current/lib/internal/streams/async_iterator.js on lines 191..214

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

        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

        function readAndResolve(iter) {
          const resolve = iter[kLastResolve];
          if (resolve !== null) {
            const data = iter[kStream].read();
            // We defer if data is null. We can be expecting either 'end' or 'error'.
        Severity: Major
        Found in lts/lib/internal/streams/async_iterator.js and 1 other location - About 3 hrs to fix
        current/lib/internal/streams/async_iterator.js on lines 30..42

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

        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

            if (lastPromise) {
              promise = new Promise(wrapForNext(lastPromise, this));
            } else {
              // Fast path needed to support multiple this.push()
              // without triggering the next() queue.
        Severity: Major
        Found in lts/lib/internal/streams/async_iterator.js and 1 other location - About 2 hrs to fix
        current/lib/internal/streams/async_iterator.js on lines 122..133

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

        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

        function wrapForNext(lastPromise, iter) {
          return (resolve, reject) => {
            lastPromise.then(() => {
              if (iter[kEnded]) {
                resolve(createIterResult(undefined, true));
        Severity: Major
        Found in lts/lib/internal/streams/async_iterator.js and 1 other location - About 1 hr to fix
        current/lib/internal/streams/async_iterator.js on lines 50..61

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

        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

              finished(stream, (err) => {
                if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
                  reject(err);
                } else {
                  resolve(createIterResult(undefined, true));
        Severity: Major
        Found in lts/lib/internal/streams/async_iterator.js and 1 other location - About 1 hr to fix
        current/lib/internal/streams/async_iterator.js on lines 70..76

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

        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

        There are no issues that match your filters.

        Category
        Status