CORE-POS/IS4C

View on GitHub
fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php

Summary

Maintainability
F
6 days
Test Coverage

File HouseCouponEditor.php has 721 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Copyright 2012 Whole Foods Co-op

Severity: Major
Found in fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php - About 1 day to fix

    Method editCoupon has 241 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function editCoupon()
        {
            $dbc = FannieDB::get($this->config->get('OP_DB'));
            
            $depts = array();
    Severity: Major
    Found in fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php - About 1 day to fix

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

          public function preprocess()
          {
              $this->display_function = 'listHouseCoupons';
      
              $msgs = array();
      Severity: Minor
      Found in fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.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 preprocess has 162 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function preprocess()
          {
              $this->display_function = 'listHouseCoupons';
      
              $msgs = array();
      Severity: Major
      Found in fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php - About 6 hrs to fix

        Method listHouseCoupons has 96 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function listHouseCoupons()
            {
                $FANNIE_URL = $this->config->get('URL');
        
                $this->addScript($FANNIE_URL . 'src/javascript/fancybox/jquery.fancybox-1.3.4.js?v=1');
        Severity: Major
        Found in fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php - About 3 hrs to fix

          Method javascriptContent has 92 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function javascriptContent()
              {
                  $dbc = FannieDB::get($this->config->get('OP_DB'));
                  $prep = $dbc->prepare("SELECT label FROM houseCoupons GROUP BY label");
                  $res = $dbc->execute($prep);
          Severity: Major
          Found in fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php - About 3 hrs to fix

            Function editCoupon has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

                private function editCoupon()
                {
                    $dbc = FannieDB::get($this->config->get('OP_DB'));
                    
                    $depts = array();
            Severity: Minor
            Found in fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php - About 2 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 couponItemTable has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function couponItemTable($id)
                {
                    $dbc = FannieDB::get($this->config->get('OP_DB'));
                    $hc = new HouseCouponsModel($dbc);
                    $hc->coupID($id);
            Severity: Minor
            Found in fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                      if ($mType == "D" || $mType == "D+" || $mType == 'C' || $mType == 'C+' || $dType == '%D' || $dType == 'S' || $mType == 'MX' || $mType == 'C!' || $mType == 'C^') {
                          $ret .= '
                              <label class="control-label">Add Dept</label>
                              <select class="form-control add-item-field" name=new_dept>
                              <option value="">Select...</option>';
              Severity: Critical
              Found in fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php - About 1 hr to fix

                Method addUPCs has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function addUPCs()
                    {
                        $ret = '<h3>Add Items to Coupon</h3>
                            <form method="post">
                            <div class="form-group">
                Severity: Minor
                Found in fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                          if ($hc->minType() == 'MX') {
                              $query = "
                                  SELECT h.upc,
                                      CASE WHEN h.type='QUALIFIER' THEN d.dept_name ELSE p.description END as description,
                                      h.type
                  Severity: Critical
                  Found in fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php - About 1 hr to fix

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

                        private function listHouseCoupons()
                        {
                            $FANNIE_URL = $this->config->get('URL');
                    
                            $this->addScript($FANNIE_URL . 'src/javascript/fancybox/jquery.fancybox-1.3.4.js?v=1');
                    Severity: Minor
                    Found in fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.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

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

                                    $report_dates = array(
                                        date('Y-m-d', $ts),
                                        date('Y-m-t', mktime(0, 0, 0, date('n',$ts), date('j',$ts)+90, date('Y',$ts))),
                                    );
                    Severity: Major
                    Found in fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php and 4 other locations - About 30 mins to fix
                    fannie/classlib2.0/lib/FormLib.php on lines 77..79
                    fannie/classlib2.0/lib/FormLib.php on lines 88..90
                    fannie/classlib2.0/lib/FormLib.php on lines 102..102
                    fannie/modules/plugins2.0/WfcVirtualCoupon/WfcUnfiTask.php on lines 31..34

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

                    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