balazsbotond/eslinq

View on GitHub
src/eslinq.js

Summary

Maintainability
F
3 days
Test Coverage

File eslinq.js has 521 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * ESLinq - LINQ for EcmaScript 2015
 *
 * An elegant way of working with ES6 iterables.
 *
Severity: Major
Found in src/eslinq.js - About 1 day to fix

    Sequence has 48 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class Sequence {
        /**
         * Creates a new `Sequence` instance wrapping the `iterable` specified.
         *
         * @param {Iterable} The `Iterable` to wrap.
    Severity: Minor
    Found in src/eslinq.js - About 6 hrs to fix

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

          union(other) {
              ensureIsIterable(other, "`other` should be iterable");
      
              const generator = function* () {
                  const seen = new Set();
      Severity: Minor
      Found in src/eslinq.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 count has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          count(matches) {
              if (matches === undefined) {
                  // If the wrapped iterable is an `Array`, `Map` or `Set`,
                  // we can use these O(1) shortcuts to get the length.
                  if (this.iterable instanceof Array) {
      Severity: Minor
      Found in src/eslinq.js - About 55 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 join has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          join(inner, getOuterKey, getInnerKey, transform = defaultJoinTransform) {
              ensureIsIterable(inner, "`inner` should be iterable");
              ensureIsFunction(getOuterKey, "`getOuterKey` should be a function");
              ensureIsFunction(getInnerKey, "`getInnerKey` should be a function");
              ensureIsFunction(transform, "`transform` should be a function");
      Severity: Minor
      Found in src/eslinq.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

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

          _elementAt(index) {
              const exhaustedResult = { element: undefined, exhausted: true },
                  valueResult = v => { return { element: v, exhausted: false }; };
      
              // O(1) optimization for arrays
      Severity: Minor
      Found in src/eslinq.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

      Function _single has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          _single(matches = constantTrue) {
              let found = false, item;
      
              for (let i of this.iterable) {
                  if (matches(i)) {
      Severity: Minor
      Found in src/eslinq.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

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

          last(matches = constantTrue) {
              ensureIsFunction(matches, "`matches` should be a function");
      
              const { found, item } = this._last(matches);
      
      
      Severity: Major
      Found in src/eslinq.js and 1 other location - About 1 hr to fix
      src/eslinq.js on lines 1424..1433

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

      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

          single(matches = constantTrue) {
              ensureIsFunction(matches, "`matches` should be a function");
      
              const { found, item } = this._single(matches);
      
      
      Severity: Major
      Found in src/eslinq.js and 1 other location - About 1 hr to fix
      src/eslinq.js on lines 1309..1318

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

      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

           orderBy(get, compare = compareDefault) {
               let result = Array.from(this.iterable);
               result.sort((a, b) => compare(get(a), get(b)));
               return new Sequence(result);
           }
      Severity: Major
      Found in src/eslinq.js and 1 other location - About 1 hr to fix
      src/eslinq.js on lines 649..653

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

      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

           orderByDescending(get, compare = compareDefault) {
               let result = Array.from(this.iterable);
               result.sort((a, b) => compare(get(b), get(a)));
               return new Sequence(result);
           }
      Severity: Major
      Found in src/eslinq.js and 1 other location - About 1 hr to fix
      src/eslinq.js on lines 636..640

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

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

                  for (let i of this.iterable) {
                      if (!seen.has(i)) {
                          seen.add(i);
                          yield i;
                      }
      Severity: Major
      Found in src/eslinq.js and 2 other locations - About 45 mins to fix
      src/eslinq.js on lines 512..517
      src/eslinq.js on lines 546..551

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

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

                  for (let i of this.iterable) {
                      if (!seen.has(i)) {
                          seen.add(i);
                          yield i;
                      }
      Severity: Major
      Found in src/eslinq.js and 2 other locations - About 45 mins to fix
      src/eslinq.js on lines 546..551
      src/eslinq.js on lines 606..611

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

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

                  for (let i of this.iterable) {
                      if (!seen.has(i)) {
                          seen.add(i);
                          yield i;
                      }
      Severity: Major
      Found in src/eslinq.js and 2 other locations - About 45 mins to fix
      src/eslinq.js on lines 512..517
      src/eslinq.js on lines 606..611

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

      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

          max(transform = identity, compare = compareDefault) {
              ensureIsFunction(transform, "`transform` should be a function");
              ensureIsFunction(compare, "`compare` should be a function");
      
              return this._findExtremum(
      Severity: Minor
      Found in src/eslinq.js and 1 other location - About 35 mins to fix
      src/eslinq.js on lines 986..993

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

      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

          min(transform = identity, compare = compareDefault) {
              ensureIsFunction(transform, "`transform` should be a function");
              ensureIsFunction(compare, "`compare` should be a function");
      
              return this._findExtremum(
      Severity: Minor
      Found in src/eslinq.js and 1 other location - About 35 mins to fix
      src/eslinq.js on lines 1057..1064

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

      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

      Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
      Open

      export default function from(iterable) {
      Severity: Minor
      Found in src/eslinq.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      There are no issues that match your filters.

      Category
      Status