api/src/workers/bulkInsert.worker.ts

Summary

Maintainability
F
1 wk
Test Coverage

Function create has a Cognitive Complexity of 136 (exceeds 5 allowed). Consider refactoring.
Open

const create = async ({
  docs,
  user,
  contentType,
  model,
Severity: Minor
Found in api/src/workers/bulkInsert.worker.ts - About 2 days 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 bulkInsert.worker.ts has 787 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as mongoose from 'mongoose';
import {
  Boards,
  Companies,
  Conformities,
Severity: Major
Found in api/src/workers/bulkInsert.worker.ts - About 1 day to fix

    Function prepareDocs has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const prepareDocs = async (body, type, collectionDocs) => {
        debugWorkers(`prepareDocs called`);
    
        const response = await fetchElk({
          action: 'search',
    Severity: Major
    Found in api/src/workers/bulkInsert.worker.ts - About 3 hrs to fix

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

        const generateUpdateDocs = async (
          _id,
          doc,
          prevCustomFieldsData: any = []
        ) => {
      Severity: Minor
      Found in api/src/workers/bulkInsert.worker.ts - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

              if (boardName && pipelineName && stageName) {
                const board = await Boards.findOne({
                  name: boardName,
                  type: contentType
                });
        Severity: Major
        Found in api/src/workers/bulkInsert.worker.ts - About 40 mins to fix

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

                  case 'basic':
                    {
                      doc[property.name] = value;
          
                      if (property.name === 'primaryName' && value) {
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 1 other location - About 1 day to fix
          api/src/commands/loadTestData.ts on lines 908..940

          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 263.

          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

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

              if (isBoardItem()) {
                doc.userId = user._id;
          
                if (boardName && pipelineName && stageName) {
                  const board = await Boards.findOne({
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 1 other location - About 6 hrs to fix
          api/src/commands/loadTestData.ts on lines 961..980

          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 161.

          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

              insertDocs.map(async (doc, docIndex) => {
                await createConformityMapping({
                  index: docIndex,
                  field: 'primaryEmail',
                  values: doc.customersPrimaryEmails || [],
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 1 other location - About 4 hrs to fix
          api/src/workers/bulkInsert.worker.ts on lines 381..401

          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 131.

          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

              insertDocs.map(async (doc, docIndex) => {
                await createConformityMapping({
                  index: docIndex,
                  field: 'primaryName',
                  values: doc.companiesPrimaryNames || [],
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 1 other location - About 4 hrs to fix
          api/src/workers/bulkInsert.worker.ts on lines 464..484

          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 131.

          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

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

                  case 'ownerEmail':
                    {
                      const userEmail = value;
          
                      const owner = await Users.findOne({ email: userEmail }).lean();
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 1 other location - About 1 hr to fix
          api/src/commands/loadTestData.ts on lines 854..862

          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 70.

          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 4 locations. Consider refactoring.
          Open

                if (doc.primaryEmail) {
                  docIdsByPrimaryEmail[doc.primaryEmail] = collection._id;
                  customFieldsByPrimaryEmail[doc.primaryEmail] =
                    doc.customFieldsData || [];
          
          
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 3 other locations - About 1 hr to fix
          api/src/workers/bulkInsert.worker.ts on lines 203..208
          api/src/workers/bulkInsert.worker.ts on lines 210..214
          api/src/workers/bulkInsert.worker.ts on lines 216..220

          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 55.

          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 4 locations. Consider refactoring.
          Open

                if (doc.primaryName) {
                  docIdsByPrimaryName[doc.primaryName] = collection._id;
                  customFieldsByPrimaryName[doc.primaryName] = doc.customFieldsData || [];
                  continue;
                }
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 3 other locations - About 1 hr to fix
          api/src/workers/bulkInsert.worker.ts on lines 195..201
          api/src/workers/bulkInsert.worker.ts on lines 203..208
          api/src/workers/bulkInsert.worker.ts on lines 216..220

          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 55.

          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 4 locations. Consider refactoring.
          Open

                if (doc.primaryPhone) {
                  docIdsByPrimaryPhone[doc.primaryPhone] = collection._id;
                  customFieldsByPrimaryPhone[doc.docIdsByPrimaryPhone] =
                    doc.customFieldsData || [];
                  continue;
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 3 other locations - About 1 hr to fix
          api/src/workers/bulkInsert.worker.ts on lines 195..201
          api/src/workers/bulkInsert.worker.ts on lines 210..214
          api/src/workers/bulkInsert.worker.ts on lines 216..220

          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 55.

          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 4 locations. Consider refactoring.
          Open

                if (doc.code) {
                  docIdsByCode[doc.code] = collection._id;
                  customFieldsByCode[doc.code] = doc.customFieldsData || [];
                  continue;
                }
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 3 other locations - About 1 hr to fix
          api/src/workers/bulkInsert.worker.ts on lines 195..201
          api/src/workers/bulkInsert.worker.ts on lines 203..208
          api/src/workers/bulkInsert.worker.ts on lines 210..214

          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 55.

          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 4 locations. Consider refactoring.
          Open

                if (doc.primaryPhone && docIdsByPrimaryPhone[doc.primaryPhone]) {
                  await generateUpdateDocs(
                    docIdsByPrimaryPhone[doc.primaryPhone],
                    doc,
                    customFieldsByPrimaryPhone[doc.primaryPhone]
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 3 other locations - About 50 mins to fix
          api/src/workers/bulkInsert.worker.ts on lines 224..231
          api/src/workers/bulkInsert.worker.ts on lines 242..249
          api/src/workers/bulkInsert.worker.ts on lines 251..258

          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 51.

          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 4 locations. Consider refactoring.
          Open

                if (doc.primaryEmail && docIdsByPrimaryEmail[doc.primaryEmail]) {
                  await generateUpdateDocs(
                    docIdsByPrimaryEmail[doc.primaryEmail],
                    doc,
                    customFieldsByPrimaryEmail[doc.primaryEmail]
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 3 other locations - About 50 mins to fix
          api/src/workers/bulkInsert.worker.ts on lines 233..240
          api/src/workers/bulkInsert.worker.ts on lines 242..249
          api/src/workers/bulkInsert.worker.ts on lines 251..258

          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 51.

          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 4 locations. Consider refactoring.
          Open

                if (doc.primaryName && docIdsByPrimaryName[doc.primaryName]) {
                  await generateUpdateDocs(
                    docIdsByPrimaryName[doc.primaryName],
                    doc,
                    customFieldsByPrimaryName[doc.customFieldsByPrimaryName]
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 3 other locations - About 50 mins to fix
          api/src/workers/bulkInsert.worker.ts on lines 224..231
          api/src/workers/bulkInsert.worker.ts on lines 233..240
          api/src/workers/bulkInsert.worker.ts on lines 251..258

          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 51.

          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 4 locations. Consider refactoring.
          Open

                if (doc.code && docIdsByCode[doc.code]) {
                  await generateUpdateDocs(
                    docIdsByCode[doc.code],
                    doc,
                    customFieldsByCode[doc.code]
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 3 other locations - About 50 mins to fix
          api/src/workers/bulkInsert.worker.ts on lines 224..231
          api/src/workers/bulkInsert.worker.ts on lines 233..240
          api/src/workers/bulkInsert.worker.ts on lines 242..249

          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 51.

          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 5 locations. Consider refactoring.
          Open

                if (bulkValues.primaryPhone.length > 0) {
                  queries.push({
                    terms: { 'primaryPhone.raw': bulkValues.primaryPhone }
                  });
                }
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 4 other locations - About 35 mins to fix
          api/src/workers/bulkInsert.worker.ts on lines 364..368
          api/src/workers/bulkInsert.worker.ts on lines 370..372
          api/src/workers/bulkInsert.worker.ts on lines 441..443
          api/src/workers/bulkInsert.worker.ts on lines 455..457

          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 46.

          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 5 locations. Consider refactoring.
          Open

                if (bulkValues.code.length > 0) {
                  queries.push({ terms: { 'code.raw': bulkValues.code } });
                }
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 4 other locations - About 35 mins to fix
          api/src/workers/bulkInsert.worker.ts on lines 364..368
          api/src/workers/bulkInsert.worker.ts on lines 441..443
          api/src/workers/bulkInsert.worker.ts on lines 449..453
          api/src/workers/bulkInsert.worker.ts on lines 455..457

          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 46.

          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 5 locations. Consider refactoring.
          Open

                if (bulkValues.primaryName.length > 0) {
                  queries.push({ terms: { 'primaryName.raw': bulkValues.primaryName } });
                }
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 4 other locations - About 35 mins to fix
          api/src/workers/bulkInsert.worker.ts on lines 364..368
          api/src/workers/bulkInsert.worker.ts on lines 370..372
          api/src/workers/bulkInsert.worker.ts on lines 449..453
          api/src/workers/bulkInsert.worker.ts on lines 455..457

          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 46.

          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 5 locations. Consider refactoring.
          Open

                if (bulkValues.code.length > 0) {
                  queries.push({ terms: { 'code.raw': bulkValues.code } });
                }
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 4 other locations - About 35 mins to fix
          api/src/workers/bulkInsert.worker.ts on lines 364..368
          api/src/workers/bulkInsert.worker.ts on lines 370..372
          api/src/workers/bulkInsert.worker.ts on lines 441..443
          api/src/workers/bulkInsert.worker.ts on lines 449..453

          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 46.

          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 5 locations. Consider refactoring.
          Open

                if (bulkValues.primaryPhone.length > 0) {
                  queries.push({
                    terms: { 'primaryPhone.raw': bulkValues.primaryPhone }
                  });
                }
          Severity: Major
          Found in api/src/workers/bulkInsert.worker.ts and 4 other locations - About 35 mins to fix
          api/src/workers/bulkInsert.worker.ts on lines 370..372
          api/src/workers/bulkInsert.worker.ts on lines 441..443
          api/src/workers/bulkInsert.worker.ts on lines 449..453
          api/src/workers/bulkInsert.worker.ts on lines 455..457

          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 46.

          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

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

                if (bulkValues.primaryEmail.length > 0) {
                  queries.push({ terms: { primaryEmail: bulkValues.primaryEmail } });
                }
          Severity: Minor
          Found in api/src/workers/bulkInsert.worker.ts and 1 other location - About 35 mins to fix
          api/src/workers/bulkInsert.worker.ts on lines 360..362

          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 46.

          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

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

                if (bulkValues.primaryEmail.length > 0) {
                  queries.push({ terms: { primaryEmail: bulkValues.primaryEmail } });
                }
          Severity: Minor
          Found in api/src/workers/bulkInsert.worker.ts and 1 other location - About 35 mins to fix
          api/src/workers/bulkInsert.worker.ts on lines 445..447

          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 46.

          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

                      v.code === doc.vendorCode ||
                      v.primaryName === doc.vendorCode ||
                      v.primaryEmail === doc.vendorCode ||
          Severity: Minor
          Found in api/src/workers/bulkInsert.worker.ts and 1 other location - About 30 mins to fix
          automations/src/utils.ts on lines 111..113

          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 45.

          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

          There are no issues that match your filters.

          Category
          Status