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
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('
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
Method accFilterExtPeriodBalanceByDays
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function accFilterExtPeriodBalanceByDays($accList,
AcPeriod $period)
{
if (!$accList) {
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('
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('
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(
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('
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
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('
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 = '
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)) {
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) {
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
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,
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
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('
Method registre2
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
AcRecAcc $debitAcc,
AcRecAcc $creditAcc,
float $amt,
string $date,
AcPeriod $period,
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,
- Read upRead up
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) {
- Read upRead up
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('
- Read upRead up
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';
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76