ekmungai/eloquent-ifrs

View on GitHub

Showing 39 of 66 total issues

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

<?php

/**
 * Eloquent IFRS Accounting
 *
Severity: Major
Found in src/Transactions/SupplierPayment.php and 1 other location - About 7 hrs to fix
src/Transactions/ClientReceipt.php on lines 1..79

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

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

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

<?php

/**
 * Eloquent IFRS Accounting
 *
Severity: Major
Found in src/Transactions/ClientReceipt.php and 1 other location - About 7 hrs to fix
src/Transactions/SupplierPayment.php on lines 1..79

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

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

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

<?php

/**
 * Eloquent IFRS Accounting
 *
Severity: Major
Found in src/Transactions/CashSale.php and 1 other location - About 3 hrs to fix
src/Transactions/CashPurchase.php on lines 1..58

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

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

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

<?php

/**
 * Eloquent IFRS Accounting
 *
Severity: Major
Found in src/Transactions/CashPurchase.php and 1 other location - About 3 hrs to fix
src/Transactions/CashSale.php on lines 1..58

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

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

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

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
database/migrations/2021_09_10_120836_add_compound_vat_column.php on lines 1..39

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

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

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

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

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
database/migrations/2021_08_25_192141_add_line_item_entry_column.php on lines 1..39

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

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

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

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

      <?php
      
      /**
       * Eloquent IFRS Accounting
       *
      Severity: Major
      Found in src/Exceptions/UnclearableTransaction.php and 1 other location - About 1 hr to fix
      src/Exceptions/UnassignableTransaction.php on lines 1..35

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

      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

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

      <?php
      
      /**
       * Eloquent IFRS Accounting
       *
      Severity: Major
      Found in src/Exceptions/UnassignableTransaction.php and 1 other location - About 1 hr to fix
      src/Exceptions/UnclearableTransaction.php on lines 1..35

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

      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

      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
                      Severity
                      Category
                      Status
                      Source
                      Language