scottohara/loot

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

Summary

Maintainability
F
4 days
Test Coverage
A
100%

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

import type {
    Account,
    AccountType,
    Accounts,
    StoredAccountType,
Severity: Major
Found in src/schedules/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/schedules/controllers/edit.ts - About 4 hrs to fix

      ScheduleEditController has 27 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class ScheduleEditController {
          public transaction: ScheduledTransaction;
      
          public mode: "Add Schedule" | "Edit Schedule" | "Enter Transaction";
      
      
      Severity: Minor
      Found in src/schedules/controllers/edit.ts - About 3 hrs to fix

        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/schedules/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 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/schedules/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 constructor has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public constructor(
                $scope: angular.IScope,
                private readonly $uibModalInstance: angular.ui.bootstrap.IModalInstanceService,
                private readonly $timeout: angular.ITimeoutService,
                private readonly filterFilter: angular.IFilterFilter,
        Severity: Major
        Found in src/schedules/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/schedules/controllers/edit.ts - About 1 hr to fix

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

                private calculateNextDue(): void {
                    const WEEK = 1,
                        FORTNIGHT = 2,
                        MONTH = 1,
                        BIMONTH = 2,
            Severity: Minor
            Found in src/schedules/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/schedules/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/schedules/controllers/edit.ts - About 1 hr to fix

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

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

                    Function getSubtransactions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private getSubtransactions(
                            transaction?: Transaction,
                        ): angular.IPromise<SplitTransaction> | Transaction | undefined {
                            if (undefined === transaction) {
                                return undefined;
                    Severity: Minor
                    Found in src/schedules/controllers/edit.ts - About 1 hr to fix

                      There are no issues that match your filters.

                      Category
                      Status