CORE-POS/IS4C

View on GitHub
fannie/classlib2.0/lib/FormLib.php

Summary

Maintainability
F
1 wk
Test Coverage
F
53%

File FormLib.php has 890 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Copyright 2012 Whole Foods Co-op

Severity: Major
Found in fannie/classlib2.0/lib/FormLib.php - About 2 days to fix

    Function queueableItemFromWhere has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
    Open

        static public function queueableItemFromWhere($form)
        {
            $op_db = FannieConfig::config('OP_DB');
            $dbc = FannieDB::getReadOnly($op_db);
            try {
    Severity: Minor
    Found in fannie/classlib2.0/lib/FormLib.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

    Function standardItemFromWhere has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

        static public function standardItemFromWhere()
        {
            $op_db = FannieConfig::config('OP_DB');
            $dbc = FannieDB::getReadOnly($op_db);
            $start_date = self::getDate('date1', date('Y-m-d'));
    Severity: Minor
    Found in fannie/classlib2.0/lib/FormLib.php - About 7 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 queueableItemFromWhere has 183 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        static public function queueableItemFromWhere($form)
        {
            $op_db = FannieConfig::config('OP_DB');
            $dbc = FannieDB::getReadOnly($op_db);
            try {
    Severity: Major
    Found in fannie/classlib2.0/lib/FormLib.php - About 7 hrs to fix

      Method standardItemFromWhere has 178 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static public function standardItemFromWhere()
          {
              $op_db = FannieConfig::config('OP_DB');
              $dbc = FannieDB::getReadOnly($op_db);
              $start_date = self::getDate('date1', date('Y-m-d'));
      Severity: Major
      Found in fannie/classlib2.0/lib/FormLib.php - About 7 hrs to fix

        Method dateRangePicker has 141 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function dateRangePicker($one='date1',$two='date2',$week_start=1)
            {
                /**
                  calculate all the applicable dates in PHP
                */
        Severity: Major
        Found in fannie/classlib2.0/lib/FormLib.php - About 5 hrs to fix

          Method standardDepartmentFields has 124 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function standardDepartmentFields($super='super',$multi='departments',$start='deptStart',$end='deptEnd', $subs='subdepts')
              {
                  /**
                    Precalculate options for superdept and dept selects
                  */
          Severity: Major
          Found in fannie/classlib2.0/lib/FormLib.php - About 4 hrs to fix

            Method standardItemFields has 98 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function standardItemFields()
                {
                    $dbc = FannieDB::getReadOnly(FannieConfig::config('OP_DB'));
                    ob_start();
                    ?>
            Severity: Major
            Found in fannie/classlib2.0/lib/FormLib.php - About 3 hrs to fix

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

                  public static function storePicker($field_name='store', $all=true, $onchange='')
                  {
                      $op_db = FannieConfig::config('OP_DB');
                      $dbc = FannieDB::getReadOnly($op_db);
              
              
              Severity: Minor
              Found in fannie/classlib2.0/lib/FormLib.php - About 1 hr to fix

                Method dateAndDepartmentForm has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function dateAndDepartmentForm($standardFieldNames=false)
                    {
                        ob_start();
                        ?>
                <form method="get" class="form-horizontal">
                Severity: Minor
                Found in fannie/classlib2.0/lib/FormLib.php - About 1 hr to fix

                  Function storePicker has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function storePicker($field_name='store', $all=true, $onchange='')
                      {
                          $op_db = FannieConfig::config('OP_DB');
                          $dbc = FannieDB::getReadOnly($op_db);
                  
                  
                  Severity: Minor
                  Found in fannie/classlib2.0/lib/FormLib.php - About 45 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

                  Method standardDepartmentFields has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public static function standardDepartmentFields($super='super',$multi='departments',$start='deptStart',$end='deptEnd', $subs='subdepts')
                  Severity: Minor
                  Found in fannie/classlib2.0/lib/FormLib.php - About 35 mins to fix

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

                                        if (is_array(FormLib::get('departments')) && count(FormLib::get('departments')) > 0) {
                                            $query .= ' AND t.department IN (';
                                            foreach (FormLib::get('departments') as $d) {
                                                $query .= '?,';
                                                $args[] = $d;
                    Severity: Major
                    Found in fannie/classlib2.0/lib/FormLib.php and 1 other location - About 4 hrs to fix
                    fannie/classlib2.0/lib/FormLib.php on lines 691..702

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

                    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

                                        if (is_array(FormLib::get('departments')) && count(FormLib::get('departments')) > 0) {
                                            $query .= ' AND t.department IN (';
                                            foreach (FormLib::get('departments') as $d) {
                                                $query .= '?,';
                                                $args[] = $d;
                    Severity: Major
                    Found in fannie/classlib2.0/lib/FormLib.php and 1 other location - About 4 hrs to fix
                    fannie/classlib2.0/lib/FormLib.php on lines 677..688

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

                    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

                                        if (is_array($form->tryGet('departments')) && count($form->tryGet('departments')) > 0) {
                                            $query .= ' AND t.department IN (';
                                            foreach ($form->tryGet('departments') as $d) {
                                                $query .= '?,';
                                                $args[] = $d;
                    Severity: Major
                    Found in fannie/classlib2.0/lib/FormLib.php and 1 other location - About 4 hrs to fix
                    fannie/classlib2.0/lib/FormLib.php on lines 890..901

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

                    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

                                        if (is_array($form->tryGet('departments')) && count($form->tryGet('departments')) > 0) {
                                            $query .= ' AND t.department IN (';
                                            foreach ($form->tryGet('departments') as $d) {
                                                $query .= '?,';
                                                $args[] = $d;
                    Severity: Major
                    Found in fannie/classlib2.0/lib/FormLib.php and 1 other location - About 4 hrs to fix
                    fannie/classlib2.0/lib/FormLib.php on lines 876..887

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

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

                            $thisWeekLY = array(date('Y-m-d', $mondayLY), date('Y-m-d', mktime(0,0,0,date('n',$mondayLY),date('j',$mondayLY)+6,date('Y',$mondayLY))));
                    Severity: Major
                    Found in fannie/classlib2.0/lib/FormLib.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/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php on lines 298..301
                    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

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

                            $this_week = array(date('Y-m-d',$monday),
                                date('Y-m-d',mktime(0,0,0,date('n',$monday),date('j',$monday)+6,date('Y',$monday)))
                            );
                    Severity: Major
                    Found in fannie/classlib2.0/lib/FormLib.php and 4 other locations - About 30 mins to fix
                    fannie/classlib2.0/lib/FormLib.php on lines 88..90
                    fannie/classlib2.0/lib/FormLib.php on lines 102..102
                    fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php on lines 298..301
                    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

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

                            $last_week = array(date('Y-m-d',$monday),
                                date('Y-m-d',mktime(0,0,0,date('n',$monday),date('j',$monday)+6,date('Y',$monday)))
                            );
                    Severity: Major
                    Found in fannie/classlib2.0/lib/FormLib.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 102..102
                    fannie/modules/plugins2.0/HouseCoupon/HouseCouponEditor.php on lines 298..301
                    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