src/client/entity-editor/relationship-editor/relationship-editor.tsx
File relationship-editor.tsx
has 425 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/*
* Copyright (C) 2018 Ben Ockmore
* 2021 Akash Gupta
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Function render
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const {onCancel, onClose, baseEntity} = this.props;
const baseEntityTypeForDisplay = _.startCase(baseEntity.type);
const submitDisabled = this.calculateProgressAmount() < 100;
const entitySelect = this.renderEntitySelect();
Function getInitState
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getInitState(
baseEntity: Entity, initRelationship: _Relationship | null | undefined
): RelationshipModalState {
if (_.isNull(initRelationship)) {
return {
Function renderRelationshipSelect
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderRelationshipSelect() {
const {baseEntity, relationshipTypes} = this.props;
const otherEntity = {
bbid: _.get(this.state, ['targetEntity', 'id']),
Function renderEntitySelect
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderEntitySelect() {
const {baseEntity, relationshipTypes} = this.props;
const {targetEntity} = this.state;
const types = getValidOtherEntityTypes(relationshipTypes, baseEntity);
if (!types.length) {
Function generateRelationshipSelection
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function generateRelationshipSelection(
relationshipTypes: Array<RelationshipType>,
entityA: Entity,
entityB: Entity
): Array<RelationshipWithLabel> {
Function getValidOtherEntityTypes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
function getValidOtherEntityTypes(
relTypes: Array<RelationshipType>,
baseEntity: Entity
) {
let relationshipTypes = relTypes;
- Read upRead up
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 getInitState
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
function getInitState(
baseEntity: Entity, initRelationship: _Relationship | null | undefined
): RelationshipModalState {
if (_.isNull(initRelationship)) {
return {
- Read upRead up
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"