my-grocery-price-book/www

View on GitHub

Showing 64 of 64 total issues

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

  it("sets back link", function () {
    const a = dom_node.find('a[href="/back"]');

    expect(a.text()).toEqual("Back");
  });
Severity: Major
Found in app/javascript/__test__/components/entries_form.spec.jsx and 8 other locations - About 45 mins to fix
app/javascript/__test__/components/entries_form.spec.jsx on lines 63..67
app/javascript/__test__/components/entries_form.spec.jsx on lines 75..79
app/javascript/__test__/components/page.spec.jsx on lines 15..18
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 25..29
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 31..35
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 37..41
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 43..47
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 49..53

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

  it("sets new store link", function () {
    const a = dom_node.find('a[href="/new_store"]');

    expect(a.text()).toEqual("New Store");
  });
Severity: Major
Found in app/javascript/__test__/components/entries_form.spec.jsx and 8 other locations - About 45 mins to fix
app/javascript/__test__/components/entries_form.spec.jsx on lines 63..67
app/javascript/__test__/components/entries_form.spec.jsx on lines 69..73
app/javascript/__test__/components/page.spec.jsx on lines 15..18
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 25..29
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 31..35
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 37..41
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 43..47
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 49..53

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

  it("shows item amount", function () {
    const div_item = react_dom.find('[data-amount]');

    expect(div_item.text()).toContain('2');
  });
Severity: Major
Found in app/javascript/__test__/components/shopping_list_item.spec.jsx and 8 other locations - About 45 mins to fix
app/javascript/__test__/components/entries_form.spec.jsx on lines 63..67
app/javascript/__test__/components/entries_form.spec.jsx on lines 69..73
app/javascript/__test__/components/entries_form.spec.jsx on lines 75..79
app/javascript/__test__/components/page.spec.jsx on lines 15..18
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 31..35
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 37..41
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 43..47
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 49..53

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

  it("enables input", function () {
    const input = react_dom.find('#shopping_list_item_name');

    expect(input.prop('disabled')).toBeFalsy();
  });
app/javascript/__test__/components/shopping_list_item_add_form.spec.jsx on lines 58..62
app/javascript/__test__/components/shopping_list_item_add_form.spec.jsx on lines 107..111
app/javascript/__test__/components/shopping_list_item_add_form.spec.jsx on lines 113..117

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

    it("works", function () {
      const info = react_dom.find('.page-info');
      expect(info.text()).toContain('Bakery,grams');
    });
Severity: Major
Found in app/javascript/__test__/components/page.spec.jsx and 8 other locations - About 45 mins to fix
app/javascript/__test__/components/entries_form.spec.jsx on lines 63..67
app/javascript/__test__/components/entries_form.spec.jsx on lines 69..73
app/javascript/__test__/components/entries_form.spec.jsx on lines 75..79
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 25..29
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 31..35
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 37..41
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 43..47
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 49..53

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

  it("shows page unit", function () {
    const div_item = react_dom.find('[data-comparing-unit]');

    expect(div_item.text()).toContain('grams');
  });
Severity: Major
Found in app/javascript/__test__/components/shopping_list_item.spec.jsx and 8 other locations - About 45 mins to fix
app/javascript/__test__/components/entries_form.spec.jsx on lines 63..67
app/javascript/__test__/components/entries_form.spec.jsx on lines 69..73
app/javascript/__test__/components/entries_form.spec.jsx on lines 75..79
app/javascript/__test__/components/page.spec.jsx on lines 15..18
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 25..29
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 31..35
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 37..41
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 49..53

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

  it("shows package_unit", function () {
    const span = dom_node.find('#package_unit');

    expect(span.text()).toEqual("KG");
  });
Severity: Major
Found in app/javascript/__test__/components/entries_form.spec.jsx and 8 other locations - About 45 mins to fix
app/javascript/__test__/components/entries_form.spec.jsx on lines 69..73
app/javascript/__test__/components/entries_form.spec.jsx on lines 75..79
app/javascript/__test__/components/page.spec.jsx on lines 15..18
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 25..29
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 31..35
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 37..41
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 43..47
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 49..53

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

  it("shows comparing store", function () {
    const div_item = react_dom.find('[data-comparing-store]');

    expect(div_item.text()).toContain('Mr Buy');
  });
