sundowndev/underbase

View on GitHub

Showing 11 of 13 total issues

Function execute has 112 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private async execute(version: number, rerun?: boolean): Promise<void> {
    const control = await this.getControl(); // Side effect: upserts control document.
    let currentVersion = control.version;

    // Run the actual migration
Severity: Major
Found in packages/core/src/classes/Migration.ts - About 4 hrs to fix

    File Migration.ts has 347 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // tslint:disable:variable-name
    import { EDirection, IMigration, IMigrationOptions } from '@underbase/types';
    import { logger } from '@underbase/utils';
    import chalk from 'chalk';
    import _ from 'lodash';
    Severity: Minor
    Found in packages/core/src/classes/Migration.ts - About 4 hrs to fix

      Function execute has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

        private async execute(version: number, rerun?: boolean): Promise<void> {
          const control = await this.getControl(); // Side effect: upserts control document.
          let currentVersion = control.version;
      
          // Run the actual migration
      Severity: Minor
      Found in packages/core/src/classes/Migration.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 checkMigrationPaths has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      const checkMigrationPaths = async (config: IConfigFile, versions: string[]) => {
        let success = true;
        const migrations = await getMigrationsEntryFiles(config, versions);
      
        for (const path of migrations) {
      Severity: Minor
      Found in packages/cli/src/commands/validate.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

      Function checkMigrationPaths has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const checkMigrationPaths = async (config: IConfigFile, versions: string[]) => {
        let success = true;
        const migrations = await getMigrationsEntryFiles(config, versions);
      
        for (const path of migrations) {
      Severity: Minor
      Found in packages/cli/src/commands/validate.ts - About 1 hr to fix

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

            const migrate = async (
              direction: EDirection,
              idx: number,
            ): Promise<void> => {
              if (!this._db) {
        Severity: Minor
        Found in packages/core/src/classes/Migration.ts - About 1 hr to fix

          Function migrateTo has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public async migrateTo(command: string | number): Promise<void> {
              if (!this._db) {
                throw new Error(
                  'Migration instance has not be configured/initialized.' +
                    ' Call <instance>.config(..) to initialize this instance',
          Severity: Minor
          Found in packages/core/src/classes/Migration.ts - About 1 hr to fix

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

              public async config(opts?: IMigrationOptions): Promise<void> {
                this.options = Object.assign({}, this.options, opts);
            
                if (this.options.logger === null && this.options.logs === true) {
                  this.options.logger = logger;
            Severity: Minor
            Found in packages/core/src/classes/Migration.ts - About 1 hr to fix

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

              export const action: TCommandAction = async ({ config, versions, argv }) => {
                if (config.supportFile && fs.existsSync(path.resolve(config.supportFile))) {
                  try {
                    const support = await import(path.resolve(config.supportFile));
              
              
              Severity: Minor
              Found in packages/cli/src/commands/migrate.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 migrateTo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                public async migrateTo(command: string | number): Promise<void> {
                  if (!this._db) {
                    throw new Error(
                      'Migration instance has not be configured/initialized.' +
                        ' Call <instance>.config(..) to initialize this instance',
              Severity: Minor
              Found in packages/core/src/classes/Migration.ts - About 45 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 config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                public async config(opts?: IMigrationOptions): Promise<void> {
                  this.options = Object.assign({}, this.options, opts);
              
                  if (this.options.logger === null && this.options.logs === true) {
                    this.options.logger = logger;
              Severity: Minor
              Found in packages/core/src/classes/Migration.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

              Severity
              Category
              Status
              Source
              Language