department-of-veterans-affairs/vets-website

View on GitHub
src/applications/static-pages/events/helpers/event-generator.js

Summary

Maintainability
D
3 days
Test Coverage

File event-generator.js has 319 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import moment from 'moment-timezone';
import { fleshOutRecurringEvents, removeDuplicateEvents } from '.';

moment.tz.setDefault('America/New_York');
const now = moment().clone();
Severity: Minor
Found in src/applications/static-pages/events/helpers/event-generator.js - About 3 hrs to fix

    Function createLocationEvents has 91 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const createLocationEvents = () => {
      const facilityEventData = {
        fieldEventCost: 'Free',
        fieldFacilityLocation: {
          entity: {
    Severity: Major
    Found in src/applications/static-pages/events/helpers/event-generator.js - About 3 hrs to fix

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

      const createRecurringEvents = () => {
        const recurEventData = { id: 'upcoming' };
        const eventA = createEvent(
          now
            .clone()
      Severity: Minor
      Found in src/applications/static-pages/events/helpers/event-generator.js - About 1 hr to fix

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

        const createFutureEvents = () => {
          // Types: upcoming, next-month, next-week
          return [
            // upcoming
            createEvent(
        Severity: Minor
        Found in src/applications/static-pages/events/helpers/event-generator.js - About 1 hr to fix

          Function createDuplicateEvents has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const createDuplicateEvents = () => {
            const eventA = createEvent(
              now
                .clone()
                .add(5, 'days')
          Severity: Minor
          Found in src/applications/static-pages/events/helpers/event-generator.js - About 1 hr to fix

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

              eventB.fieldDatetimeRangeTimezone.push({
                value: now
                  .clone()
                  .subtract(1, 'week')
                  .unix(),
            src/applications/static-pages/events/helpers/event-generator.js on lines 71..82

            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

              eventA.fieldDatetimeRangeTimezone.push({
                value: now
                  .clone()
                  .add(1, 'week')
                  .unix(),
            src/applications/static-pages/events/helpers/event-generator.js on lines 93..104

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

              const eventA = createEvent(
                now
                  .clone()
                  .add(5, 'days')
                  .unix(),
            src/applications/static-pages/events/helpers/index.unit.spec.js on lines 322..334
            src/applications/static-pages/events/helpers/index.unit.spec.js on lines 370..382

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

            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

                createEvent(
                  moment(`${lastYear}-01-04 10:15:00`).unix(),
                  moment(`${lastYear}-01-04 10:15:00`)
                    .add(1, 'hour')
                    .unix(),
            src/applications/static-pages/events/helpers/event-generator.js on lines 128..135

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

            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

                createEvent(
                  moment(`${lastYear}-06-01 12:00:00`).unix(),
                  moment(`${lastYear}-06-01 12:00:00`)
                    .add(1, 'hour')
                    .unix(),
            src/applications/static-pages/events/helpers/event-generator.js on lines 120..127

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

            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

                createEvent(
                  now
                    .clone()
                    .add(1, 'day')
                    .unix(),
            src/applications/static-pages/events/helpers/event-generator.js on lines 276..288

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

            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

                createEvent(
                  now
                    .clone()
                    .add(1, 'day')
                    .unix(),
            src/applications/static-pages/events/helpers/event-generator.js on lines 263..275

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

            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