scottohara/loot

View on GitHub
src/transactions/controllers/edit.ts

Summary

Maintainability
F
4 days
Test Coverage
A
100%

File edit.ts has 701 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import type { Account, StoredAccountType } from "~/accounts/types";
import type {
    CashTransaction,
    CategorisableTransaction,
    PayeeCashTransaction,
Severity: Major
Found in src/transactions/controllers/edit.ts - About 1 day to fix

    Function categorySelected has 101 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public categorySelected(index?: number): void {
            const transaction: SplitTransactionChild | Transaction = isNaN(
                Number(index),
            )
                ? this.transaction
    Severity: Major
    Found in src/transactions/controllers/edit.ts - About 4 hrs to fix

      Function categorySelected has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public categorySelected(index?: number): void {
              const transaction: SplitTransactionChild | Transaction = isNaN(
                  Number(index),
              )
                  ? this.transaction
      Severity: Minor
      Found in src/transactions/controllers/edit.ts - About 3 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

      Function updateInvestmentDetails has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public updateInvestmentDetails(): void {
              const QUANTITY_DECIMAL_PLACES = 4,
                  PRICE_DECIMAL_PLACES = 3,
                  AMOUNT_DECIMAL_PLACES = 2;
      
      
      Severity: Minor
      Found in src/transactions/controllers/edit.ts - About 3 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

      Function invalidateCaches has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private invalidateCaches(
              savedTransaction: Transaction,
          ): angular.IPromise<Transaction> {
              // Create a deferred so that we return a promise
              const q: angular.IDeferred<Transaction> = this.$q.defer(),
      Severity: Major
      Found in src/transactions/controllers/edit.ts - About 3 hrs to fix

        Function updateLruCaches has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private updateLruCaches(
                transaction: Transaction,
            ): angular.IPromise<Transaction> {
                // Create a deferred so that we return a promise
                const q: angular.IDeferred<Transaction> = this.$q.defer();
        Severity: Major
        Found in src/transactions/controllers/edit.ts - About 2 hrs to fix

          TransactionEditController has 23 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export default class TransactionEditController {
              public transaction: Transaction;
          
              public readonly mode: "Add" | "Edit";
          
          
          Severity: Minor
          Found in src/transactions/controllers/edit.ts - About 2 hrs to fix

            Function updateInvestmentDetails has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public updateInvestmentDetails(): void {
                    const QUANTITY_DECIMAL_PLACES = 4,
                        PRICE_DECIMAL_PLACES = 3,
                        AMOUNT_DECIMAL_PLACES = 2;
            
            
            Severity: Minor
            Found in src/transactions/controllers/edit.ts - About 1 hr to fix

              Function constructor has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public constructor(
                      $scope: angular.IScope,
                      private readonly $uibModalInstance: angular.ui.bootstrap.IModalInstanceService,
                      private readonly $q: angular.IQService,
                      private readonly $timeout: angular.ITimeoutService,
              Severity: Minor
              Found in src/transactions/controllers/edit.ts - About 1 hr to fix

                Function investmentCategorySelected has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public investmentCategorySelected(): void {
                        let { transaction_type, direction } = this.transaction;
                
                        // Check the category selection
                        if ("object" === typeof this.transaction.category) {
                Severity: Minor
                Found in src/transactions/controllers/edit.ts - About 1 hr to fix

                  Function categories has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public categories(
                          filter: string,
                          limit: number,
                          parent?: Category | null,
                          includeSplits = false,
                  Severity: Minor
                  Found in src/transactions/controllers/edit.ts - About 1 hr to fix

                    Function useLastTransaction has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private useLastTransaction(transaction?: Partial<Transaction>): void {
                            if (undefined === transaction) {
                                return;
                            }
                    
                    
                    Severity: Minor
                    Found in src/transactions/controllers/edit.ts - About 1 hr to fix

                      Function updateLruCaches has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private updateLruCaches(
                              transaction: Transaction,
                          ): angular.IPromise<Transaction> {
                              // Create a deferred so that we return a promise
                              const q: angular.IDeferred<Transaction> = this.$q.defer();
                      Severity: Minor
                      Found in src/transactions/controllers/edit.ts - 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

                      There are no issues that match your filters.

                      Category
                      Status