CORE-POS/IS4C

View on GitHub
fannie/classlib2.0/data/models/trans/DTransactionsModel.php

Summary

Maintainability
F
4 days
Test Coverage
C
72%

File DTransactionsModel.php has 460 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Copyright 2013 Whole Foods Co-op

Severity: Minor
Found in fannie/classlib2.0/data/models/trans/DTransactionsModel.php - About 7 hrs to fix

    Function normalize has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        public function normalize($db_name, $mode=BasicModel::NORMALIZE_MODE_CHECK, $doCreate=false)
        {
            $config = FannieConfig::factory();
            $FANNIE_TRANS_DB = $config->get('TRANS_DB');
            $FANNIE_ARCHIVE_DB = $config->get('ARCHIVE_DB');
    Severity: Minor
    Found in fannie/classlib2.0/data/models/trans/DTransactionsModel.php - About 5 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 doc has 144 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function doc()
        {
            return '
    Use:
    This is IT CORE\'s transaction log. A rather important table.
    Severity: Major
    Found in fannie/classlib2.0/data/models/trans/DTransactionsModel.php - About 5 hrs to fix

      Method normalize has 127 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function normalize($db_name, $mode=BasicModel::NORMALIZE_MODE_CHECK, $doCreate=false)
          {
              $config = FannieConfig::factory();
              $FANNIE_TRANS_DB = $config->get('TRANS_DB');
              $FANNIE_ARCHIVE_DB = $config->get('ARCHIVE_DB');
      Severity: Major
      Found in fannie/classlib2.0/data/models/trans/DTransactionsModel.php - About 5 hrs to fix

        Function normalizeLog has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public function normalizeLog($view_name, $table_name, $mode=BasicModel::NORMALIZE_MODE_CHECK)
            {
                printf("%s view: %s",
                    ($mode==BasicModel::NORMALIZE_MODE_CHECK)?"Would recreate":"Recreating", 
                    "$view_name (of table $table_name)\n"
        Severity: Minor
        Found in fannie/classlib2.0/data/models/trans/DTransactionsModel.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 normalizeLog has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function normalizeLog($view_name, $table_name, $mode=BasicModel::NORMALIZE_MODE_CHECK)
            {
                printf("%s view: %s",
                    ($mode==BasicModel::NORMALIZE_MODE_CHECK)?"Would recreate":"Recreating", 
                    "$view_name (of table $table_name)\n"
        Severity: Major
        Found in fannie/classlib2.0/data/models/trans/DTransactionsModel.php - About 2 hrs to fix

          Method selectStruct has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              static private function selectStruct($dlog, $start, $end=false)
              {
                  $config = FannieConfig::factory();
                  $sep = ($config->get('SERVER_DBMS') == 'MSSQL') ? '.dbo.' : '.';
                  $FANNIE_TRANS_DB = $config->get('TRANS_DB');
          Severity: Minor
          Found in fannie/classlib2.0/data/models/trans/DTransactionsModel.php - About 1 hr to fix

            Function selectStruct has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                static private function selectStruct($dlog, $start, $end=false)
                {
                    $config = FannieConfig::factory();
                    $sep = ($config->get('SERVER_DBMS') == 'MSSQL') ? '.dbo.' : '.';
                    $FANNIE_TRANS_DB = $config->get('TRANS_DB');
            Severity: Minor
            Found in fannie/classlib2.0/data/models/trans/DTransactionsModel.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 $union;
            Severity: Major
            Found in fannie/classlib2.0/data/models/trans/DTransactionsModel.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return ($dlog) ? $FANNIE_ARCHIVE_DB.$sep.'dlogBig' : $FANNIE_ARCHIVE_DB.$sep.'bigArchive';
              Severity: Major
              Found in fannie/classlib2.0/data/models/trans/DTransactionsModel.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return ($dlog) ? $FANNIE_ARCHIVE_DB.$sep.'dlog'.$yyyymm : $FANNIE_ARCHIVE_DB.$sep.'transArchive'.$yyyymm;
                Severity: Major
                Found in fannie/classlib2.0/data/models/trans/DTransactionsModel.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return ($dlog) ? $FANNIE_TRANS_DB.$sep.'dlog_90_view' : $FANNIE_TRANS_DB.$sep.'transarchive';
                  Severity: Major
                  Found in fannie/classlib2.0/data/models/trans/DTransactionsModel.php - About 30 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status