Severity: Major
Found in app/javascript/__test__/components/shopping_list_item.spec.jsx and 8 other locations - About 45 mins to fix
app/javascript/__test__/components/entries_form.spec.jsx on lines 63..67
app/javascript/__test__/components/entries_form.spec.jsx on lines 69..73
app/javascript/__test__/components/entries_form.spec.jsx on lines 75..79
app/javascript/__test__/components/page.spec.jsx on lines 15..18
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 25..29
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 31..35
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 43..47
app/javascript/__test__/components/shopping_list_item.spec.jsx on lines 49..53

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

    it("disables input", function () {
      const input = react_dom.find('#shopping_list_item_name');

      expect(input.prop('disabled')).toBeTruthy();
    });
app/javascript/__test__/components/shopping_list_item_add_form.spec.jsx on lines 52..56
app/javascript/__test__/components/shopping_list_item_add_form.spec.jsx on lines 58..62
app/javascript/__test__/components/shopping_list_item_add_form.spec.jsx on lines 113..117

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

  it("enables button", function () {
    const button = react_dom.find('button');

    expect(button.prop('disabled')).toBeFalsy();
  });
app/javascript/__test__/components/shopping_list_item_add_form.spec.jsx on lines 52..56
app/javascript/__test__/components/shopping_list_item_add_form.spec.jsx on lines 107..111
app/javascript/__test__/components/shopping_list_item_add_form.spec.jsx on lines 113..117

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

    it("disables button", function () {
      const button = react_dom.find('button');

      expect(button.prop('disabled')).toBeTruthy();
    });
app/javascript/__test__/components/shopping_list_item_add_form.spec.jsx on lines 52..56
app/javascript/__test__/components/shopping_list_item_add_form.spec.jsx on lines 58..62
app/javascript/__test__/components/shopping_list_item_add_form.spec.jsx on lines 107..111

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

    axios.delete(this.props.item.delete_url, {
      data: { authenticity_token: this.props.authenticity_token }
    }).then(function (response) {
      self.setState({is_deleted: true, is_busy: false});
    }).catch(function (error) {
app/javascript/src/ShoppingList/components/shopping_list_item.jsx on lines 67..71

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

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

  dasherize: function (str) {
    return this.trim(str).replace(/([A-Z])/g, '-$1').replace(/[-_\s]+/g, '-').toLowerCase();
  },
app/javascript/src/PriceBook/components/page.jsx on lines 12..14

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

    axios.delete(this.props.item.unpurchase_url, {
      data: { authenticity_token: this.props.authenticity_token }
    }).then(function (response) {
      self.setState({purchased_at: response.data.data.purchased_at, is_busy: false});
    }).catch(function (error) {
app/javascript/src/ShoppingList/components/shopping_list_item.jsx on lines 87..91

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

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

  dasherize: function (str) {
    return this.trim(str).replace(/([A-Z])/g, '-$1').replace(/[-_\s]+/g, '-').toLowerCase();
  },
Severity: Minor
Found in app/javascript/src/PriceBook/components/page.jsx and 1 other location - About 35 mins to fix
app/javascript/src/ShoppingList/components/shopping_list_item.jsx on lines 23..25

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

    it("hides title", function () {
      const shopping_list_title_span = shopping_list_title.find('#shopping_list_title_span');

      expect(shopping_list_title_span.length).toEqual(0);
    });
Severity: Minor
Found in app/javascript/__test__/components/shopping_list_title.spec.jsx and 1 other location - About 35 mins to fix
app/javascript/__test__/components/shopping_list_title.spec.jsx on lines 23..27

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

    it("hides title input", function () {
      const shopping_list_title_input = shopping_list_title.find('#shopping_list_title');

      expect(shopping_list_title_input.length).toEqual(0);
    });
Severity: Minor
Found in app/javascript/__test__/components/shopping_list_title.spec.jsx and 1 other location - About 35 mins to fix
app/javascript/__test__/components/shopping_list_title.spec.jsx on lines 46..50

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

  displayPriceRatio: function (p, unit) {
    if (unit == 'grams' && p >= 1000) {
      return (this.displayPrice(p / 1000) + ' / kilograms');
    } else if (unit == 'kilograms' && p <= 0.01) {
      return (this.displayPrice(p * 1000) + ' / grams');
Severity: Minor
Found in app/javascript/src/PriceBook/components/page.jsx - 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

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

                <span data-comparing-size style={show_comparing_price ? null : {display: 'none'} }
                      className="item-field item-size">{best_entry.package_size}</span>
app/javascript/src/ShoppingList/components/shopping_list_item.jsx on lines 120..121

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 (this.displayPrice(p) + ' / ' + unit);
Severity: Major
Found in app/javascript/src/PriceBook/components/page.jsx - About 30 mins to fix
    Severity
    Category
    Status
    Source
    Language