ekmungai/eloquent-ifrs

View on GitHub

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);
Severity: Minor
Found in src/Models/ReportingPeriod.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

Account has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class Account extends Model implements Recyclable, Segregatable
{
    use Segregating;
    use SoftDeletes;
    use Recycling;
Severity: Minor
Found in src/Models/Account.php - About 2 hrs to fix

    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 {
    Severity: Minor
    Found in src/Models/Transaction.php - About 1 hr to fix

      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);
      Severity: Minor
      Found in src/Models/ReportingPeriod.php - About 1 hr to fix

        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 {
        Severity: Minor
        Found in src/Models/Balance.php - About 1 hr to fix

          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(
          Severity: Minor
          Found in src/Reports/CashFlowStatement.php - About 1 hr to fix

            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 {
            Severity: Minor
            Found in src/Models/Transaction.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

            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;
            Severity: Minor
            Found in src/Reports/AccountSchedule.php - About 1 hr to fix

              Method balanceAccount has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function balanceAccount(
                      int $forexAccountId,
                      Account $account,
                      float $localBalance,
                      float $foreignBalance,
              Severity: Minor
              Found in src/Models/ReportingPeriod.php - About 1 hr to fix

                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]);
                Severity: Minor
                Found in src/Models/Ledger.php - About 1 hr to fix

                  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];
                    Severity: Minor
                    Found in src/Models/Account.php - About 1 hr to fix

                      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{
                      Severity: Minor
                      Found in src/Reports/AgingSchedule.php - About 1 hr to fix

                        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;
                                }
                        Severity: Major
                        Found in src/Models/ReportingPeriod.php - About 1 hr to fix

                          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;
                          Severity: Major
                          Found in src/Models/Ledger.php - About 1 hr to fix

                            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;
                            
                            
                            Severity: Minor
                            Found in src/Models/Ledger.php - About 45 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

                            Method balanceAccount has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    int $forexAccountId,
                                    Account $account,
                                    float $localBalance,
                                    float $foreignBalance,
                                    Carbon $closingDate,
                            Severity: Minor
                            Found in src/Models/ReportingPeriod.php - About 45 mins to fix

                              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");
                                      }
                              Severity: Minor
                              Found in src/Models/Transaction.php - About 45 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

                              Method allocateAmount has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  private static function allocateAmount($postAccount, $amount, $posts, $folios, $transaction, $entryType): bool
                              Severity: Minor
                              Found in src/Models/Ledger.php - About 45 mins to fix

                                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,
                                Severity: Minor
                                Found in src/Models/ReportingPeriod.php - About 45 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

                                Severity
                                Category
                                Status
                                Source
                                Language