scottohara/loot

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

Summary

Maintainability
F
5 days
Test Coverage
A
100%

File index.ts has 779 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Function editTransaction has 134 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private editTransaction(index?: number): void {
            // Helper function to sort by transaction date, then by transaction id
            function byTransactionDateAndId(a: Transaction, b: Transaction): number {
                let x: Date | number, y: Date | number;
    
    
    Severity: Major
    Found in src/transactions/controllers/index.ts - About 5 hrs to fix

      Function editTransaction has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          private editTransaction(index?: number): void {
              // Helper function to sort by transaction date, then by transaction id
              function byTransactionDateAndId(a: Transaction, b: Transaction): number {
                  let x: Date | number, y: Date | number;
      
      
      Severity: Minor
      Found in src/transactions/controllers/index.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

      TransactionIndexController has 29 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class TransactionIndexController {
          public readonly tableActions: OgTableActions;
      
          public readonly today: Date = startOfDay(new Date());
      
      
      Severity: Minor
      Found in src/transactions/controllers/index.ts - About 3 hrs to fix

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

            public constructor(
                $scope: angular.IScope,
                $transitions: angular.ui.IStateParamsService,
                private readonly $uibModal: angular.ui.bootstrap.IModalService,
                private readonly $timeout: angular.ITimeoutService,
        Severity: Major
        Found in src/transactions/controllers/index.ts - About 2 hrs to fix

          Function transaction has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                              transaction: ():
                                  | angular.IPromise<Transaction>
                                  | Partial<SecurityTransaction | Transaction>
                                  | Transaction => {
                                  // If we didn't get an index, we're adding a new transaction
          Severity: Major
          Found in src/transactions/controllers/index.ts - About 2 hrs to fix

            Function reconcile has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public reconcile(): void {
                    if (!this.reconciling) {
                        // Disable navigation on the table
                        this.ogTableNavigableService.enabled = false;
            
            
            Severity: Minor
            Found in src/transactions/controllers/index.ts - About 1 hr to fix

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

                  private transitionSuccessHandler(transactionId: number): void {
                      if (isNaN(this.focusTransaction(transactionId))) {
                          // Transaction was not found in the current set
              
                          // Get the transaction details from the server
              Severity: Minor
              Found in src/transactions/controllers/index.ts - About 1 hr to fix

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

                    public getTransactions(
                        direction: TransactionFetchDirection,
                        fromDate?: Date,
                        transactionIdToFocus?: number,
                    ): void {
                Severity: Minor
                Found in src/transactions/controllers/index.ts - About 1 hr to fix

                  Function updateClosingBalance has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private updateClosingBalance(
                          originalTransaction?: Transaction,
                          newTransaction?: Transaction,
                      ): void {
                          // Only proceed if the context has a closing balance (ie. not in search mode)
                  Severity: Minor
                  Found in src/transactions/controllers/index.ts - 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

                  Function contextChanged has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private contextChanged(transaction: Transaction): boolean {
                          let currentContext: Entity | null | undefined;
                  
                          // Check if the transaction still matches the context
                          switch (this.contextType) {
                  Severity: Minor
                  Found in src/transactions/controllers/index.ts - About 1 hr to fix

                    Function promptToSwitchAccounts has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private promptToSwitchAccounts(
                            message: string,
                            transaction: SplitTransactionChild | Transaction,
                        ): void {
                            // Disable navigation on the table
                    Severity: Minor
                    Found in src/transactions/controllers/index.ts - About 1 hr to fix

                      Function constructor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public constructor(
                              $scope: angular.IScope,
                              $transitions: angular.ui.IStateParamsService,
                              private readonly $uibModal: angular.ui.bootstrap.IModalService,
                              private readonly $timeout: angular.ITimeoutService,
                      Severity: Minor
                      Found in src/transactions/controllers/index.ts - About 55 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

                      Function getTransactions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public getTransactions(
                              direction: TransactionFetchDirection,
                              fromDate?: Date,
                              transactionIdToFocus?: number,
                          ): void {
                      Severity: Minor
                      Found in src/transactions/controllers/index.ts - About 35 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