theBenForce/data-migration

View on GitHub

Showing 43 of 43 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        return new Listr(
          filteredScripts.map((script) => ({
            title: script.description ?? script.name,
            task: () =>
              new Listr([
packages/data-migration-cli/src/commands/up.ts on lines 43..63

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 145.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

          return new Listr(
            filteredScripts.map((script) => ({
              title: script.description ?? script.name,
              task: () =>
                new Listr([
Severity: Major
Found in packages/data-migration-cli/src/commands/up.ts and 1 other location - About 5 hrs to fix
packages/data-migration-cli/src/utils/createDownMigrationTasks.ts on lines 33..53

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 145.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function dynamoDbDriver has 115 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const dynamoDbDriver: DriverBuilder<DynamoDbParameters, AWS.DynamoDB.DocumentClient> = (
  params,
  logger: Logger
): DynamoDbDriver => {
  let { TableName } = params;
Severity: Major
Found in plugins/drivers/dynamodb/src/index.ts - About 4 hrs to fix

    Function rdsDriver has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const rdsDriver: DriverBuilder<AuroraRdsParameters, AWS.RDSDataService> = (
      params: AuroraRdsParameters,
      logger: Logger
    ): AuroraRdsDriver => {
      let dataService: AWS.RDSDataService;
    Severity: Major
    Found in plugins/drivers/aurora-rds/src/index.ts - About 3 hrs to fix

      Function s3DriverBuilder has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const s3DriverBuilder: DriverBuilder<S3DriverParameters, AWS.S3> = (
        params,
        logger: Logger
      ): S3Driver => {
        let bucketName: string;
      Severity: Major
      Found in plugins/drivers/s3/src/index.ts - About 3 hrs to fix

        Function getScripts has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

        export default async function getScripts({
          config,
          scope,
          context,
          log,
        Severity: Minor
        Found in packages/data-migration/src/methods/GetScripts.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 lambdaDriverBuilder has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const lambdaDriverBuilder: DriverBuilder<LambdaParameters, AWS.Lambda> = (
          params,
          logger: Logger
        ): LambdaDriver => {
          let FunctionName: string;
        Severity: Major
        Found in plugins/drivers/lambda/src/index.ts - About 2 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            const DocumentDb = new AWS.DynamoDB.DocumentClient({
              region: params.region,
              apiVersion: "2012-08-10",
              accessKeyId: params.accessKeyId,
              secretAccessKey: params.secretAccessKey,
          Severity: Major
          Found in plugins/trackers/dynamo/src/index.ts and 1 other location - About 2 hrs to fix
          plugins/drivers/dynamodb/src/index.ts on lines 39..48

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 88.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                DocumentDb = new AWS.DynamoDB.DocumentClient({
                  region: params.region,
                  apiVersion: "2012-08-10",
                  accessKeyId: params.accessKeyId,
                  secretAccessKey: params.secretAccessKey,
          Severity: Major
          Found in plugins/drivers/dynamodb/src/index.ts and 1 other location - About 2 hrs to fix
          plugins/trackers/dynamo/src/index.ts on lines 29..38

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 88.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function cognitoDriver has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const cognitoDriver: DriverBuilder<CognitoDriverParams, AWS.CognitoIdentityServiceProvider> = (
            params,
            logger: Logger
          ): CognitoDriver => {
            let cognitoidentityserviceprovider: AWS.CognitoIdentityServiceProvider;
          Severity: Major
          Found in plugins/drivers/cognito/src/index.ts - About 2 hrs to fix

            Function tracker has 62 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const tracker: ExecutionTracker<DynamoTrackerParams> = (params, log: Logger) => {
              const { TableName } = params;
              const DocumentDb = new AWS.DynamoDB.DocumentClient({
                region: params.region,
                apiVersion: "2012-08-10",
            Severity: Major
            Found in plugins/trackers/dynamo/src/index.ts - About 2 hrs to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                if (params.upFile !== undefined) {
                  const sqlFileName = params.upFile;
                  const taskName = `up migration ${sqlFileName}`;
              
                  result.up = createMigrationExecutor({
              Severity: Major
              Found in packages/data-migration/src/tasks/sql.ts and 1 other location - About 2 hrs to fix
              packages/data-migration/src/tasks/sql.ts on lines 63..72

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 77.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                if (params.downFile !== undefined) {
                  const sqlFileName = params.downFile;
                  const taskName = `down migration ${sqlFileName}`;
              
                  result.down = createMigrationExecutor({
              Severity: Major
              Found in packages/data-migration/src/tasks/sql.ts and 1 other location - About 2 hrs to fix
              packages/data-migration/src/tasks/sql.ts on lines 52..61

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 77.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Function run has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async run() {
                  const { args, flags } = this.parse(List);
                  const { scripts } = await loadScripts(flags);
              
                  cli.info(`Found ${scripts.length} scripts`);
              Severity: Minor
              Found in packages/data-migration-cli/src/commands/list.ts - About 1 hr to fix

                Function createScriptContext has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                export default function createScriptContext(
                  drivers: Map<string, Driver<any, any>>,
                  config: { [key: string]: string },
                  log: Logger,
                  defaultParams?: Record<string, string>
                Severity: Minor
                Found in packages/data-migration/src/methods/CreateScriptContext.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 loadScripts has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default async function loadScripts(
                  flags: DefaultFlagParameters
                ): Promise<LoadScriptsResult> {
                  let config = await loadConfiguration(path.resolve(flags.config), { flags });
                  let stage = "prod";
                Severity: Minor
                Found in packages/data-migration-cli/src/utils/loadScripts.ts - About 1 hr to fix

                  Function run has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async run() {
                      const { flags } = this.parse(Up);
                      let stage: string = "";
                      let scripts: Array<InitializedMigrationScript>;
                      let context: ScriptContext;
                  Severity: Minor
                  Found in packages/data-migration-cli/src/commands/up.ts - About 1 hr to fix

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

                    export default function (flags: DefaultFlagParameters, numberToRun: number = Infinity): Listr {
                      let stage: string = "";
                      let scripts: Array<InitializedMigrationScript>;
                      let context: ScriptContext;
                    
                    
                    Severity: Minor
                    Found in packages/data-migration-cli/src/utils/createDownMigrationTasks.ts - About 1 hr to fix

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                          {
                            title: `Load configuration`,
                            async task() {
                              const scriptDetails = await loadScripts(flags);
                              scripts = scriptDetails.scripts;
                      packages/data-migration-cli/src/commands/up.ts on lines 27..35

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 66.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                            {
                              title: `Load configuration`,
                              async task() {
                                const scriptDetails = await loadScripts(flags);
                                scripts = scriptDetails.scripts;
                      Severity: Major
                      Found in packages/data-migration-cli/src/commands/up.ts and 1 other location - About 1 hr to fix
                      packages/data-migration-cli/src/utils/createDownMigrationTasks.ts on lines 14..22

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 66.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Severity
                      Category
                      Status
                      Source
                      Language