CORE-POS/IS4C

View on GitHub
fannie/modules/plugins2.0/TimesheetPlugin/admin/TsAdminView.php

Summary

Maintainability
F
4 days
Test Coverage

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

    function body_content(){
        global $FANNIE_OP_DB,$FANNIE_PLUGIN_SETTINGS;
        $ts_db = FannieDB::get($FANNIE_PLUGIN_SETTINGS['TimesheetDatabase']);

        $emp_no = (int) $this->emp_no;
Severity: Minor
Found in fannie/modules/plugins2.0/TimesheetPlugin/admin/TsAdminView.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 body_content has 204 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function body_content(){
        global $FANNIE_OP_DB,$FANNIE_PLUGIN_SETTINGS;
        $ts_db = FannieDB::get($FANNIE_PLUGIN_SETTINGS['TimesheetDatabase']);

        $emp_no = (int) $this->emp_no;
Severity: Major
Found in fannie/modules/plugins2.0/TimesheetPlugin/admin/TsAdminView.php - About 1 day to fix

    File TsAdminView.php has 340 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    include(dirname(__FILE__).'/../../../../config.php');
    if (!class_exists('FannieAPI')) {
        include_once(__DIR__ . '/../../../../classlib2.0/FannieAPI.php');
    }
    Severity: Minor
    Found in fannie/modules/plugins2.0/TimesheetPlugin/admin/TsAdminView.php - About 4 hrs to fix

      Method javascript_content has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function javascript_content(){
              ob_start();
              ?>
          function toggleTable(id, obj) {
              if (id == 'all') {
      Severity: Minor
      Found in fannie/modules/plugins2.0/TimesheetPlugin/admin/TsAdminView.php - About 1 hr to fix

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

            function preprocess(){
                global $FANNIE_OP_DB,$FANNIE_PLUGIN_SETTINGS;
                $ts_db = FannieDB::get($FANNIE_PLUGIN_SETTINGS['TimesheetDatabase']);
        
                $this->emp_no = FormLib::get_form_value('emp_no',0);
        Severity: Minor
        Found in fannie/modules/plugins2.0/TimesheetPlugin/admin/TsAdminView.php - About 1 hr to fix

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

              function preprocess(){
                  global $FANNIE_OP_DB,$FANNIE_PLUGIN_SETTINGS;
                  $ts_db = FannieDB::get($FANNIE_PLUGIN_SETTINGS['TimesheetDatabase']);
          
                  $this->emp_no = FormLib::get_form_value('emp_no',0);
          Severity: Minor
          Found in fannie/modules/plugins2.0/TimesheetPlugin/admin/TsAdminView.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

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

              private function parseTime($time, $mer) {
                  $hour = array();
                  if (strlen($time) == 2 && is_numeric($time)) {
                      $time = $time . ':00';
                  } elseif (strlen($time) == 4 && is_numeric($time)) {
          Severity: Minor
          Found in fannie/modules/plugins2.0/TimesheetPlugin/admin/TsAdminView.php - About 25 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 roundTime has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              private function roundTime($number) {
                  // This function takes a two digit precision number and rounds it to the nearest quarter.
                  
                  $roundhour = explode('.', number_format($number, 2));
                                
          Severity: Minor
          Found in fannie/modules/plugins2.0/TimesheetPlugin/admin/TsAdminView.php - About 25 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

                  if ($roundhour[1] < 13) {$roundhour[1] = 00;}
                  elseif ($roundhour[1] >= 13 && $roundhour[1] < 37) {$roundhour[1] = 25;}
                  elseif ($roundhour[1] >= 37 && $roundhour[1] < 63) {$roundhour[1] = 50;}
                  elseif ($roundhour[1] >= 63 && $roundhour[1] < 87) {$roundhour[1] = 75;}
                  elseif ($roundhour[1] >= 87) {$roundhour[1] = 00; $roundhour[0]++;}
          fannie/modules/plugins2.0/TimesheetPlugin/PayrollDetail.php on lines 100..104
          fannie/modules/plugins2.0/TimesheetPlugin/PayrollSummaryPage.php on lines 211..215
          fannie/modules/plugins2.0/TimesheetPlugin/ViewsheetPage.php on lines 50..54
          fannie/modules/plugins2.0/TimesheetPlugin/ViewsheetPage.php on lines 226..230

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

          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