18F/web-design-standards

View on GitHub
packages/usa-combo-box/src/test/combo-box.spec.js

Summary

Maintainability
F
5 days
Test Coverage

File combo-box.spec.js has 485 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const fs = require("fs");
const path = require("path");
const assert = require("assert");
const ComboBox = require("../index");
const EVENTS = require("./events");
Severity: Minor
Found in packages/usa-combo-box/src/test/combo-box.spec.js - About 7 hrs to fix

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

          it("should select the focused list item in the list when pressing enter on a focused item", () => {
            select.value = "pineapple";
            input.value = "berry";
            EVENTS.input(input);
            EVENTS.keydownArrowDown(input);
    Severity: Major
    Found in packages/usa-combo-box/src/test/combo-box.spec.js and 1 other location - About 4 hrs to fix
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 411..435

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

    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

          it("should select the focused list item in the list when pressing space on a focused item", () => {
            select.value = "cantaloupe";
            input.value = "berry";
            EVENTS.input(input);
            EVENTS.keydownArrowDown(input);
    Severity: Major
    Found in packages/usa-combo-box/src/test/combo-box.spec.js and 1 other location - About 4 hrs to fix
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 385..409

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

    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

          it("should close the list and reset input value when escape is performed while the list is open", () => {
            select.value = "cherry";
            input.value = "a";
    
            EVENTS.input(input);
    Severity: Major
    Found in packages/usa-combo-box/src/test/combo-box.spec.js and 1 other location - About 4 hrs to fix
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 301..320

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

    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

          it("should set the input value when a complete selection is submitted by pressing enter", () => {
            select.value = "cranberry";
            input.value = "grape";
    
            EVENTS.input(input);
    Severity: Major
    Found in packages/usa-combo-box/src/test/combo-box.spec.js and 1 other location - About 4 hrs to fix
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 267..286

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

    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

          it("should reset input values when an incomplete item is remaining on blur", () => {
            select.value = "apricot";
            input.value = "a";
            EVENTS.input(input);
            assert.ok(!list.hidden, "should display the option list");
    Severity: Major
    Found in packages/usa-combo-box/src/test/combo-box.spec.js and 1 other location - About 4 hrs to fix
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 288..299

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

    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

          it("should reset the input value when a complete selection is left on blur from the input element", () => {
            select.value = "coconut";
            input.value = "date";
            EVENTS.input(input);
            assert.ok(!list.hidden, "should display the option list");
    Severity: Major
    Found in packages/usa-combo-box/src/test/combo-box.spec.js and 1 other location - About 4 hrs to fix
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 223..234

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

    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

          it("should display and filter the option list after a character is typed", () => {
            input.value = "a";
    
            EVENTS.input(input);
    
    
    Severity: Major
    Found in packages/usa-combo-box/src/test/combo-box.spec.js and 1 other location - About 1 hr to fix
    packages/usa-combo-box/src/test/combo-box-filter.spec.js on lines 41..52

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

    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

            Array.from(list.children).forEach((listItem) => {
              Array.from(listItem.childNodes).forEach((childNode) => {
                assert.strictEqual(childNode.nodeType, Node.TEXT_NODE);
              });
            });
    Severity: Minor
    Found in packages/usa-combo-box/src/test/combo-box.spec.js and 1 other location - About 55 mins to fix
    packages/usa-character-count/src/test/character-count.spec.js on lines 148..152

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

    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

          it("should close the list by clicking away", () => {
            EVENTS.click(input);
            EVENTS.focusout(input);
    
            assert.ok(list.hidden, "should hide the option list");
    Severity: Minor
    Found in packages/usa-combo-box/src/test/combo-box.spec.js and 1 other location - About 50 mins to fix
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 137..142

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 51.

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

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

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

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

    Refactorings

    Further Reading

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

          it("should toggle the list and close by clicking when clicking the toggle button twice", () => {
            EVENTS.click(toggle);
            EVENTS.click(toggle);
    
            assert.ok(list.hidden, "should hide the option list");
    Severity: Minor
    Found in packages/usa-combo-box/src/test/combo-box.spec.js and 1 other location - About 50 mins to fix
    packages/usa-combo-box/src/test/combo-box.spec.js on lines 184..189

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 51.

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

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

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

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

    Refactorings

    Further Reading

    Similar blocks of code found in 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

    There are no issues that match your filters.

    Category
    Status