18F/web-design-standards

View on GitHub

Showing 67 of 368 total issues

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");

        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

          Function renderCalendar has 208 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const renderCalendar = (el, _dateToDisplay) => {
            const {
              datePickerEl,
              calendarEl,
              statusEl,
          Severity: Major
          Found in packages/usa-date-picker/src/index.js - About 1 day to fix

            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

              Function showToolTip has 154 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const showToolTip = (tooltipBody, tooltipTrigger, position) => {
                tooltipBody.setAttribute("aria-hidden", "false");
              
                // This sets up the tooltip body. The opacity is 0, but
                // we can begin running the calculations below.
              Severity: Major
              Found in packages/usa-tooltip/src/index.js - About 6 hrs to fix

                Function renderCalendar has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
                Open

                const renderCalendar = (el, _dateToDisplay) => {
                  const {
                    datePickerEl,
                    calendarEl,
                    statusEl,
                Severity: Minor
                Found in packages/usa-date-picker/src/index.js - About 6 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function parseDateString has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                Open

                const parseDateString = (
                  dateString,
                  dateFormat = INTERNAL_DATE_FORMAT,
                  adjustDate = false
                ) => {
                Severity: Minor
                Found in packages/usa-date-picker/src/index.js - About 5 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

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

                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: Minor
                Found in packages/usa-file-input/src/index.js - About 4 hrs to fix

                  Function displayYearSelection has 115 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const displayYearSelection = (el, yearToDisplay) => {
                    const { calendarEl, statusEl, calendarDate, minDate, maxDate } =
                      getDatePickerContext(el);
                  
                    const selectedYear = calendarDate.getFullYear();
                  Severity: Major
                  Found in packages/usa-date-picker/src/index.js - About 4 hrs to fix

                    Function toggleModal has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function toggleModal(event) {
                      let originalOpener;
                      let clickedElement = event.target;
                      const { body } = document;
                      const safeActive = !isActive();
                    Severity: Minor
                    Found in packages/usa-modal/src/index.js - About 4 hrs to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Function enhanceComboBox has 105 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const enhanceComboBox = (_comboBoxEl) => {
                      const comboBoxEl = _comboBoxEl.closest(COMBO_BOX);
                    
                      if (comboBoxEl.dataset.enhanced) return;
                    
                    
                    Severity: Major
                    Found in packages/usa-combo-box/src/index.js - About 4 hrs to fix

                      Function showToolTip has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const showToolTip = (tooltipBody, tooltipTrigger, position) => {
                        tooltipBody.setAttribute("aria-hidden", "false");
                      
                        // This sets up the tooltip body. The opacity is 0, but
                        // we can begin running the calculations below.
                      Severity: Minor
                      Found in packages/usa-tooltip/src/index.js - About 4 hrs to fix

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Function displayList has 90 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const displayList = (el) => {
                        const {
                          comboBoxEl,
                          selectEl,
                          inputEl,
                      Severity: Major
                      Found in packages/usa-combo-box/src/index.js - About 3 hrs to fix

                        Function displayList has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                        Open

                        const displayList = (el) => {
                          const {
                            comboBoxEl,
                            selectEl,
                            inputEl,
                        Severity: Minor
                        Found in packages/usa-combo-box/src/index.js - About 3 hrs to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function toggleModal has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function toggleModal(event) {
                          let originalOpener;
                          let clickedElement = event.target;
                          const { body } = document;
                          const safeActive = !isActive();
                        Severity: Major
                        Found in packages/usa-modal/src/index.js - About 3 hrs to fix

                          Function svg4everybody has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            function svg4everybody(rawopts) {
                              function oninterval() {
                                // if all <use>s in the array are being bypassed, don't proceed.
                                if (
                                  numberOfSvgUseElementsToBypass &&
                          Severity: Major
                          Found in packages/uswds-core/src/js/polyfills/svg4everybody.js - About 2 hrs to fix

                            Function generateDateHtml has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              const generateDateHtml = (dateToRender) => {
                                const classes = [CALENDAR_DATE_CLASS];
                                const day = dateToRender.getDate();
                                const month = dateToRender.getMonth();
                                const year = dateToRender.getFullYear();
                            Severity: Major
                            Found in packages/usa-date-picker/src/index.js - About 2 hrs to fix

                              Function handleChange has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const handleChange = (e, fileInputEl, instructions, dropTarget) => {
                                const fileNames = e.target.files;
                                const inputParent = dropTarget.closest(`.${DROPZONE_CLASS}`);
                                const statusElement = inputParent.querySelector(`.${SR_ONLY_CLASS}`);
                                const fileStore = [];
                              Severity: Major
                              Found in packages/usa-file-input/src/index.js - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language