department-of-veterans-affairs/vets-website

View on GitHub

Showing 4,177 of 14,709 total issues

Function PrintDownload has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

const PrintDownload = props => {
  const { onDownload, isSuccess, list, onPrint, onText, isLoading } = props;
  const [isError, setIsError] = useState(false);

  const [menuOpen, setMenuOpen] = useState(false);
Severity: Minor
Found in src/applications/mhv-medications/components/shared/PrintDownload.jsx - 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 render has 110 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const { uiSchema, errorSchema, idSchema, schema, formContext } = this.props;
    const { SchemaField } = this.props.registry.fields || {};

    const properties = Object.keys(schema.properties);
Severity: Major
Found in src/platform/forms-system/src/js/review/ObjectField.jsx - About 4 hrs to fix

    Function TravelPayAlert has 110 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const TravelPayAlert = props => {
      const {
        travelPayEligible,
        travelPayClaimRequested,
        travelPayClaimError,

      Function transformForSubmit has 110 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function transformForSubmit(formConfig, form) {
        const transformedData = JSON.parse(
          sharedTransformForSubmit(formConfig, form),
        );
        const { preparerType, otherReasons } = transformedData;
      Severity: Major
      Found in src/applications/simple-forms/20-10207/config/submit-transformer.js - About 4 hrs to fix

        Function generateFoodJournalContent has 110 lines of code (exceeds 25 allowed). Consider refactoring.
        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

          // 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';
          
          
          Severity: Minor
          Found in src/applications/simple-forms/21-0845/config/form.js - About 4 hrs to fix

            File form.js has 349 lines of code (exceeds 250 allowed). Consider refactoring.
            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';
            Severity: Minor
            Found in src/applications/representative-appoint/config/form.js - About 4 hrs to fix

              Function RequiredLoginView has 109 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const RequiredLoginView = props => {
                const { user, verify, useSiS, showProfileErrorMessage = false } = props;
              
                const shouldSignIn = useCallback(() => !user.login.currentlyLoggedIn, [
                  user.login.currentlyLoggedIn,
              Severity: Major
              Found in src/platform/user/authorization/components/RequiredLoginView.jsx - About 4 hrs to fix

                Function render has 109 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  render() {
                    const { route } = this.props;
                    const { formConfig, pageList } = route;
                
                    return (

                  Function UpcomingAppointmentsList has 109 lines of code (exceeds 25 allowed). Consider refactoring.
                  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

                    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

                      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

                              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

                          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

                              render() {
                                const { form } = this.props;
                                const { submission, data } = form;
                                const submitDate = new Date(submission?.timestamp);
                            
                            
                            Severity: Major
                            Found in src/applications/ivc-champva/10-7959a/containers/ConfirmationPage.jsx - About 4 hrs to fix

                              Function prefillTransformer has 108 lines of code (exceeds 25 allowed). Consider refactoring.
                              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

                                const TopicSelectPage = props => {
                                  const {
                                    onChange,
                                    loggedIn,
                                    goBack,
                                Severity: Major
                                Found in src/applications/ask-va/containers/TopicSelectPage.jsx - About 4 hrs to fix

                                  Function CategorySelectPage has 108 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  const CategorySelectPage = props => {
                                    const { onChange, isLoggedIn, goToPath, formData, goBack, router } = props;
                                    const dispatch = useDispatch();
                                  
                                    const [apiData, setApiData] = useState([]);
                                  Severity: Major
                                  Found in src/applications/ask-va/containers/CategorySelectPage.jsx - About 4 hrs to fix

                                    Function render has 108 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      render() {
                                        const { submission, data } = this.props.form;
                                        const { isLoggedIn, fullName } = this.props;
                                        const { response } = submission;
                                        const name = isLoggedIn ? fullName : data.veteranInformation.fullName;
                                    Severity: Major
                                    Found in src/applications/vre/28-1900/containers/ConfirmationPage.jsx - About 4 hrs to fix

                                      Function useClinicFormState has 108 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                      export default function useClinicFormState(pageTitle) {
                                        const initialData = useSelector(getFormData);
                                        const location = useSelector(selectChosenFacilityInfo);
                                      
                                        const selectedTypeOfCare = getTypeOfCare(initialData);
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language