d3yii2/yii2-d3acc

View on GitHub
models/AcTran.php

Summary

Maintainability
F
1 wk
Test Coverage

File AcTran.php has 907 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * registre transactions and get data of transactions
 * 
 * @author Uldis Nelsons
Severity: Major
Found in models/AcTran.php - About 2 days to fix

    Method periodBalanceTotal has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function periodBalanceTotal(AcPeriod $period): array
        {
            $connection = Yii::$app->getDb();
    
            $command    = $connection->createCommand('
    Severity: Major
    Found in models/AcTran.php - About 3 hrs to fix

      Method accBalanceFilter has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function accBalanceFilter(
              int $accountId,
              AcPeriod $period,
              array $filter,
              bool $addPrevBalance = false
      Severity: Major
      Found in models/AcTran.php - About 2 hrs to fix

        Method accFilterExtPeriodBalanceByDays has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function accFilterExtPeriodBalanceByDays($accList,
                                                                   AcPeriod $period)
            {
        
                if (!$accList) {
        Severity: Major
        Found in models/AcTran.php - About 2 hrs to fix

          Method periodBalanceWithDimByCodeTotal has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function periodBalanceWithDimByCodeTotal(AcPeriod $period,int $accountId): array
              {
                  $connection = Yii::$app->getDb();
          
                  $command    = $connection->createCommand('
          Severity: Major
          Found in models/AcTran.php - About 2 hrs to fix

            Method periodBalanceDimTotal has 63 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function periodBalanceDimTotal(AcPeriod $period, array $accList,int $accDimGroupId): array
                {
                    $connection = Yii::$app->getDb();
            
                    $command    = $connection->createCommand('
            Severity: Major
            Found in models/AcTran.php - About 2 hrs to fix

              Method accBalanceFilterOld has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function accBalanceFilterOld($accountId, AcPeriod $period,
                                                          $filter, $addPrevPalance = false)
                  {
                      $selectSql = '   
                          IFNULL(SUM(
              Severity: Major
              Found in models/AcTran.php - About 2 hrs to fix

                Method periodBalanceTotal1x has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function periodBalanceTotal1x(AcPeriod $period)
                    {
                
                        $connection = Yii::$app->getDb();
                        $command    = $connection->createCommand('
                Severity: Major
                Found in models/AcTran.php - About 2 hrs to fix

                  Method accPeriodTran has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function accPeriodTran(AcRecAcc $acc, AcPeriod $period, $startBalance = true)
                      {
                          $connection = Yii::$app->getDb();
                          $command    = $connection->createCommand('
                              SELECT
                  Severity: Major
                  Found in models/AcTran.php - About 2 hrs to fix

                    Method periodBalanceByCodeTotal has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function periodBalanceByCodeTotal(AcPeriod $period,int $accountId): array
                        {
                            $connection = Yii::$app->getDb();
                    
                            $command    = $connection->createCommand('
                    Severity: Major
                    Found in models/AcTran.php - About 2 hrs to fix

                      Method periodBalance has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function periodBalance(AcPeriod $period, $addPrevBalance = true)
                          {
                              $unionPrevBalanceSql = '';
                              if($addPrevBalance){
                                  $unionPrevBalanceSql = '
                      Severity: Minor
                      Found in models/AcTran.php - About 2 hrs to fix

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

                            public static function accFilterAccPeriodBalanceByDays(AcRecAcc $acc,
                                                                                   $accFilter,
                                                                                   AcPeriod $period)
                            {
                                if (!is_array($accFilter)) {
                        Severity: Minor
                        Found in models/AcTran.php - About 1 hr to fix

                          Method accByDaysFilter has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function accByDaysFilter($accountId, AcPeriod $period, $filter)
                              {
                          
                                  $join    = $where   = $broupBy = [];
                                  foreach (AcAccount::findOne($accountId)->getAcDefs()->all() as $acDef) {
                          Severity: Minor
                          Found in models/AcTran.php - About 1 hr to fix

                            Method accPeriodBalanceByDays has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function accPeriodBalanceByDays(AcRecAcc $acc, AcPeriod $period, $addPrevToFirstDay = true)
                                {
                                    $connection = Yii::$app->getDb();
                                    $command    = $connection->createCommand('
                                        SELECT
                            Severity: Minor
                            Found in models/AcTran.php - About 1 hr to fix

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

                                  public static function registre2(
                                      AcRecAcc $debitAcc,
                                      AcRecAcc $creditAcc,
                                      float $amt,
                                      string $date,
                              Severity: Minor
                              Found in models/AcTran.php - About 1 hr to fix

                                Method accPeriodBalanceGroupedByCode has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public static function accPeriodBalanceGroupedByCode($accountId, AcPeriod $period)
                                    {
                                        $connection = Yii::$app->getDb();
                                        $command    = $connection->createCommand('
                                            SELECT
                                Severity: Minor
                                Found in models/AcTran.php - About 1 hr to fix

                                  Method accPeriodBalance has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public static function accPeriodBalance(AcRecAcc $acc, AcPeriod $period,
                                                                              $addPrevBalance = true)
                                      {
                                          $connection = Yii::$app->getDb();
                                          $command    = $connection->createCommand('
                                  Severity: Minor
                                  Found in models/AcTran.php - About 1 hr to fix

                                    Method registre2 has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                            AcRecAcc $debitAcc,
                                            AcRecAcc $creditAcc,
                                            float $amt,
                                            string $date,
                                            AcPeriod $period,
                                    Severity: Major
                                    Found in models/AcTran.php - About 1 hr to fix

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

                                          public static function registre2(
                                              AcRecAcc $debitAcc,
                                              AcRecAcc $creditAcc,
                                              float $amt,
                                              string $date,
                                      Severity: Minor
                                      Found in models/AcTran.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 accFilterExtPeriodBalanceByDays has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public static function accFilterExtPeriodBalanceByDays($accList,
                                                                                                 AcPeriod $period)
                                          {
                                      
                                              if (!$accList) {
                                      Severity: Minor
                                      Found in models/AcTran.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 periodBalanceTotal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public static function periodBalanceTotal(AcPeriod $period): array
                                          {
                                              $connection = Yii::$app->getDb();
                                      
                                              $command    = $connection->createCommand('
                                      Severity: Minor
                                      Found in models/AcTran.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

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

                                              foreach (AcAccount::findOne($accountId)->getAcDefs()->all() as $acDef) {
                                      
                                                  $tableAsName = '`r'.$acDef->table.'`';
                                      
                                                  $select[] = ','.$tableAsName.'.`pk_value` '.$acDef->table.'_pk_value';
                                      Severity: Major
                                      Found in models/AcTran.php and 1 other location - About 3 hrs to fix
                                      models/AcPeriodBalance.php on lines 114..128

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

                                      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 (AcAccount::findOne($accountId)->getAcDefs()->all() as $acDef) {
                                      
                                                  if (!isset($filter[$acDef->table])) {
                                                      continue;
                                                  }
                                      Severity: Major
                                      Found in models/AcTran.php and 1 other location - About 1 hr to fix
                                      models/AcTran.php on lines 1033..1044

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

                                      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 (AcAccount::findOne($accountId)->getAcDefs()->all() as $acDef) {
                                      
                                                  if (!isset($filter[$acDef->table])) {
                                                      continue;
                                                  }
                                      Severity: Major
                                      Found in models/AcTran.php and 1 other location - About 1 hr to fix
                                      models/AcTran.php on lines 974..985

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

                                      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