partkeepr/PartKeepr

View on GitHub
src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js

Summary

Maintainability
F
1 wk
Test Coverage

Function applyData has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

    applyData: function ()
    {
        var spec, i, unit, value, siPrefix, distributor, j, partDistributor, currency, k, found;

        if (this.waitMessage instanceof Ext.window.MessageBox)

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

    checkRequirements: function ()
    {
        var i, unit, file, image, distributor;

        var manufacturer = PartKeepr.getApplication().getManufacturerStore().findRecord("name",

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

File DataApplicator.js has 437 lines of code (exceeds 250 allowed). Consider refactoring.
Open

Ext.define("PartKeepr.Components.OctoPart.DataApplicator", {
    extend: "Ext.Base",
    mixins: ['Ext.mixin.Observable'],

    import: {},

    Function checkRequirements has 151 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        checkRequirements: function ()
        {
            var i, unit, file, image, distributor;
    
            var manufacturer = PartKeepr.getApplication().getManufacturerStore().findRecord("name",

      Function applyData has 136 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          applyData: function ()
          {
              var spec, i, unit, value, siPrefix, distributor, j, partDistributor, currency, k, found;
      
              if (this.waitMessage instanceof Ext.window.MessageBox)

        Function SIUnitPrefix has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            SIUnitPrefix: function( q_value, q_unit )
            {
                // the new Octopart API returns quantities as display strings: e.g. "12 mm"
                // try to recognize SI-unit and SI-prefix
                

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

            SIUnitPrefix: function( q_value, q_unit )
            {
                // the new Octopart API returns quantities as display strings: e.g. "12 mm"
                // try to recognize SI-unit and SI-prefix
                

          Avoid deeply nested control flow statements.
          Open

                                  for (k = 0; k < this.part.distributors().count(); k++)
                                  {
                                      if (partDistributor.isPartiallyEqualTo(
                                              this.part.distributors().getAt(k),
                                              ["sku", "packagingUnit", "currency", "distributor.name"]

            Avoid deeply nested control flow statements.
            Open

                                    if (found !== null)
                                    {
                                        found.set("price", this.data.sellers[i].offers[o].prices[p].price);
                                    } else
                                    {

              Avoid too many return statements within this function.
              Open

                              return false;

                Avoid too many return statements within this function.
                Open

                                return false;

                  Avoid too many return statements within this function.
                  Open

                                  return false;

                    Avoid too many return statements within this function.
                    Open

                            return true;

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

                          parseQuantity: function( quantity )
                          {
                              try {
                                  quantity = quantity.trim();
                                  const regex = /[^\d+-.]/g;

                      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

                              if (this.import.bestDatasheet)
                              {
                                  if (this.data['best_datasheet'])
                                  {
                                      file = this.data.best_datasheet;
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 159..176
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 197..216

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

                      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

                              if (this.import.cadModels)
                              {
                                  if (this.data['cad'])
                                  {
                                      file = this.data.cad;
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 138..157
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 197..216

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

                      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

                              if (this.import.images)
                              {
                                  if (this.data['best_image'])
                                  {
                                      image = this.data.best_image;
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 138..157
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 159..176

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

                      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

                                              unit.save({
                                                  success: function ()
                                                  {
                                                      PartKeepr.getApplication().getUnitStore().load({
                                                          callback: this.applyData,
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 60..70
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 122..132

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

                      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

                                  manufacturer.save({
                                      success: function ()
                                      {
                                          PartKeepr.getApplication().getManufacturerStore().load({
                                              callback: this.applyData,
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 92..102
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 122..132

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

                      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

                                          distributor.save({
                                              success: function ()
                                              {
                                                  PartKeepr.getApplication().getDistributorStore().load({
                                                      callback: this.applyData,
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 60..70
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 92..102

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

                      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

                                      distributor = PartKeepr.getApplication().getDistributorStore().findRecord("name",
                                          this.data.sellers[i].company.name, 0, false, true, true);
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 314..315

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

                      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

                                      distributor = PartKeepr.getApplication().getDistributorStore().findRecord("name",
                                          this.data.sellers[i].company.name, 0, false, true, true);
                      src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js on lines 113..114

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

                      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