18F/web-design-standards

View on GitHub

Showing 368 of 368 total issues

Avoid deeply nested control flow statements.
Open

          if (allFilesAllowed) {
            TYPE_IS_VALID = true;
            break;
          }
Severity: Major
Found in packages/usa-file-input/src/index.js - About 45 mins to fix

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

    const tests = [
      { name: "document.body", selector: () => document.body },
      {
        name: "in page nav",
        selector: () => document.querySelector(".usa-in-page-nav"),
    packages/usa-banner/src/test/banner.spec.js on lines 10..13
    packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
    packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
    packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
    packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
    packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
    packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
    packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
    packages/usa-footer/src/test/footer.spec.js on lines 36..39
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
    packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

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

    const tests = [
      { name: "document.body", selector: () => document.body },
      {
        name: "combo box",
        selector: () => document.querySelector(".usa-combo-box"),
    Severity: Major
    Found in packages/usa-combo-box/src/test/combo-box-filter.spec.js and 17 other locations - About 45 mins to fix
    packages/usa-banner/src/test/banner.spec.js on lines 10..13
    packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
    packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
    packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
    packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
    packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
    packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
    packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
    packages/usa-footer/src/test/footer.spec.js on lines 36..39
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
    packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

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

    const tests = [
      { name: "document.body", selector: () => document.body },
      {
        name: "file input",
        selector: () => document.querySelector(".usa-file-input"),
    Severity: Major
    Found in packages/usa-file-input/src/test/file-input.spec.js and 17 other locations - About 45 mins to fix
    packages/usa-banner/src/test/banner.spec.js on lines 10..13
    packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
    packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
    packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
    packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
    packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
    packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
    packages/usa-footer/src/test/footer.spec.js on lines 36..39
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
    packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

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

    const tests = [
      { name: "document.body", selector: () => document.body },
      {
        name: "combo box",
        selector: () => document.querySelector(".usa-combo-box"),
    Severity: Major
    Found in packages/usa-combo-box/src/test/combo-box.spec.js and 17 other locations - About 45 mins to fix
    packages/usa-banner/src/test/banner.spec.js on lines 10..13
    packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
    packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
    packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
    packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
    packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
    packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
    packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
    packages/usa-footer/src/test/footer.spec.js on lines 36..39
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
    packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

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

    const tests = [
      { name: "document.body", selector: () => document.body },
      {
        name: "combo box",
        selector: () => document.querySelector(".usa-combo-box"),
    packages/usa-banner/src/test/banner.spec.js on lines 10..13
    packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
    packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
    packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
    packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
    packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
    packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
    packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
    packages/usa-footer/src/test/footer.spec.js on lines 36..39
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
    packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

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

    const tests = [
      { name: "document.body", selector: () => document.body },
      {
        name: "character count",
        selector: () => document.querySelector(".usa-character-count"),
    packages/usa-banner/src/test/banner.spec.js on lines 10..13
    packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
    packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
    packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
    packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
    packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
    packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
    packages/usa-footer/src/test/footer.spec.js on lines 36..39
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
    packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

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

    const tests = [
      { name: "document.body", selector: () => document.body },
      { name: "tooltip", selector: () => document.querySelector(".usa-tooltip") },
    ];
    Severity: Major
    Found in packages/usa-tooltip/src/test/tooltips.spec.js and 17 other locations - About 45 mins to fix
    packages/usa-banner/src/test/banner.spec.js on lines 10..13
    packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
    packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
    packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
    packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
    packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
    packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
    packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
    packages/usa-footer/src/test/footer.spec.js on lines 36..39
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43

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

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

    const tests = [
      { name: "document.body", selector: () => document.body },
      { name: "banner", selector: () => document.querySelector(".usa-banner") },
    ];
    Severity: Major
    Found in packages/usa-banner/src/test/banner.spec.js and 17 other locations - About 45 mins to fix
    packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
    packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
    packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
    packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
    packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
    packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
    packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
    packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
    packages/usa-footer/src/test/footer.spec.js on lines 36..39
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
    packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
    packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

    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

    Avoid deeply nested control flow statements.
    Open

                  if (url.length) {
                    // get the cached xhr request
                    var xhr = requests[url];
                    // ensure the xhr request exists
                    xhr ||
    Severity: Major
    Found in packages/uswds-core/src/js/polyfills/svg4everybody.js - About 45 mins to fix

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

      const tests = [
        { name: "document.body", selector: () => document.body },
        {
          name: "combo box",
          selector: () => document.querySelector(".usa-combo-box"),
      packages/usa-banner/src/test/banner.spec.js on lines 10..13
      packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
      packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
      packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
      packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
      packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
      packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
      packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
      packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
      packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
      packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
      packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
      packages/usa-footer/src/test/footer.spec.js on lines 36..39
      packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
      packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
      packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
      packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

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

      const tests = [
        { name: "document.body", selector: () => document.body },
        { name: "footer", selector: () => document.querySelector(".usa-footer") },
      ];
      Severity: Major
      Found in packages/usa-footer/src/test/footer.spec.js and 17 other locations - About 45 mins to fix
      packages/usa-banner/src/test/banner.spec.js on lines 10..13
      packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
      packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
      packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
      packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
      packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
      packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
      packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
      packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
      packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
      packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
      packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
      packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
      packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
      packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
      packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
      packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

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

      const tests = [
        { name: "document.body", selector: () => document.body },
        {
          name: "combo box",
          selector: () => document.querySelector(".usa-combo-box"),
      packages/usa-banner/src/test/banner.spec.js on lines 10..13
      packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
      packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
      packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
      packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
      packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
      packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
      packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
      packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
      packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
      packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
      packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
      packages/usa-footer/src/test/footer.spec.js on lines 36..39
      packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
      packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
      packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
      packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

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

      const tests = [
        { name: "document.body", selector: () => document.body },
        {
          name: "combo box",
          selector: () => document.querySelector(".usa-combo-box"),
      Severity: Major
      Found in packages/usa-combo-box/src/test/combo-box-placeholder.spec.js and 17 other locations - About 45 mins to fix
      packages/usa-banner/src/test/banner.spec.js on lines 10..13
      packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
      packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
      packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
      packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
      packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
      packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
      packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
      packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
      packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
      packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
      packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
      packages/usa-footer/src/test/footer.spec.js on lines 36..39
      packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
      packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
      packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
      packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

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

      const tests = [
        { name: "document.body", selector: () => document.body },
        {
          name: "file input",
          selector: () => document.querySelector(".usa-file-input"),
      Severity: Major
      Found in packages/usa-file-input/src/test/file-input-disabled.spec.js and 17 other locations - About 45 mins to fix
      packages/usa-banner/src/test/banner.spec.js on lines 10..13
      packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
      packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
      packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
      packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
      packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
      packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
      packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
      packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
      packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
      packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
      packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
      packages/usa-footer/src/test/footer.spec.js on lines 36..39
      packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
      packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
      packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
      packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

      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

      Avoid deeply nested control flow statements.
      Open

                if (yearStr.length < 3) {
                  const currentYear = today().getFullYear();
                  const currentYearStub =
                    currentYear - (currentYear % 10 ** yearStr.length);
                  year = currentYearStub + parsed;
      Severity: Major
      Found in packages/usa-date-picker/src/index.js - About 45 mins to fix

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

        const tests = [
          { name: "document.body", selector: () => document.body },
          {
            name: "in page nav",
            selector: () => document.querySelector(".usa-in-page-nav"),
        packages/usa-banner/src/test/banner.spec.js on lines 10..13
        packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
        packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
        packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
        packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
        packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
        packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
        packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
        packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
        packages/usa-file-input/src/test/file-input-accepts.spec.js on lines 52..58
        packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
        packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
        packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
        packages/usa-footer/src/test/footer.spec.js on lines 36..39
        packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
        packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
        packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

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

        const tests = [
          { name: "document.body", selector: () => document.body },
          {
            name: "file input",
            selector: () => document.querySelector(".usa-file-input"),
        Severity: Major
        Found in packages/usa-file-input/src/test/file-input-accepts.spec.js and 17 other locations - About 45 mins to fix
        packages/usa-banner/src/test/banner.spec.js on lines 10..13
        packages/usa-character-count/src/test/invalid-template-no-message.spec.js on lines 10..16
        packages/usa-character-count/src/test/invalid-template-no-wrapper.spec.js on lines 10..16
        packages/usa-combo-box/src/test/combo-box-change-event.spec.js on lines 12..18
        packages/usa-combo-box/src/test/combo-box-default-value.spec.js on lines 10..16
        packages/usa-combo-box/src/test/combo-box-disable-filtering.spec.js on lines 11..17
        packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 11..17
        packages/usa-combo-box/src/test/combo-box-placeholder.spec.js on lines 10..16
        packages/usa-combo-box/src/test/combo-box.spec.js on lines 11..17
        packages/usa-file-input/src/test/file-input-disabled.spec.js on lines 9..15
        packages/usa-file-input/src/test/file-input.spec.js on lines 9..15
        packages/usa-file-input/src/test/single-file-input.spec.js on lines 9..15
        packages/usa-footer/src/test/footer.spec.js on lines 36..39
        packages/usa-in-page-navigation/src/test/in-page-navigation-custom-content.spec.js on lines 14..20
        packages/usa-in-page-navigation/src/test/in-page-navigation-custom-heading.spec.js on lines 14..20
        packages/usa-in-page-navigation/src/test/in-page-navigation.spec.js on lines 37..43
        packages/usa-tooltip/src/test/tooltips.spec.js on lines 8..11

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

        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

            const [month, day, year] = dateStringParts.map((str) => {
              let value;
              const parsed = parseInt(str, 10);
              if (!Number.isNaN(parsed)) value = parsed;
              return value;
        Severity: Minor
        Found in packages/usa-date-picker/src/index.js and 1 other location - About 40 mins to fix
        packages/usa-time-picker/src/index.js on lines 34..39

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

        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

            const [hours, mins] = timeStr.split(":").map((str) => {
              let value;
              const parsed = parseInt(str, 10);
              if (!Number.isNaN(parsed)) value = parsed;
              return value;
        Severity: Minor
        Found in packages/usa-time-picker/src/index.js and 1 other location - About 40 mins to fix
        packages/usa-date-picker/src/index.js on lines 757..762

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

        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