Showing 67 of 368 total issues
Function compileJS
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
compileJS() {
dutil.logMessage("javascript", "Compiling JavaScript");
let packageName = dutil.pkg.name.replace("@uswds/", "");
const streams = Object.entries({
[packageName]: browserify({
Consider simplifying this complex logical expression. Open
} else if (
(!isCharsetPresent && !isInt && matchesNumber) ||
(isCharsetPresent &&
((matchesLetter && !isLet) || (matchesNumber && !isInt)))
) {
Function handleCurrentValue
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleCurrentValue = (el) => {
const isCharsetPresent = el.dataset.charset;
const placeholder = isCharsetPresent || el.dataset.placeholder;
const { value } = el;
const len = placeholder.length;
Function exports
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (context, additionalKeyBindings = {}) => {
const tabEventHandler = tabHandler(context);
const bindings = additionalKeyBindings;
const { Esc, Escape } = bindings;
Function toggleHtmlTag
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function toggleHtmlTag(isMobile) {
const bigFooter = document.querySelector(SCOPE);
if (!bigFooter) {
return;
Function setUpAttributes
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const setUpAttributes = (tooltipTrigger) => {
const tooltipID = `tooltip-${Math.floor(Math.random() * 900000) + 100000}`;
const tooltipContent = tooltipTrigger.getAttribute("title");
const wrapper = document.createElement("span");
const tooltipBody = document.createElement("span");
Function init
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
init(root) {
selectOrMatches(DROPZONE, root).forEach((fileInputEl) => {
const { instructions, dropTarget } = enhanceFileInput(fileInputEl);
dropTarget.addEventListener(
Function months
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const months = MONTH_LABELS.map((month, index) => {
const monthToCheck = setMonth(calendarDate, index);
const isDisabled = isDatesMonthOutsideMinOrMax(
monthToCheck,
Function embed
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function embed(parent, svg, target, use) {
// if the target exists
if (target) {
// create a document fragment to hold the contents of the target
var fragment = document.createDocumentFragment(),
Function getComboBoxContext
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getComboBoxContext = (el) => {
const comboBoxEl = el.closest(COMBO_BOX);
if (!comboBoxEl) {
throw new Error(`Element is missing outer ${COMBO_BOX}`);
Function enhanceDateRangePicker
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const enhanceDateRangePicker = (el) => {
const dateRangePickerEl = el.closest(DATE_RANGE_PICKER);
const [rangeStart, rangeEnd] = select(DATE_PICKER, dateRangePickerEl);
Function compileSass
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
compileSass() {
dutil.logMessage("sass", "Compiling Sass");
const pluginsProcess = [discardComments(), autoprefixer()];
const pluginsMinify = [csso({ forceMediaMerge: false })];
Function isDateInputInvalid
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const isDateInputInvalid = (el) => {
const { externalInputEl, minDate, maxDate } = getDatePickerContext(el);
const dateString = externalInputEl.value;
let isInvalid = false;
Function displayMonthSelection
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const displayMonthSelection = (el, monthToDisplay) => {
const { calendarEl, statusEl, calendarDate, minDate, maxDate } =
getDatePickerContext(el);
const selectedMonth = calendarDate.getMonth();
- Read upRead up
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 enhanceDatePicker
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const enhanceDatePicker = (el) => {
const datePickerEl = el.closest(DATE_PICKER);
const { defaultValue } = datePickerEl.dataset;
const internalInputEl = datePickerEl.querySelector(`input`);
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if (allFilesAllowed) {
TYPE_IS_VALID = true;
break;
}
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 ||
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;
Function compareFunction
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const compareFunction = (index, isAscending) => (thisRow, nextRow) => {
// get values to compare from data attribute or cell content
const value1 = getCellValue(isAscending ? thisRow : nextRow, index);
const value2 = getCellValue(isAscending ? nextRow : thisRow, index);
- Read upRead up
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 exports
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
module.exports = (context, additionalKeyBindings = {}) => {
const tabEventHandler = tabHandler(context);
const bindings = additionalKeyBindings;
const { Esc, Escape } = bindings;
- Read upRead up
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"