department-of-veterans-affairs/vets-website

View on GitHub

Showing 4,231 of 14,884 total issues

Function UNSAFE_componentWillReceiveProps has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  UNSAFE_componentWillReceiveProps(nextProps) {
    // Once the login logic is all done...
    // This will occur even for unauthenticated users and should only occur once.
    if (this.props.user.profile.loading && !nextProps.user.profile.loading) {
      const userProfile = nextProps.user.profile;
Severity: Minor
Found in src/applications/veteran-id-card/containers/VeteranIDCard.jsx - About 1 hr 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 LandingPage has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

const LandingPage = () => {
  const dispatch = useDispatch();
  const fullState = useSelector(state => state);
  const displayNotes = useSelector(selectNotesFlag);
  const displayVaccines = useSelector(selectVaccinesFlag);
Severity: Minor
Found in src/applications/mhv-medical-records/containers/LandingPage.jsx - About 1 hr 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 buildVAPrescriptionPDFList has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export const buildVAPrescriptionPDFList = prescription => {
  const refillHistory = [...(prescription?.rxRfRecords || [])];
  const originalFill = createOriginalFillRecord(prescription);
  refillHistory.push(originalFill);

Severity: Minor
Found in src/applications/mhv-medications/util/pdfConfigs.js - About 1 hr 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 pharmacyPhoneNumber has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export const pharmacyPhoneNumber = prescription => {
  if (!prescription) {
    return null;
  }
  if (prescription.cmopDivisionPhone) {
Severity: Minor
Found in src/applications/mhv-medications/util/helpers.js - About 1 hr 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 PrescriptionDetailsDocumentation has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

const PrescriptionDetailsDocumentation = () => {
  const { prescriptionId } = useParams();
  const contentRef = useRef();
  const {
    prescription,

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 getSubmenu has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  getSubmenu(item, currentSection) {
    if (this.mobileMediaQuery?.matches) {
      const menuSections = [
        item.menuSections.mainColumn,
        item.menuSections.columnOne,
Severity: Minor
Found in src/platform/site-wide/mega-menu/components/MegaMenu.jsx - About 1 hr to fix

    Function createRoutes has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function createRoutes(formConfig) {
      // Validate the config while creating the routes because this is really the
      // entry point for applications to use the forms library.
      // TODO: Tree shake this config validation in prod
      validateConfig(formConfig);
    Severity: Minor
    Found in src/platform/forms-system/src/js/routing.js - About 1 hr to fix

      Function replaceSchema has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              replaceSchema: (formData, _schema, _uiSchema, index, path) => {
                const addressPath = getAddressPath(path); // path is ['address', 'currentField']
                cachedPath = addressPath;
                const data = get(addressPath, formData) ?? {};
                const { country } = data;

        Function prefillTransformer has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function prefillTransformer(pages, formData, metadata, state) {
          const vaProfile = state.user.profile;
        
          // For reference, I _think_ the vapContactInfo has the follow form:
          // const vapContactInfo = {
        Severity: Minor
        Found in src/applications/fry-dea/helpers.jsx - About 1 hr to fix

          Function pactAct has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const pactAct = (state = initialState, action) => {
            switch (action.type) {
              case PAW_UPDATE_SERVICE_PERIOD:
                return updateFormValue(SERVICE_PERIOD, false, state, action);
              case PAW_UPDATE_BURN_PIT_2_1:
          Severity: Minor
          Found in src/applications/pact-act/reducers/index.js - About 1 hr to fix

            Function fetchFormStatus has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const fetchFormStatus = () => async dispatch => {
              dispatch(initiateApiCall());
              const sessionExpiration = localStorage.getItem('sessionExpiration');
              const remainingSessionTime = moment(sessionExpiration).diff(moment());
              if (!remainingSessionTime) {
            Severity: Minor
            Found in src/applications/health-care-supply-reordering/actions/index.js - About 1 hr to fix

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

                render() {
                  return (
                    <div>
                      <va-button onClick={this.openModal} text="Opt Out" />
                      <VaModal
              Severity: Minor
              Found in src/applications/edu-benefits/components/OptOutWizard.jsx - About 1 hr to fix

                Function mailInfo has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const mailInfo = (address, officeName, faxNum, preamble, appType) => {
                  const faxNumMarkup = (
                    <VaTelephone
                      contact={JSON.stringify({
                        phoneNumber: faxNum ?? '3033317809',

                  Function fetchPersonalInfo has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const fetchPersonalInfo = () => {
                    return async (dispatch, getState) => {
                      dispatch({ type: FETCH_PERSONAL_INFO });
                      const {
                        checkClaimant: { claimantId },
                  Severity: Minor
                  Found in src/applications/verify-your-enrollment/actions/index.js - About 1 hr to fix

                    Function YourAppointment has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const YourAppointment = props => {
                      const { avs } = props;
                    
                      return (
                        <div className="avs-accordion-item">
                    Severity: Minor
                    Found in src/applications/avs/components/YourAppointment.jsx - About 1 hr to fix

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

                        render() {
                          const { form } = this.props;
                          const { submission, formId, data } = form;
                          const submitDate = new Date(submission?.timestamp);
                      
                      

                        Function verifyDependents has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function verifyDependents(state = initialState, action) {
                          switch (action.type) {
                            case DEPENDENCY_VERIFICATION_CALL_SUCCESS:
                              return {
                                ...state,

                          Function createRecurringEvents has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const createRecurringEvents = () => {
                            const recurEventData = { id: 'upcoming' };
                            const eventA = createEvent(
                              now
                                .clone()
                          Severity: Minor
                          Found in src/applications/static-pages/events/helpers/event-generator.js - About 1 hr to fix

                            Function FinancialConfirmation has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const FinancialConfirmation = props => {
                              const { goBack, goForward } = props;
                            
                              return (
                                <va-alert
                            Severity: Minor
                            Found in src/applications/hca/components/FormPages/FinancialConfirmation.jsx - About 1 hr to fix

                              Function MFA has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const MFA = () => {
                                const verifyLink = useCallback(async policy => {
                                  await verify({ policy, isLink: true, isSignup: false });
                                }, []);
                              
                              
                                Severity
                                Category
                                Status
                                Source
                                Language