Showing 4,177 of 14,709 total issues
Function PrintDownload
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
Open
const PrintDownload = props => {
const { onDownload, isSuccess, list, onPrint, onText, isLoading } = props;
const [isError, setIsError] = useState(false);
const [menuOpen, setMenuOpen] = useState(false);
- 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 render
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { uiSchema, errorSchema, idSchema, schema, formContext } = this.props;
const { SchemaField } = this.props.registry.fields || {};
const properties = Object.keys(schema.properties);
Function TravelPayAlert
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const TravelPayAlert = props => {
const {
travelPayEligible,
travelPayClaimRequested,
travelPayClaimError,
Function transformForSubmit
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function transformForSubmit(formConfig, form) {
const transformedData = JSON.parse(
sharedTransformForSubmit(formConfig, form),
);
const { preparerType, otherReasons } = transformedData;
Function generateFoodJournalContent
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const generateFoodJournalContent = record => {
const content = {
title: record.date,
details: [
{
File form.js
has 349 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// this form does NOT use JSON schema for its data model
import environment from '@department-of-veterans-affairs/platform-utilities/environment';
import footerContent from 'platform/forms/components/FormFooter';
import { externalServices } from 'platform/monitoring/DowntimeNotification';
File form.js
has 349 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import commonDefinitions from 'vets-json-schema/dist/definitions.json';
import environment from '@department-of-veterans-affairs/platform-utilities/environment';
// import profileContactInfo from 'platform/forms-system/src/js/definitions/profileContactInfo';
import configService from '../utilities/configService';
import manifest from '../manifest.json';
Function RequiredLoginView
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const RequiredLoginView = props => {
const { user, verify, useSiS, showProfileErrorMessage = false } = props;
const shouldSignIn = useCallback(() => !user.login.currentlyLoggedIn, [
user.login.currentlyLoggedIn,
Function render
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { route } = this.props;
const { formConfig, pageList } = route;
return (
Function UpcomingAppointmentsList
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function UpcomingAppointmentsList() {
const history = useHistory();
const dispatch = useDispatch();
const {
showScheduleButton,
Function getUiSchema
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const getUiSchema = () => {
return {
'view:livesOnMilitaryBase': {
'ui:title': 'I live on a United States military base outside of the U.S.',
'ui:webComponentField': VaCheckboxField,
File index.jsx
has 348 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import React, { useEffect } from 'react';
import { connect, useDispatch, useSelector } from 'react-redux';
import { useHistory } from 'react-router-dom';
import SchemaForm from '@department-of-veterans-affairs/platform-forms-system/SchemaForm';
import { usePrevious } from '@department-of-veterans-affairs/platform-utilities/exports';
Consider simplifying this complex logical expression. Open
Open
if (isDataFetched) {
return {
labsAndTests:
labsAndTests && recordFilter?.includes('labTests')
? labsAndTests.filter(rec => filterByDate(rec.sortDate))
File IntroductionPage.jsx
has 347 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { CONTACTS } from '@department-of-veterans-affairs/component-library/contacts';
Function render
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { form } = this.props;
const { submission, data } = form;
const submitDate = new Date(submission?.timestamp);
Function prefillTransformer
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function prefillTransformer(pages, formData, metadata, state) {
const bankInformation = state.data?.bankInformation || {};
const claimant = state.data?.formData?.data?.attributes?.claimant || {};
const contactInfo = claimant?.contactInfo || {};
const stateUser = state.user;
Function TopicSelectPage
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const TopicSelectPage = props => {
const {
onChange,
loggedIn,
goBack,
Function CategorySelectPage
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const CategorySelectPage = props => {
const { onChange, isLoggedIn, goToPath, formData, goBack, router } = props;
const dispatch = useDispatch();
const [apiData, setApiData] = useState([]);
Function render
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { submission, data } = this.props.form;
const { isLoggedIn, fullName } = this.props;
const { response } = submission;
const name = isLoggedIn ? fullName : data.veteranInformation.fullName;
Function useClinicFormState
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function useClinicFormState(pageTitle) {
const initialData = useSelector(getFormData);
const location = useSelector(selectChosenFacilityInfo);
const selectedTypeOfCare = getTypeOfCare(initialData);