bookbrainz/bookbrainz-site

View on GitHub
src/client/entity-editor/relationship-editor/relationship-editor.tsx

Summary

Maintainability
D
2 days
Test Coverage

File relationship-editor.tsx has 425 lines of code (exceeds 250 allowed). Consider refactoring.
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
Severity: Minor
Found in src/client/entity-editor/relationship-editor/relationship-editor.tsx - About 6 hrs to fix

    Function render has 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        render() {
            const {onCancel, onClose, baseEntity} = this.props;
            const baseEntityTypeForDisplay = _.startCase(baseEntity.type);
            const submitDisabled = this.calculateProgressAmount() < 100;
            const entitySelect = this.renderEntitySelect();
    Severity: Major
    Found in src/client/entity-editor/relationship-editor/relationship-editor.tsx - About 3 hrs to fix

      Function getInitState has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      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

            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

              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

            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

              function getValidOtherEntityTypes(
                  relTypes: Array<RelationshipType>,
                  baseEntity: Entity
              ) {
                  let relationshipTypes = relTypes;
              Severity: Minor
              Found in src/client/entity-editor/relationship-editor/relationship-editor.tsx - About 35 mins 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 getInitState has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function getInitState(
                  baseEntity: Entity, initRelationship: _Relationship | null | undefined
              ): RelationshipModalState {
                  if (_.isNull(initRelationship)) {
                      return {
              Severity: Minor
              Found in src/client/entity-editor/relationship-editor/relationship-editor.tsx - About 25 mins 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

              There are no issues that match your filters.

              Category
              Status