department-of-veterans-affairs/vets-website

View on GitHub

Showing 12,841 of 12,841 total issues

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

export default {
  uiSchema: {
    ...titleUI(({ formData }) => getPhoneAndEmailPageTitle(formData)),
    nonVeteranPhone: phoneUI('Phone number'),
    nonVeteranEmailAddress: emailUI(),
src/applications/simple-forms/20-10207/pages/veteranPhoneAndEmail.js on lines 11..24

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

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 index.js has 254 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const all = {
  id: '868a0f70-f920-4483-9be4-fa64f65d2e85',
  meta: {
    lastUpdated: '2023-07-21T12:22:25.721-04:00',
  },
Severity: Minor
Found in src/platform/mhv/api/mocks/medical-records/vaccines/index.js - About 2 hrs to fix

    File ResponseInboxPageMock.jsx has 254 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {
      VaAlert,
      VaButton,
      VaFileInputMultiple,
      VaIcon,
    Severity: Minor
    Found in src/applications/ask-va/containers/ResponseInboxPageMock.jsx - About 2 hrs to fix

      Function waitForRenderThenFocus has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export function waitForRenderThenFocus(
        selector,
        root = document,
        timeInterval = defaultTime,
        // added because we first need to wait for a component to be rendered, then we
      Severity: Minor
      Found in src/platform/utilities/ui/focus.js - About 2 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 ProfileInformationView has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      const ProfileInformationView = props => {
        const { data, fieldName, title, id } = props;
      
        const titleLower = title.toLowerCase();
      
      

      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 componentDidUpdate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        componentDidUpdate(prevProps) {
          const {
            fieldName,
            forceEditView,
            successCallback,

      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 InformalConference has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export const InformalConference = ({
        data,
        goBack,
        goForward,
        onReviewPage,
      Severity: Minor
      Found in src/applications/appeals/996/components/InformalConference.jsx - About 2 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 ReviewPage has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      const ReviewPage = ({
        dependentsInput,
        editMode,
        pastMode,
        router,
      Severity: Minor
      Found in src/applications/income-limits/containers/ReviewPage.jsx - About 2 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 getBoardExplanation has a Cognitive Complexity of 16 (exceeds 5 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: Minor
      Found in src/applications/discharge-wizard/helpers/index.jsx - About 2 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 componentDidUpdate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        componentDidUpdate(prevProps) {
          const {
            fieldName,
            forceEditView,
            successCallback,

      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 useFormRouting has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      const useFormRouting = (router = {}) => {
        const selectForm = useMemo(makeSelectForm, []);
        const { pages, data } = useSelector(selectForm);
      
        const selectApp = useMemo(makeSelectApp, []);
      Severity: Minor
      Found in src/applications/check-in/hooks/useFormRouting.jsx - About 2 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 prefillTransformerV2 has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export function prefillTransformerV2(pages, formData, metadata, state) {
        const bankInformation = state.data?.bankInformation || {};
        const claimant = state.data?.formData?.data?.attributes?.claimant || {};
        const contactInfo = claimant?.contactInfo || {};
        const sponsors = state.data?.formData?.attributes?.sponsors;
      Severity: Minor
      Found in src/applications/toe/helpers.jsx - About 2 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 IntroductionPage has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      const IntroductionPage = props => {
        const dispatch = useDispatch();
        const { hasVaFileNumber, isLoading } = useSelector(
          state => state?.vaFileNumber,
        );

      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 AdditionalInformation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export function AdditionalInformation({ title, id, formData }) {
        return (
          <>
            <h2
              id={id}
      Severity: Minor
      Found in src/applications/pensions/components/SectionField.jsx - About 2 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 AddAsset has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      const AddAsset = ({ data, goToPath, setFormData }) => {
        const { assets } = data;
        const { otherAssets = [] } = assets;
      
        // Borrowed from 995 AddIssue

      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 DependentCount has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      const DependentCount = ({
        data,
        goBack,
        goToPath,
        setFormData,

      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 selectAppointmentLocality has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export function selectAppointmentLocality(
        appointment,
        isPendingAppointment = false,
      ) {
        const practitioner = selectPractitionerName(appointment);
      Severity: Minor
      Found in src/applications/vaos/appointment-list/redux/selectors.js - About 2 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 VAFacilityPage has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      function VAFacilityPage({
        address,
        canScheduleAtChosenFacility,
        facilitiesStatus,
        initialData,

      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 selectModalityText has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export function selectModalityText(appointment, isPendingAppointment = false) {
        const isCommunityCare = selectIsCommunityCare(appointment);
        const isInPerson = selectIsInPerson(appointment);
        const isPhone = selectIsPhone(appointment);
        const isVideoAtlas = selectIsAtlasVideo(appointment);
      Severity: Minor
      Found in src/applications/vaos/appointment-list/redux/selectors.js - About 2 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 getEligibilityMessage has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function getEligibilityMessage({
        typeOfCare,
        eligibility,
        facilityDetails,
        includeFacilityContactInfo = false,

      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

      Severity
      Category
      Status
      Source
      Language