18F/web-design-standards

View on GitHub

Showing 368 of 368 total issues

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

tests.forEach(({ name, selector: containerSelector }) => {
  describe(`date picker component year selection initialized at ${name}`, () => {
    const { body } = document;

    let root;
packages/usa-date-picker/src/test/date-picker-month-selection.spec.js on lines 17..172

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

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

tests.forEach(({ name, selector: containerSelector }) => {
  describe(`date picker component month selection initialized at ${name}`, () => {
    const { body } = document;

    let root;
packages/usa-date-picker/src/test/date-picker-year-selection.spec.js on lines 17..170

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

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

File index.js has 1372 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const keymap = require("receptor/keymap");
const behavior = require("../../uswds-core/src/js/utils/behavior");
const select = require("../../uswds-core/src/js/utils/select");
const selectOrMatches = require("../../uswds-core/src/js/utils/select-or-matches");
const { prefix: PREFIX } = require("../../uswds-core/src/js/config");
Severity: Major
Found in packages/usa-date-picker/src/index.js - About 3 days to fix

    File date-picker.spec.js has 1001 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const fs = require("fs");
    const path = require("path");
    const assert = require("assert");
    const DatePicker = require("../index");
    const EVENTS = require("./events");
    Severity: Major
    Found in packages/usa-date-picker/src/test/date-picker.spec.js - About 2 days to fix

      File date-picker-min-date-max-date.spec.js has 856 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      const fs = require("fs");
      const path = require("path");
      const assert = require("assert");
      const EVENTS = require("./events");
      const DatePicker = require("../index");

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

        tests.forEach(({ name, selector: containerSelector }) => {
          describe(`Range slider with updated preposition initialized at ${name}`, () => {
            describe("range slider component", () => {
              const { body } = document;
        
        
        packages/usa-range/src/test/sr-callout.spec.js on lines 27..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 288.

        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

        tests.forEach(({ name, selector: containerSelector }) => {
          describe(`Range slider with aria-valuetext initialized at ${name}`, () => {
            describe("range slider component", () => {
              const { body } = document;
        
        
        Severity: Major
        Found in packages/usa-range/src/test/sr-callout.spec.js and 1 other location - About 1 day to fix
        packages/usa-range/src/test/sr-callout-with-preposition.spec.js on lines 27..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 288.

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

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

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

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

        Refactorings

        Further Reading

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

        tests.forEach(({ name, selector: containerSelector }) => {
          describe(`input mask component initialized at ${name}`, () => {
            const { body } = document;
        
            let root;
        Severity: Major
        Found in packages/usa-input-mask/src/test/input-mask.spec.js and 3 other locations - About 1 day to fix
        packages/usa-input-mask/src/test/input-mask-alphanumeric.spec.js on lines 26..55
        packages/usa-input-mask/src/test/input-mask-phone.spec.js on lines 26..55
        packages/usa-input-mask/src/test/input-mask-zip-code.spec.js on lines 26..55

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

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

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

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

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

        Refactorings

        Further Reading

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

        tests.forEach(({ name, selector: containerSelector }) => {
          describe(`input mask component initialized at ${name}`, () => {
            const { body } = document;
        
            let root;
        packages/usa-input-mask/src/test/input-mask-alphanumeric.spec.js on lines 26..55
        packages/usa-input-mask/src/test/input-mask-phone.spec.js on lines 26..55
        packages/usa-input-mask/src/test/input-mask.spec.js on lines 26..55

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

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

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

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

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

        Refactorings

        Further Reading

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

        tests.forEach(({ name, selector: containerSelector }) => {
          describe(`input mask component initialized at ${name}`, () => {
            const { body } = document;
        
            let root;
        packages/usa-input-mask/src/test/input-mask-phone.spec.js on lines 26..55
        packages/usa-input-mask/src/test/input-mask-zip-code.spec.js on lines 26..55
        packages/usa-input-mask/src/test/input-mask.spec.js on lines 26..55

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

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

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

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

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

        Refactorings

        Further Reading

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

        tests.forEach(({ name, selector: containerSelector }) => {
          describe(`input mask component initialized at ${name}`, () => {
            const { body } = document;
        
            let root;
        Severity: Major
        Found in packages/usa-input-mask/src/test/input-mask-phone.spec.js and 3 other locations - About 1 day to fix
        packages/usa-input-mask/src/test/input-mask-alphanumeric.spec.js on lines 26..55
        packages/usa-input-mask/src/test/input-mask-zip-code.spec.js on lines 26..55
        packages/usa-input-mask/src/test/input-mask.spec.js on lines 26..55

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

        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

        File index.js has 563 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        const keymap = require("receptor/keymap");
        const selectOrMatches = require("../../uswds-core/src/js/utils/select-or-matches");
        const behavior = require("../../uswds-core/src/js/utils/behavior");
        const Sanitizer = require("../../uswds-core/src/js/utils/sanitizer");
        const { prefix: PREFIX } = require("../../uswds-core/src/js/config");
        Severity: Major
        Found in packages/usa-combo-box/src/index.js - About 1 day to fix

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

            describe("behavior.off()", () => {
              it("calls teardown()", () => {
                const teardown = sinon.spy();
                behavior({}, { teardown }).off();
                assert(teardown.calledOnce);
          Severity: Major
          Found in packages/uswds-core/src/js/utils/test/behavior.spec.js and 1 other location - About 1 day to fix
          packages/uswds-core/src/js/utils/test/behavior.spec.js on lines 17..36

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

          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

            describe("behavior.on()", () => {
              it("calls init()", () => {
                const init = sinon.spy();
                behavior({}, { init }).on();
                assert(init.calledOnce);
          Severity: Major
          Found in packages/uswds-core/src/js/utils/test/behavior.spec.js and 1 other location - About 1 day to fix
          packages/uswds-core/src/js/utils/test/behavior.spec.js on lines 38..57

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

          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

              describe("validation state", () => {
                it(`adds .${CHECKED_CLASS} for all successful validations`, () => {
                  validated.value = "This is one great comment!";
                  keyup(validated);
                  validators.forEach((checkbox) => {
          Severity: Major
          Found in packages/usa-validation/src/test/validator-textarea.spec.js and 1 other location - About 1 day to fix
          packages/usa-validation/src/test/validator.spec.js on lines 55..76

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

          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

              describe("validation state", () => {
                it(`adds .${CHECKED_CLASS} for all successful validations`, () => {
                  validated.value = "GreatPassword1";
                  keyup(validated);
                  validators.forEach((checkbox) => {
          Severity: Major
          Found in packages/usa-validation/src/test/validator.spec.js and 1 other location - About 1 day to fix
          packages/usa-validation/src/test/validator-textarea.spec.js on lines 58..79

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

          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

          const displayNextYearChunk = (el) => {
            if (el.disabled) return;
          
            const { calendarEl, calendarDate, minDate, maxDate } =
              getDatePickerContext(el);
          Severity: Major
          Found in packages/usa-date-picker/src/index.js and 1 other location - About 1 day to fix
          packages/usa-date-picker/src/index.js on lines 1604..1627

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

          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

          const displayPreviousYearChunk = (el) => {
            if (el.disabled) return;
          
            const { calendarEl, calendarDate, minDate, maxDate } =
              getDatePickerContext(el);
          Severity: Major
          Found in packages/usa-date-picker/src/index.js and 1 other location - About 1 day to fix
          packages/usa-date-picker/src/index.js on lines 1634..1657

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

          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

          const handleRangeEndUpdate = (el) => {
            const { dateRangePickerEl, rangeStartEl, rangeEndEl } =
              getDateRangePickerContext(el);
            const { internalInputEl } = getDatePickerContext(rangeEndEl);
            const updatedDate = internalInputEl.value;
          Severity: Major
          Found in packages/usa-date-range-picker/src/index.js and 1 other location - About 1 day to fix
          packages/usa-date-range-picker/src/index.js on lines 64..81

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

          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

          const handleRangeStartUpdate = (el) => {
            const { dateRangePickerEl, rangeStartEl, rangeEndEl } =
              getDateRangePickerContext(el);
            const { internalInputEl } = getDatePickerContext(rangeStartEl);
            const updatedDate = internalInputEl.value;
          Severity: Major
          Found in packages/usa-date-range-picker/src/index.js and 1 other location - About 1 day to fix
          packages/usa-date-range-picker/src/index.js on lines 88..105

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

          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