CORE-POS/IS4C

View on GitHub
fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php

Summary

Maintainability
F
2 wks
Test Coverage

File CoopCredProgramEditor.php has 1033 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*******************************************************************************

    Copyright 2009,2013 Whole Foods Co-op
    Copyright 2014 West End Food Co-op, Toronto
Severity: Major
Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 2 days to fix

    Method ajax_display_program has 481 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function ajax_display_program($id){
            global $FANNIE_PLUGIN_SETTINGS, $FANNIE_URL, $FANNIE_OP_DB;
    
            $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['CoopCredDatabase']);
    
    
    Severity: Major
    Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 2 days to fix

      Function ajax_save_program has a Cognitive Complexity of 90 (exceeds 5 allowed). Consider refactoring.
      Open

          private function ajax_save_program(){
      
              global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB;
      
              $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['CoopCredDatabase']);
      Severity: Minor
      Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 1 day 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 ajax_save_program has 359 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function ajax_save_program(){
      
              global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB;
      
              $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['CoopCredDatabase']);
      Severity: Major
      Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 1 day to fix

        Function ajax_display_program has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

            private function ajax_display_program($id){
                global $FANNIE_PLUGIN_SETTINGS, $FANNIE_URL, $FANNIE_OP_DB;
        
                $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['CoopCredDatabase']);
        
        
        Severity: Minor
        Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 4 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

        Function updateViews has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

            function updateViews ($dbc) {
                global $FANNIE_PLUGIN_SETTINGS;
        
                $models = array(
                    array('name' => 'CCredHistoryTodayModel', 'drop' => True)
        Severity: Minor
        Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.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 updateViews has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function updateViews ($dbc) {
                global $FANNIE_PLUGIN_SETTINGS;
        
                $models = array(
                    array('name' => 'CCredHistoryTodayModel', 'drop' => True)
        Severity: Major
        Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 2 hrs to fix

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

              function body_content(){
          
                  global $FANNIE_PLUGIN_SETTINGS;
                  global $FANNIE_URL;
          
          
          Severity: Major
          Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 2 hrs to fix

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

                function preprocess(){
                    global $FANNIE_PLUGIN_LIST, $FANNIE_PLUGIN_SETTINGS;
            
                    if (!isset($FANNIE_PLUGIN_LIST) || !in_array('CoopCred', $FANNIE_PLUGIN_LIST)) {
                        $this->errors .= _("Error: The Coop Cred Plugin is not enabled.");

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

                  function body_content(){
              
                      global $FANNIE_PLUGIN_SETTINGS;
                      global $FANNIE_URL;
              
              
              Severity: Minor
              Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 55 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

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

                  function preprocess(){
                      global $FANNIE_PLUGIN_LIST, $FANNIE_PLUGIN_SETTINGS;
              
                      if (!isset($FANNIE_PLUGIN_LIST) || !in_array('CoopCred', $FANNIE_PLUGIN_LIST)) {
                          $this->errors .= _("Error: The Coop Cred Plugin is not enabled.");
              Severity: Minor
              Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - 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

              Avoid too many return statements within this method.
              Open

                                      return;
              Severity: Major
              Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return;
                Severity: Major
                Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return;
                  Severity: Major
                  Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return True;
                    Severity: Major
                    Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return;
                      Severity: Major
                      Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return;
                        Severity: Major
                        Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                                  return;
                          Severity: Major
                          Found in fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php - About 30 mins to fix

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

                                    foreach($models as $model){
                                        $model_class = $model['name'];
                                        $filename = dirname(__FILE__).'../models/vmodels/'.$model_class.'.php';
                                        if (!class_exists($model_class)) {
                                            include_once($filename);
                            fannie/modules/plugins2.0/CoopCred/CoopCred.php on lines 198..252

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

                            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

                                    foreach($hbKeys as $hbKey) {
                                        $hbTarget = "$hbPrefix" . ++$hbNumber;
                                        if (isset($hbLongMessage["$hbKey"]) && $hbLongMessage["$hbKey"] != "") {
                                            $anyMore = $hbMore;
                                            $onClick = " onclick=\"$('#{$hbTarget}').toggle();return false;\" ";
                            fannie/modules/plugins2.0/CoopCred/programs/CoopCredConfigEditor.php on lines 319..341

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

                            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

                                    if ($tendertype == $this->dummyTenderCode) {
                                        $returnMessage .= "\nThe Program may not be actually used until " .
                                            "a real Tender is assigned.";
                                    } else {
                                        if ($tendername != "") {
                            fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php on lines 1262..1280

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

                            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

                                    if ($paymentid == $this->dummyDepartment) {
                                        $returnMessage .= "\nThe Program may not be actually used until " .
                                            "a real Input/Payment is assigned.";
                                    } else {
                                        if ($paymentname != "") {
                            fannie/modules/plugins2.0/CoopCred/programs/CoopCredProgramEditor.php on lines 1242..1260

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

                            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

                                    while($row = $dbc->fetch_row($resp)){
                                        if ($listSize < 4) {
                                            $listSize++;
                                        }
                                        if ($selectedPID !== '' && $selectedPID == $row['programID']) {
                            fannie/modules/plugins2.0/CoopCred/programs/CoopCredConfigEditor.php on lines 616..627

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

                            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