Showing 12,821 of 12,821 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
export default {
uiSchema: {
...titleUI('Phone and email address'),
veteranPhone: phoneUI('Phone number'),
veteranInternationalPhone: phoneUI('International phone number'),
- 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 85.
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
Function paginatedThreads
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
const paginatedThreads = (req, res) => {
const { index } = req.params;
const { pageSize, pageNumber, sortField, sortOrder } = req.query;
const sortFunc = (a, b) => {
Function render
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const {
columnThreeLinkClicked,
href,
linkClicked,
Function updateUiSchema
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateUiSchema: formData => {
const arrayData = formData?.[arrayPath];
return arrayData?.length
? {
'ui:title':
File profileAddress.js
has 270 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* This uiSchema is modeled after how addresses are handled in the Profile application, and makes the same pattern
* available for use inside forms generated by the platform's form system.
*/
Function searchWithBounds
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
static searchWithBounds(
address = null,
bounds,
locationType,
serviceType,
Function onAddFile
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
const onAddFile = async (event, index = null, password) => {
if (event.target?.files?.length) {
// Only upload the first file; when va-file-input v3 supports multiple
// files, we'll need to update this entire component
const currentFile = event.target.files[0];
Function renderMedicalRecordInfo
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
const renderMedicalRecordInfo = formResponses => {
if (
[
RESPONSES.REASON_PTSD,
RESPONSES.REASON_TBI,
Function ClaimantInformation
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function ClaimantInformation(props) {
const { values, setFieldValue } = useFormikContext();
const getOptions = [
{ label: 'Spouse', value: 'spouse', key: 1 },
{ label: 'Child', value: 'child', key: 2 },
Function transform
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function transform(formConfig, form) {
const newSchoolTransform = formData => {
let clonedData = _.cloneDeep(formData);
delete clonedData.newSchoolName;
delete clonedData.newSchoolAddress;
Function RadioWidget
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function RadioWidget(props) {
const { options, formContext = {}, value, disabled, onChange, id } = props;
const { enumOptions, labels = {} } = options;
const onReviewPage = formContext?.onReviewPage || false;
Function AuthBenefitsPackagePage
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
const AuthBenefitsPackagePage = props => {
const { location, route, router } = props;
const { pathname } = location;
const { pageList } = route;
const { schema } = definition;
Function CustomReviewTopContent
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
const CustomReviewTopContent = () => {
const { form } = useSelector(state => state || {});
const { uploadedFile, idNumber, address, fullName } = form?.data;
const renderFileInfo = file => (
Function ConfirmationPage
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
const ConfirmationPage = () => {
const { user, form } = useSelector(state => state);
const { submission, data } = form;
const {
login: { currentlyLoggedIn },
Function aboutTheSchoolOptions
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function aboutTheSchoolOptions(
excludeCautionFlags,
accredited,
studentVeteran,
yellowRibbonScholarship,
Function typeOfInstitution
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
const typeOfInstitution = () => {
const title = 'Filter your results';
return (
<>
<hr />
Function validateAddress
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const validateAddress = (formData, fullName) => async (
dispatch,
getState,
) => {
dispatch({ type: ADDRESS_VALIDATION_START });
Function RadioWidget
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function RadioWidget(props) {
const { options, formContext = {}, value, disabled, onChange, id } = props;
const { enumOptions, labels = {} } = options;
const onReviewPage = formContext?.onReviewPage || false;
Function GenderIdentityAdditionalInfo
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function GenderIdentityAdditionalInfo() {
return (
<>
<p className="vads-u-color--gray-medium vads-u-display--block vads-u-font-weight--normal vads-u-margin--0 vads-u-width--full">
You can change your selection at any time. If you decide you no longer
Function render
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
let view;
if (this.props.success) {
view = (