CORE-POS/IS4C

View on GitHub
fannie/batches/BatchTypeEditor.php

Summary

Maintainability
D
2 days
Test Coverage
F
51%

Function preprocess has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    function preprocess()
    {
        global $FANNIE_OP_DB;
        $dbc = FannieDB::get($FANNIE_OP_DB);

Severity: Minor
Found in fannie/batches/BatchTypeEditor.php - About 3 hrs 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

Method body_content has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function body_content()
    {
        $this->addScript('type-editor.js');
        global $FANNIE_OP_DB;
        $dbc = FannieDB::get($FANNIE_OP_DB);
Severity: Major
Found in fannie/batches/BatchTypeEditor.php - About 3 hrs to fix

    Method preprocess has 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function preprocess()
        {
            global $FANNIE_OP_DB;
            $dbc = FannieDB::get($FANNIE_OP_DB);
    
    
    Severity: Major
    Found in fannie/batches/BatchTypeEditor.php - About 3 hrs to fix

      Method helpContent has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function helpContent()
          {
              return '<p>Batch types control what kind of change a batch makes and
                  may also be used for organization. Discount type controls the
                  batch type\'s behavior. You may have multiple batch types with
      Severity: Major
      Found in fannie/batches/BatchTypeEditor.php - About 2 hrs to fix

        File BatchTypeEditor.php has 252 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /*******************************************************************************
        
            Copyright 2011,2013 Whole Foods Co-op
        
        
        Severity: Minor
        Found in fannie/batches/BatchTypeEditor.php - About 2 hrs to fix

          Function body_content has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              function body_content()
              {
                  $this->addScript('type-editor.js');
                  global $FANNIE_OP_DB;
                  $dbc = FannieDB::get($FANNIE_OP_DB);
          Severity: Minor
          Found in fannie/batches/BatchTypeEditor.php - 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

          Avoid too many return statements within this method.
          Open

                      return false; // ajax call
          Severity: Major
          Found in fannie/batches/BatchTypeEditor.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return false; // ajax call
            Severity: Major
            Found in fannie/batches/BatchTypeEditor.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return true;
              Severity: Major
              Found in fannie/batches/BatchTypeEditor.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return false; // ajax call
                Severity: Major
                Found in fannie/batches/BatchTypeEditor.php - About 30 mins to fix

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

                          if (FormLib::get('saveUI') !== '') {
                              $model->batchTypeID(FormLib::get('bid'));
                              $model->editorUI(FormLib::get('saveUI'));
                              if ($model->save() === false) {
                                  $json['error'] = 'Error saving UI setting';
                  Severity: Major
                  Found in fannie/batches/BatchTypeEditor.php and 6 other locations - About 30 mins to fix
                  fannie/batches/BatchTypeEditor.php on lines 62..71
                  fannie/batches/BatchTypeEditor.php on lines 72..81
                  fannie/batches/BatchTypeEditor.php on lines 82..91
                  fannie/batches/BatchTypeEditor.php on lines 92..101
                  fannie/batches/BatchTypeEditor.php on lines 102..111
                  fannie/batches/BatchTypeEditor.php on lines 112..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 91.

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

                          if (FormLib::get('saveSO') !== '') {
                              $model->batchTypeID(FormLib::get('bid'));
                              $model->specialOrderEligible(FormLib::get('saveSO'));
                              if ($model->save() === false) {
                                  $json['error'] = 'Error saving SO eligibility';
                  Severity: Major
                  Found in fannie/batches/BatchTypeEditor.php and 6 other locations - About 30 mins to fix
                  fannie/batches/BatchTypeEditor.php on lines 62..71
                  fannie/batches/BatchTypeEditor.php on lines 72..81
                  fannie/batches/BatchTypeEditor.php on lines 82..91
                  fannie/batches/BatchTypeEditor.php on lines 102..111
                  fannie/batches/BatchTypeEditor.php on lines 112..121
                  fannie/batches/BatchTypeEditor.php on lines 122..131

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

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

                          if (FormLib::get('savePartial') !== '') {
                              $model->batchTypeID(FormLib::get('bid'));
                              $model->allowSingleStore(FormLib::get('savePartial'));
                              if ($model->save() === false) {
                                  $json['error'] = 'Error saving single store option';
                  Severity: Major
                  Found in fannie/batches/BatchTypeEditor.php and 6 other locations - About 30 mins to fix
                  fannie/batches/BatchTypeEditor.php on lines 62..71
                  fannie/batches/BatchTypeEditor.php on lines 72..81
                  fannie/batches/BatchTypeEditor.php on lines 82..91
                  fannie/batches/BatchTypeEditor.php on lines 92..101
                  fannie/batches/BatchTypeEditor.php on lines 112..121
                  fannie/batches/BatchTypeEditor.php on lines 122..131

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

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

                          if (FormLib::get('saveDesc') !== '') {
                              $model->batchTypeID(FormLib::get('bid'));
                              $model->typeDesc(FormLib::get('saveDesc'));
                              if ($model->save() === false) {
                                  $json['error'] = 'Error saving description';
                  Severity: Major
                  Found in fannie/batches/BatchTypeEditor.php and 6 other locations - About 30 mins to fix
                  fannie/batches/BatchTypeEditor.php on lines 72..81
                  fannie/batches/BatchTypeEditor.php on lines 82..91
                  fannie/batches/BatchTypeEditor.php on lines 92..101
                  fannie/batches/BatchTypeEditor.php on lines 102..111
                  fannie/batches/BatchTypeEditor.php on lines 112..121
                  fannie/batches/BatchTypeEditor.php on lines 122..131

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

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

                          if (FormLib::get('saveDated') !== '') {
                              $model->batchTypeID(FormLib::get('bid'));
                              $model->datedSigns(FormLib::get('saveDated'));
                              if ($model->save() === false) {
                                  $json['error'] = 'Error saving date setting';
                  Severity: Major
                  Found in fannie/batches/BatchTypeEditor.php and 6 other locations - About 30 mins to fix
                  fannie/batches/BatchTypeEditor.php on lines 62..71
                  fannie/batches/BatchTypeEditor.php on lines 72..81
                  fannie/batches/BatchTypeEditor.php on lines 92..101
                  fannie/batches/BatchTypeEditor.php on lines 102..111
                  fannie/batches/BatchTypeEditor.php on lines 112..121
                  fannie/batches/BatchTypeEditor.php on lines 122..131

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

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

                          if (FormLib::get('saveType') !== '') {
                              $model->batchTypeID(FormLib::get('bid'));
                              $model->discType(FormLib::get('saveType'));
                              if ($model->save() === false) {
                                  $json['error'] = 'Error saving sale type';
                  Severity: Major
                  Found in fannie/batches/BatchTypeEditor.php and 6 other locations - About 30 mins to fix
                  fannie/batches/BatchTypeEditor.php on lines 62..71
                  fannie/batches/BatchTypeEditor.php on lines 82..91
                  fannie/batches/BatchTypeEditor.php on lines 92..101
                  fannie/batches/BatchTypeEditor.php on lines 102..111
                  fannie/batches/BatchTypeEditor.php on lines 112..121
                  fannie/batches/BatchTypeEditor.php on lines 122..131

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

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

                          if (FormLib::get('saveExitInv') !== '') {
                              $model->batchTypeID(FormLib::get('bid'));
                              $model->exitInventory(FormLib::get('saveExitInv'));
                              if ($model->save() === false) {
                                  $json['error'] = 'Error saving exit inventory';
                  Severity: Major
                  Found in fannie/batches/BatchTypeEditor.php and 6 other locations - About 30 mins to fix
                  fannie/batches/BatchTypeEditor.php on lines 62..71
                  fannie/batches/BatchTypeEditor.php on lines 72..81
                  fannie/batches/BatchTypeEditor.php on lines 82..91
                  fannie/batches/BatchTypeEditor.php on lines 92..101
                  fannie/batches/BatchTypeEditor.php on lines 102..111
                  fannie/batches/BatchTypeEditor.php on lines 122..131

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

                  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