department-of-veterans-affairs/vets-website

View on GitHub

Showing 12,835 of 12,835 total issues

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

export const SelectCategories = [
  {
    value: 'general',
    label: 'General',
  },
Severity: Major
Found in src/applications/mhv-secure-messaging/util/inputContants.js and 1 other location - About 2 hrs to fix
src/platform/static-data/options-for-select.js on lines 25..32

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

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 DashboardCardsMock.jsx has 266 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  VaPagination,
  VaSelect,
} from '@department-of-veterans-affairs/component-library/dist/react-bindings';
import { focusElement } from '@department-of-veterans-affairs/platform-utilities/ui';
Severity: Minor
Found in src/applications/ask-va/containers/DashboardCardsMock.jsx - About 2 hrs to fix

    File CreditCardBill.jsx has 266 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { useState } from 'react';
    import PropTypes from 'prop-types';
    import { connect } from 'react-redux';
    import { setData } from 'platform/forms-system/src/js/actions';
    import { isValidCurrency } from '../../utils/validations';

      Function getBoardExplanation has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const getBoardExplanation = formResponses => {
        const reason = formResponses[SHORT_NAME_MAP.REASON];
        const noPrevApp =
          formResponses[SHORT_NAME_MAP.PREV_APPLICATION] === RESPONSES.NO;
        const prevAppType = formResponses[SHORT_NAME_MAP.PREV_APPLICATION_TYPE];
      Severity: Major
      Found in src/applications/discharge-wizard/helpers/index.jsx - About 2 hrs to fix

        Function BenefitSelectionWarning has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function BenefitSelectionWarning(chapter, relationship) {
          let warningText = '';
          if (chapter === 'chapter33') {
            // Fry
            if (relationship === 'child') {

          Function CustomAttestation has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function CustomAttestation(signatureProps) {
            const { formData } = signatureProps;
            const isBeneficiary = get('certifierRole', formData) === 'applicant';
          
            const pp = (

            Function IntroductionPage has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const IntroductionPage = props => {
              const { route } = props;
              const { formConfig, pageList } = route;
            
              return (

              Function IsUserLoggedIn has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const IsUserLoggedIn = () => {
                const user = useSelector(selectUser);
                const isUserLOA1 = useSelector(isLOA1);
                const response = useSelector(state => state.personalInfo);
                const { useToggleValue, TOGGLE_NAMES } = useFeatureToggle();
              Severity: Major
              Found in src/applications/verify-your-enrollment/routes.jsx - About 2 hrs to fix

                File TermsOfUse.jsx has 265 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import React, { useState, useEffect } from 'react';
                import { useSelector } from 'react-redux';
                import { apiRequest } from '@department-of-veterans-affairs/platform-utilities/exports';
                import { VaModal } from '@department-of-veterans-affairs/component-library/dist/react-bindings';
                import {
                Severity: Minor
                Found in src/applications/terms-of-use/containers/TermsOfUse.jsx - About 2 hrs to fix

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

                    render() {
                      const { form } = this.props;
                      const { submission, /* formId, */ data } = form;
                      const submitDate = submission.timestamp;
                      const confirmationNumber = submission.response?.confirmationNumber;

                    Function content has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        () => {
                          if (isLoading || awaitingResults) {
                            return <LoadingIndicator />;
                          }
                    
                    

                      Function selectRequestedAppointmentData has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function selectRequestedAppointmentData(state, appointment) {
                        const featureVAOSServiceCCAppointments = selectFeatureVAOSServiceCCAppointments(
                          state,
                        );
                        const { facilityData } = state?.appointments || [];
                      Severity: Major
                      Found in src/applications/vaos/appointment-list/redux/selectors.js - About 2 hrs to fix

                        Function DeleteDraftModal has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const DeleteDraftModal = props => {
                          const { unsavedDraft, draftSequence } = props;
                          return (
                            <VaModal
                              id={`delete-draft-modal${draftSequence ? `-${draftSequence}` : ''}`}

                          Function routeToPageInFlow has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function routeToPageInFlow(callback, history, current, action, data) {
                            return async (dispatch, getState) => {
                              const flow = callback(getState());
                          
                              dispatch({
                          Severity: Major
                          Found in src/applications/vaos/new-appointment/redux/actions.js - About 2 hrs to fix

                            Function LandingPageContainer has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const LandingPageContainer = () => {
                              const { featureToggles, user } = useSelector(state => state);
                              const [unreadMessageCount, setUnreadMessageCount] = useState();
                              const profile = useSelector(selectProfile);
                              const ssoe = useSelector(isAuthenticatedWithSSOe);
                            Severity: Major
                            Found in src/applications/mhv-landing-page/containers/LandingPageContainer.jsx - About 2 hrs to fix

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

                                render() {
                                  const { logo, title, grants } = this.props.attributes;
                              
                                  return (
                                    <div

                                Function useHighlightedClaimOrAppeal has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const useHighlightedClaimOrAppeal = (appealsData, claimsData) => {
                                  // the appeals data sorted with the most recently updated appeal first
                                  const sortedAppeals = React.useMemo(
                                    () => {
                                      // Array sorting is done in place. Sorting `appealsData` directly was

                                  Function fetchNotifications has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export const fetchNotifications = () => async dispatch => {
                                    const getNotifications = () => {
                                      const options = {
                                        method: 'GET',
                                        credentials: 'include',
                                  Severity: Major
                                  Found in src/applications/personalization/common/actions/notifications.js - About 2 hrs to fix

                                    Function content has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      const content = () => {
                                        if (labAndTestDetails) {
                                          return (
                                            <>
                                              <PrintHeader />

                                      File PrescriptionPrintOnly.jsx has 265 lines of code (exceeds 250 allowed). Consider refactoring.
                                      Open

                                      import React from 'react';
                                      import PropTypes from 'prop-types';
                                      import {
                                        pdfStatusDefinitions,
                                        pdfDefaultStatusDefinition,
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language