scottohara/loot

View on GitHub

Showing 124 of 298 total issues

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 editSchedule has 74 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private editSchedule(index?: number): void {
            // Helper function to sort by next due date, then by transaction id
            function byNextDueDateAndId(
                a: ScheduledTransaction,
                b: ScheduledTransaction,
    Severity: Major
    Found in src/schedules/controllers/index.ts - About 2 hrs to fix

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

      import type { Account, Accounts } from "~/accounts/types";
      import type {
          ControllerTestFactory,
          JQueryKeyEventObjectMock,
      } from "~/mocks/types";
      Severity: Minor
      Found in src/accounts/controllers/index.test.ts - About 2 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

          Function editCategory has 70 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public editCategory(index?: number): void {
                  // Helper function to sort by direction, then by category name, then by subcategory name
                  function byDirectionAndName(a: Category, b: Category): number {
                      let x: string, y: string;
          
          
          Severity: Major
          Found in src/categories/controllers/index.ts - About 2 hrs to fix

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

                public constructor(
                    private readonly $q: QMock = {
                        defer<T>(): DeferredMock<T> {
                            let isResolved = false,
                                promiseValue: PromiseMock<T> | T | undefined,
            Severity: Minor
            Found in src/mocks/node-modules/angular/services/q.ts - 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

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

            import { addDays, lightFormat, startOfDay } from "date-fns";
            import {
                checkRowMatches,
                checkSubtransactionRowValues,
                scheduleSubtransactionsTableRows,
            Severity: Minor
            Found in cypress/e2e/schedules/index.cy.ts - About 2 hrs to fix

              Function populateFormWith has 64 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function populateFormWith(schedule: ScheduleEdit): void {
                  const {
                      primaryAccountName,
                      frequency,
                      rawNextDueDate,
              Severity: Major
              Found in cypress/support/schedules/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 deleteCategory has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public deleteCategory(index: number): void {
                          // Check if the category can be deleted
                          this.categoryModel
                              .find(Number(this.categories[index].id))
                              .then((category: Category): void => {
                  Severity: Major
                  Found in src/categories/controllers/index.ts - About 2 hrs to fix

                    Method ledger_query has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def ledger_query(opts)
                            # Get the specified number of transactions up to the given date
                            transactions
                                .for_ledger(opts)
                                .select(
                    Severity: Major
                    Found in app/models/concerns/transactable.rb - About 2 hrs to fix

                      Function transactionsState has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              function transactionsState(parentContext: string): angular.ui.IState {
                                  return {
                                      url: "/transactions",
                                      data: {
                                          title: `${
                      Severity: Major
                      Found in src/loot/providers/states.ts - About 2 hrs to fix

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

                                  public constructor(
                                      $sce: angular.ISCEService,
                                      transactionModel: TransactionModel,
                                      accountModel: AccountModel,
                                      ogModalErrorService: OgModalErrorService,
                              Severity: Major
                              Found in src/transactions/directives/status.ts - About 2 hrs to fix

                                File layout.test.ts has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                import type {
                                    StateMock,
                                    UibModalMock,
                                } from "~/mocks/node-modules/angular/types";
                                import type { AuthenticationModelMock } from "~/mocks/authentication/types";
                                Severity: Minor
                                Found in src/loot/controllers/layout.test.ts - About 2 hrs to fix

                                  Method closing_balance has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def closing_balance(balance_opts = {})
                                          as_at =
                                              begin
                                                  ::Date.parse(balance_opts[:as_at]).to_s
                                              rescue ::TypeError, ::ArgumentError
                                  Severity: Minor
                                  Found in app/models/concerns/transactable.rb - 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

                                  Function populateFormWith has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export function populateFormWith(transaction: TransactionEdit): void {
                                      const {
                                          rawTransactionDate,
                                          payeeName,
                                          securityName,
                                  Severity: Major
                                  Found in cypress/support/transactions/edit.ts - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language