Showing 12,811 of 12,811 total issues
File YourClaimsPageV2.jsx
has 302 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React from 'react';
import { connect } from 'react-redux';
import { VaPagination } from '@department-of-veterans-affairs/component-library/dist/react-bindings';
import PropTypes from 'prop-types';
File ComparePage.jsx
has 302 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React, {
useEffect,
useRef,
useState,
useCallback,
File index.jsx
has 302 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable react/sort-prop-types */
/* eslint-disable react/static-property-placement */
// Dependencies.
import React, { Component } from 'react';
import {
Function render
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { route } = this.props;
const { formConfig, pageList } = route;
return (
Function FileFieldCustom
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function FileFieldCustom(props) {
const updateButton = (
// eslint-disable-next-line @department-of-veterans-affairs/prefer-button-component
<button type="submit" onClick={props.updatePage}>
Update page
Function renderResultsSection
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
const renderResultsSection = () => {
const {
currentQuery,
searchResults,
pagination,
Function usePostTravelOnlyClaim
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
const usePostTravelOnlyClaim = props => {
const { router } = props;
const { jumpToPage } = useFormRouting(router);
const [isLoading, setIsLoading] = useState(false);
const [isComplete, setIsComplete] = useState(false);
Function useFormRouting
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
const useFormRouting = (router = {}) => {
const selectForm = useMemo(makeSelectForm, []);
const { pages, data } = useSelector(selectForm);
const selectApp = useMemo(makeSelectApp, []);
File actions.js
has 301 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as Sentry from '@sentry/browser';
import recordEvent from '../../monitoring/record-event';
import { logOut } from '../../user/authentication/actions';
import { apiRequest } from '../../utilities/api';
Function OfficialGovtWebsite
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const OfficialGovtWebsite = () => {
const [expanded, setExpanded] = useState(false);
const onToggle = () => {
if (expanded) {
File RoutedSavableApp.jsx
has 300 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React from 'react';
import PropTypes from 'prop-types';
import Scroll from 'react-scroll';
import { withRouter } from 'react-router';
import { connect } from 'react-redux';
Function AdditionalConsiderationTemplate
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
function AdditionalConsiderationTemplate(page, formField, options = {}) {
const { title, additionalInfo } = page;
const additionalInfoViewName = `view:${page.name}AdditionalInfo`;
const displayTypeMapping = {
[formFields.federallySponsoredAcademy]: 'Academy',
Function priorServiceStatement
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
const priorServiceStatement = () => {
const onDD214LinkClick = () => {
router.push(ROUTES.DD214);
};
Function render
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { form } = this.props;
const { submission, data } = form;
const submitDate = new Date(submission?.timestamp);
Function onAddFile
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
const onAddFile = async (event, index = null, password) => {
if (event.target?.files?.length) {
const currentFile = event.target.files[0];
const allFiles = props.formData || [];
const addUiOptions = props.uiSchema['ui:options'];
Function onAddFile
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
const onAddFile = async (event, index = null, password) => {
if (event.target?.files?.length) {
const currentFile = event.target.files[0];
const allFiles = props.formData || [];
const addUiOptions = props.uiSchema['ui:options'];
Function ApplicationDownloadLink
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
const ApplicationDownloadLink = () => {
const [loading, isLoading] = useState(false);
const [errors, setErrors] = useState([]);
// define local use variables
Function ClosestCityStatePage
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function ClosestCityStatePage() {
const pageTitle = useSelector(state => getPageTitle(state, pageKey));
const uiSchema = {
communityCareSystemId: {
Function HealthConditions
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
const HealthConditions = () => {
const dispatch = useDispatch();
const updatedRecordList = useSelector(
state => state.mr.conditions.updatedList,
);
Identical blocks of code found in 6 locations. Consider refactoring. Open
if (suffix) {
newData[formFields.viewUserFullName].userFullName.suffix =
state?.form?.pages?.applicantInformation?.schema?.properties[
formFields.viewUserFullName
]?.properties?.userFullName?.properties?.suffix?.enum?.find(e =>
- 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 99.
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