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',
},
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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';
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];
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();
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 {
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 || [];
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({
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);
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',
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,