cityssm/faster-web-helper

View on GitHub

Showing 47 of 47 total issues

Function runInventoryTransactionsTask has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
Open

export default async function runInventoryTransactionsTask() {
    if (inventoryTransactionsConfig === undefined) {
        return;
    }
    debug(`Running "${taskName}"...`);
Severity: Minor
Found in modules/worktechUpdate/tasks/inventoryTransactionsTask.js - About 1 day 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

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

export function initializeWorktechUpdateDatabase(): boolean {
  let success = false

  const database = sqlite(databasePath)

Severity: Major
Found in modules/worktechUpdate/database/databaseHelpers.ts and 1 other location - About 5 hrs to fix
modules/purchaseOrderApprovals/database/databaseHelpers.ts on lines 56..83

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

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

export function initializePurchaseOrderApprovalsDatabase(): boolean {
  let success = false

  const database = sqlite(databasePath)

Severity: Major
Found in modules/purchaseOrderApprovals/database/databaseHelpers.ts and 1 other location - About 5 hrs to fix
modules/worktechUpdate/database/databaseHelpers.ts on lines 31..58

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

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

export function initializePurchaseOrderApprovalsDatabase() {
    let success = false;
    const database = sqlite(databasePath);
    const row = database
        .prepare(
Severity: Major
Found in modules/purchaseOrderApprovals/database/databaseHelpers.js and 1 other location - About 5 hrs to fix
modules/worktechUpdate/database/databaseHelpers.js on lines 23..42

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

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

export function initializeWorktechUpdateDatabase() {
    let success = false;
    const database = sqlite(databasePath);
    const row = database
        .prepare(
Severity: Major
Found in modules/worktechUpdate/database/databaseHelpers.js and 1 other location - About 5 hrs to fix
modules/purchaseOrderApprovals/database/databaseHelpers.js on lines 46..65

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

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

export default async function runInventoryTransactionsTask() {
    if (inventoryTransactionsConfig === undefined) {
        return;
    }
    debug(`Running "${taskName}"...`);
Severity: Major
Found in modules/worktechUpdate/tasks/inventoryTransactionsTask.js - About 4 hrs to fix

    Function initializeWorktechUpdateModule has 85 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default async function initializeWorktechUpdateModule(options?: ModuleInitializerOptions): Promise<void> {
      debug(`Initializing "${moduleName}"...`)
    
      /*
       * Ensure the local database is available.
    Severity: Major
    Found in modules/worktechUpdate/initializeWorktechUpdateModule.ts - About 3 hrs to fix

      Function _updateWorkOrderNumberMappings has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      async function _updateWorkOrderNumberMappings(report, data) {
          const mapping = getWorkOrderNumberMapping(data.documentNumber);
          const exportDate = dateStringToInteger(report.exportDate);
          const exportTime = timeStringToInteger(report.exportTime);
          if (mapping === undefined) {
      Severity: Minor
      Found in modules/worktechUpdate/tasks/directChargeHelperTask.js - 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

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

          if (itemNumbersConfig !== undefined) {
              updateItemNumbersJob = schedule.scheduleJob(updateItemNumbersTaskName, itemNumbersConfig.schedule, runUpdateItemNumbersTask);
              const updateItemNumbersFirstRunDate = new Date(updateItemNumbersJob.nextInvocation().getTime());
              debug(`Scheduled to run "${updateItemNumbersTaskName}" on ${dateToString(updateItemNumbersFirstRunDate)} at ${dateToTimePeriodString(updateItemNumbersFirstRunDate)}`);
          }
      Severity: Major
      Found in modules/autocomplete/initializeAutocompleteModule.js and 1 other location - About 2 hrs to fix
      modules/worktechUpdate/initializeWorktechUpdateModule.js on lines 67..71

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

      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 (activeEquipmentConfig !== undefined) {
          activeEquipmentJob = schedule.scheduleJob(
            activeEquipmentTaskName,
            activeEquipmentConfig.schedule,
            activeEquipmentTask
      Severity: Major
      Found in modules/worktechUpdate/initializeWorktechUpdateModule.ts and 1 other location - About 2 hrs to fix
      modules/autocomplete/initializeAutocompleteModule.ts on lines 82..96

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

      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 (activeEquipmentConfig !== undefined) {
              activeEquipmentJob = schedule.scheduleJob(activeEquipmentTaskName, activeEquipmentConfig.schedule, activeEquipmentTask);
              const activeEquipmentFirstRunDate = new Date(activeEquipmentJob.nextInvocation().getTime());
              debug(`Scheduled to run "${activeEquipmentTaskName}" on ${dateToString(activeEquipmentFirstRunDate)} at ${dateToTimePeriodString(activeEquipmentFirstRunDate)}`);
          }
      Severity: Major
      Found in modules/worktechUpdate/initializeWorktechUpdateModule.js and 1 other location - About 2 hrs to fix
      modules/autocomplete/initializeAutocompleteModule.js on lines 43..47

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

      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 (itemNumbersConfig !== undefined) {
          updateItemNumbersJob = schedule.scheduleJob(
            updateItemNumbersTaskName,
            itemNumbersConfig.schedule,
            runUpdateItemNumbersTask
      Severity: Major
      Found in modules/autocomplete/initializeAutocompleteModule.ts and 1 other location - About 2 hrs to fix
      modules/worktechUpdate/initializeWorktechUpdateModule.ts on lines 139..153

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

      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

      export default function addWorkOrderNumberMapping(workOrderNumberMapping) {
          const database = sqlite(databasePath);
          const results = database
              .prepare(`insert into WorkOrderNumberMappings
              (documentNumber, workOrderNumber, exportDate, exportTime)
      Severity: Major
      Found in modules/worktechUpdate/database/addWorkOrderNumberMapping.js and 1 other location - About 2 hrs to fix
      modules/worktechUpdate/database/updateWorkOrderNumberMapping.js on lines 3..14

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

      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

      export default function updateWorkOrderNumberMapping(workOrderNumberMapping) {
          const database = sqlite(databasePath);
          const results = database
              .prepare(`update WorkOrderNumberMappings
              set workOrderNumber = ?,
      modules/worktechUpdate/database/addWorkOrderNumberMapping.js on lines 3..12

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

      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

      export default function addWorkOrderNumberMapping(workOrderNumberMapping: {
        documentNumber: string | number
        workOrderNumber: string
        exportDate: number
        exportTime: number
      Severity: Major
      Found in modules/worktechUpdate/database/addWorkOrderNumberMapping.ts and 1 other location - About 2 hrs to fix
      modules/worktechUpdate/database/updateWorkOrderNumberMapping.ts on lines 7..30

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

      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

      export default function updateWorkOrderNumberMapping(
        workOrderNumberMapping: WorkOrderNumberMapping
      ): boolean {
        const database = sqlite(databasePath)
      
      
      modules/worktechUpdate/database/addWorkOrderNumberMapping.ts on lines 5..29

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

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

      export default function createUser(
        user: Partial<PurchaseOrderApprovalUser> & { userName: string }
      ): boolean {
        const database = sqlite(databasePath)
      
      
      Severity: Major
      Found in modules/purchaseOrderApprovals/database/createUser.ts - About 2 hrs to fix

        Function initializeAutocompleteModule has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default async function initializeAutocompleteModule(
          options: ModuleInitializerOptions
        ): Promise<void> {
          debug(`Initializing "${moduleName}"...`)
        
        
        Severity: Major
        Found in modules/autocomplete/initializeAutocompleteModule.ts - About 2 hrs to fix

          Function initializeWorktechUpdateModule has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default async function initializeWorktechUpdateModule(options) {
              debug(`Initializing "${moduleName}"...`);
              /*
               * Ensure the local database is available.
               */
          Severity: Minor
          Found in modules/worktechUpdate/initializeWorktechUpdateModule.js - About 1 hr to fix

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

            export async function downloadFilesToTemp(ftpPath) {
                await ensureTempFolderExists();
                const ftpClient = new Client();
                const downloadedFiles = [];
                try {
            Severity: Minor
            Found in helpers/functions.sftp.js - 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

            Severity
            Category
            Status
            Source
            Language