huridocs/uwazi

View on GitHub
app/react/utils/specs/prioritySortingCriteria.spec.js

Summary

Maintainability
D
2 days
Test Coverage

Arrow function has too many statements (12). Maximum allowed is 10.
Open

  describe('Priority sorting', () => {

title: max-statements ruletype: suggestion relatedrules: - complexity - max-depth - max-len - max-lines - max-lines-per-function - max-nested-callbacks

- max-params

The max-statements rule allows you to specify the maximum number of statements allowed in a function.

function foo() {
  var bar = 1; // one statement
  var baz = 2; // two statements
  var qux = 3; // three statements
}

Rule Details

This rule enforces a maximum number of statements allowed in function blocks.

Options

This rule has a number or object option:

  • "max" (default 10) enforces a maximum number of statements allows in function blocks

Deprecated: The object property maximum is deprecated; please use the object property max instead.

This rule has an object option:

  • "ignoreTopLevelFunctions": true ignores top-level functions

max

Examples of incorrect code for this rule with the default { "max": 10 } option:

::: incorrect

/*eslint max-statements: ["error", 10]*/
/*eslint-env es6*/

function foo() {
  var foo1 = 1;
  var foo2 = 2;
  var foo3 = 3;
  var foo4 = 4;
  var foo5 = 5;
  var foo6 = 6;
  var foo7 = 7;
  var foo8 = 8;
  var foo9 = 9;
  var foo10 = 10;

  var foo11 = 11; // Too many.
}

let foo = () => {
  var foo1 = 1;
  var foo2 = 2;
  var foo3 = 3;
  var foo4 = 4;
  var foo5 = 5;
  var foo6 = 6;
  var foo7 = 7;
  var foo8 = 8;
  var foo9 = 9;
  var foo10 = 10;

  var foo11 = 11; // Too many.
};

:::

Examples of correct code for this rule with the default { "max": 10 } option:

::: correct

/*eslint max-statements: ["error", 10]*/
/*eslint-env es6*/

function foo() {
  var foo1 = 1;
  var foo2 = 2;
  var foo3 = 3;
  var foo4 = 4;
  var foo5 = 5;
  var foo6 = 6;
  var foo7 = 7;
  var foo8 = 8;
  var foo9 = 9;
  var foo10 = 10;
  return function () {

    // The number of statements in the inner function does not count toward the
    // statement maximum.

    return 42;
  };
}

let foo = () => {
  var foo1 = 1;
  var foo2 = 2;
  var foo3 = 3;
  var foo4 = 4;
  var foo5 = 5;
  var foo6 = 6;
  var foo7 = 7;
  var foo8 = 8;
  var foo9 = 9;
  var foo10 = 10;
  return function () {

    // The number of statements in the inner function does not count toward the
    // statement maximum.

    return 42;
  };
}

:::

Note that this rule does not apply to class static blocks, and that statements in class static blocks do not count as statements in the enclosing function.

Examples of correct code for this rule with { "max": 2 } option:

::: correct

/*eslint max-statements: ["error", 2]*/

function foo() {
    let one;
    let two = class {
        static {
            let three;
            let four;
            let five;
            if (six) {
                let seven;
                let eight;
                let nine;
            }
        }
    };
}

:::

ignoreTopLevelFunctions

Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

::: correct

/*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/

function foo() {
  var foo1 = 1;
  var foo2 = 2;
  var foo3 = 3;
  var foo4 = 4;
  var foo5 = 5;
  var foo6 = 6;
  var foo7 = 7;
  var foo8 = 8;
  var foo9 = 9;
  var foo10 = 10;
  var foo11 = 11;
}

::: Source: http://eslint.org/docs/rules/

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

        templates: Immutable([
          { _id: 't1', properties: [{ name: 'property0', filter: false, type: 'text' }] },
          {
            _id: 't2',
            properties: [{ name: 'property1', prioritySorting: true, filter: true, type: 'date' }],
Severity: Major
Found in app/react/utils/specs/prioritySortingCriteria.spec.js and 1 other location - About 4 hrs to fix
app/react/utils/specs/prioritySortingCriteria.spec.js on lines 105..120

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

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

        templates: Immutable([
          { _id: 't1', properties: [{ name: 'property0', filter: false, type: 'text' }] },
          {
            _id: 't2',
            properties: [{ name: 'property1', prioritySorting: true, filter: true, type: 'date' }],
Severity: Major
Found in app/react/utils/specs/prioritySortingCriteria.spec.js and 1 other location - About 4 hrs to fix
app/react/utils/specs/prioritySortingCriteria.spec.js on lines 134..149

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

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 options = {
        currentCriteria: { sort: 'metadata.property1', order: 'asc', treatAs: 'string' },
        filteredTemplates: [],
        templates: Immutable([
          { properties: [{ name: 'property0', filter: true, type: 'text' }] },
Severity: Major
Found in app/react/utils/specs/prioritySortingCriteria.spec.js and 1 other location - About 2 hrs to fix
app/react/utils/specs/prioritySortingCriteria.spec.js on lines 250..264

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

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 options = {
        currentCriteria: { sort: 'metadata.nonExistentProperty', order: 'asc', treatAs: 'string' },
        filteredTemplates: [],
        templates: Immutable([
          { properties: [{ name: 'property0', filter: false, type: 'text' }] },
Severity: Major
Found in app/react/utils/specs/prioritySortingCriteria.spec.js and 1 other location - About 2 hrs to fix
app/react/utils/specs/prioritySortingCriteria.spec.js on lines 230..244

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

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 options = {
        currentCriteria: { sort: 'metadata.property1', order: 'asc', treatAs: 'string' },
        filteredTemplates: ['t1'],
        templates: Immutable([
          { _id: 't1', properties: [{ name: 'property0', filter: false, type: 'text' }] },
Severity: Major
Found in app/react/utils/specs/prioritySortingCriteria.spec.js and 1 other location - About 1 hr to fix
app/react/utils/specs/prioritySortingCriteria.spec.js on lines 72..79

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

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 options = {
        currentCriteria: { sort: 'metadata.property1', order: 'asc', treatAs: 'string' },
        filteredTemplates: ['t2'],
        templates: Immutable([
          { _id: 't1', properties: [{ name: 'property0', filter: false, type: 'text' }] },
Severity: Major
Found in app/react/utils/specs/prioritySortingCriteria.spec.js and 1 other location - About 1 hr to fix
app/react/utils/specs/prioritySortingCriteria.spec.js on lines 85..92

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

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 options = {
        currentCriteria: { sort: 'metadata.property2', order: 'asc', treatAs: 'string' },
        filteredTemplates: [],
        templates: Immutable([
          { properties: [{ name: 'property0', filter: false, type: 'text' }] },
Severity: Minor
Found in app/react/utils/specs/prioritySortingCriteria.spec.js and 1 other location - About 45 mins to fix
app/react/utils/specs/prioritySortingCriteria.spec.js on lines 42..49

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

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 options = {
        currentCriteria: { sort: 'metadata.property1', order: 'asc', treatAs: 'string' },
        filteredTemplates: [],
        templates: Immutable([
          { properties: [{ name: 'property0', filter: false, type: 'text' }] },
Severity: Minor
Found in app/react/utils/specs/prioritySortingCriteria.spec.js and 1 other location - About 45 mins to fix
app/react/utils/specs/prioritySortingCriteria.spec.js on lines 55..62

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

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

Definition for rule 'node/no-restricted-import' was not found.
Open

import { fromJS as Immutable } from 'immutable';

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

There are no issues that match your filters.

Category
Status