Showing 29 of 66 total issues
Function prepareBalancesTranslation
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function prepareBalancesTranslation($forexAccountId, int $accountId = null): array
{
if (Account::find($forexAccountId)->account_type != Account::EQUITY) {
throw new InvalidAccountType('Transaltion Forex', Account::EQUITY);
- 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
Account
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class Account extends Model implements Recyclable, Segregatable
{
use Segregating;
use SoftDeletes;
use Recycling;
Method save
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save(array $options = []): bool
{
if (is_null($this->entity_id)) {
$entity = Auth::user()->entity;
} else {
Method prepareBalancesTranslation
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function prepareBalancesTranslation($forexAccountId, int $accountId = null): array
{
if (Account::find($forexAccountId)->account_type != Account::EQUITY) {
throw new InvalidAccountType('Transaltion Forex', Account::EQUITY);
Method save
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save(array $options = []): bool
{
if (is_null($this->entity_id)) {
$entity = Auth::user()->entity;
} else {
Method getSections
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getSections($startDate = null, $endDate = null, $fullbalance = true): array
{
// Accounts movements for the Period
foreach (array_keys($this->balances) as $section) {
$this->balances[$section] = Account::sectionBalances(
Function save
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function save(array $options = []): bool
{
if (is_null($this->entity_id)) {
$entity = Auth::user()->entity;
} else {
- 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
Method getTransactions
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTransactions(): array
{
$entity = $this->account->entity;
$periodId = ReportingPeriod::getPeriod($this->period['endDate'], $entity)->id;
Method balanceAccount
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function balanceAccount(
int $forexAccountId,
Account $account,
float $localBalance,
float $foreignBalance,
Method allocateAmount
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function allocateAmount($postAccount, $amount, $posts, $folios, $transaction, $entryType): bool
{
if ($amount == 0) {
$key = array_key_first($posts);
unset($posts[$key]);
Method up
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function up()
{
Schema::create(
config('ifrs.table_prefix').'recycled_objects',
Method openingBalance
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function openingBalance(int $year = null, int $currencyId = null): array
{
$entity = $this->entity;
$balances = [$entity->currency_id => 0];
Method __construct
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(string $accountType = Account::RECEIVABLE, string $endDate = null, int $currencyId = null, Entity $entity = null)
{
if (is_null($entity)) {
$this->entity = Auth::user()->entity;
}else{
Consider simplifying this complex logical expression. Open
if ($transaction->is_credited && $rateDifference < 0 || !$transaction->is_credited && $rateDifference > 0) {
$post->entry_type = Balance::CREDIT;
$folio->entry_type = Balance::DEBIT;
} elseif ($transaction->is_credited && $rateDifference > 0 || !$transaction->is_credited && $rateDifference < 0) {
$post->entry_type = Balance::DEBIT;
Consider simplifying this complex logical expression. Open
if ($isAsset && $difference > 0 || $isLiability && $difference < 0) {
$credited = true;
} elseif ($isAsset && $difference < 0 || $isLiability && $difference > 0) {
$credited = false;
}
Function removeLineItem
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function removeLineItem(LineItem $lineItem): void
{
if (count($lineItem->ledgers) > 0) {
throw new PostedTransaction("remove LineItems from");
}
- 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
Method allocateAmount
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private static function allocateAmount($postAccount, $amount, $posts, $folios, $transaction, $entryType): bool
Function balanceAccount
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function balanceAccount(
int $forexAccountId,
Account $account,
float $localBalance,
float $foreignBalance,
- 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 postForex
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function postForex(Assignment $assignment, $transactionRate, $clearedRate): void
{
$rateDifference = round($transactionRate - $clearedRate, config('ifrs.forex_scale'));
$transaction = $assignment->transaction;
- 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
Method balanceAccount
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
int $forexAccountId,
Account $account,
float $localBalance,
float $foreignBalance,
Carbon $closingDate,