bookbrainz/bookbrainz-site

View on GitHub

Showing 365 of 1,033 total issues

File add-to-collection-modal.js has 310 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as bootstrap from 'react-bootstrap';
import {faPlus, faTimes} from '@fortawesome/free-solid-svg-icons';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import PropTypes from 'prop-types';
import React from 'react';
Severity: Minor
Found in src/client/components/pages/parts/add-to-collection-modal.js - About 3 hrs to fix

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

        render() {
            const warnMessage = 'Are you sure? You entered a date in the future!';
            const labelElement = (
                <ValidationLabel
                    empty={this.props.empty}
    Severity: Major
    Found in src/client/entity-editor/common/new-date-field.js - About 3 hrs to fix

      Function LicensingPage has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function LicensingPage(): JSX.Element {
          const CC0Link = 'http://creativecommons.org/publicdomain/zero/1.0/';
          const CC0Image = 'http://i.creativecommons.org/p/zero/1.0/88x31.png';
      
          const CCBYSALink = 'http://creativecommons.org/licenses/by-sa/4.0/';
      Severity: Major
      Found in src/client/components/pages/licensing.tsx - About 3 hrs to fix

        File userCollection.js has 308 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*
         * Copyright (C) 2020 Prabal Singh
         *
         * 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/components/forms/userCollection.js - About 3 hrs to fix

          Function EntityMerge has 84 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const EntityMerge = (props: Props) => {
              const {
                  children,
                  mergingEntities,
                  identifierSet,
          Severity: Major
          Found in src/client/entity-editor/entity-merge.tsx - About 3 hrs to fix

            Function editionGroupToFormState has 84 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function editionGroupToFormState(editionGroup) {
                /** The front-end expects a language id rather than the language object. */
                const aliases = editionGroup.aliasSet ?
                    editionGroup.aliasSet.aliases.map(({languageId, ...rest}) => ({
                        ...rest,
            Severity: Major
            Found in src/server/routes/entity/edition-group.ts - About 3 hrs to fix

              File name-section.js has 306 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /*
               * Copyright (C) 2016  Ben Ockmore
               *
               * 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/name-section/name-section.js - About 3 hrs to fix

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

                    render() {
                        return (
                            <div>
                                {
                                    this.props.user ?
                Severity: Major
                Found in src/client/components/pages/entities/footer.js - About 3 hrs to fix

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

                      render() {
                          let errorComponent = null;
                          if (this.state.error) {
                              errorComponent =
                                  <Alert variant="danger">{this.state.error}</Alert>;
                  Severity: Major
                  Found in src/client/components/forms/registration-details.js - About 3 hrs to fix

                    Function transformFormData has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function transformFormData(data:Record<string, any>):Record<string, any> {
                        const newData = {};
                        const nextId = 0;
                        // add new series
                        _.forEach(data.Series, (series, sid) => {
                    Severity: Major
                    Found in src/client/entity-editor/submission-section/actions.ts - About 3 hrs to fix

                      File collection.js has 299 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      /*
                       * Copyright (C) 2020 Prabal Singh
                       *
                       * 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/server/routes/collection.js - About 3 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 IdentifierTypeEditor has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function IdentifierTypeEditor({identifierTypeData, parentTypes}: IdentifierTypeEditorPropsT) {
                              const [formData, setFormData] = useState<IdentifierTypeDataT>(identifierTypeData);
                          
                              // State for the ParentType modal
                              const [showModal, setShowModal] = useState<boolean>(false);
                          Severity: Minor
                          Found in src/client/components/forms/type-editor/identifier-type.tsx - About 3 hrs 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 SingleEntityCard has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export default function SingleEntityCard({entity, languageOptions}:SingleEntityCardProps) {
                              const id2LanguageMap = React.useMemo(() => Object.fromEntries(_.map(languageOptions, (option) => [option.id, option.name])), []);
                              // display formatted entity attributes in modal
                              function renderField(path, key) {
                                  let fieldVal = _.get(entity, path, '');
                          Severity: Minor
                          Found in src/client/unified-form/submit-tab/single-entity-card.tsx - About 3 hrs 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 EditorContainer has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function EditorContainer(props) {
                              const {tabActive, editor, children, user} = props;
                          
                              return (
                                  <div>
                          Severity: Major
                          Found in src/client/containers/editor.js - About 3 hrs to fix

                            File work.ts has 292 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            /*
                             * Copyright (C) 2015       Ben Ockmore
                             *               2015-2016  Sean Burke
                             *
                             * This program is free software; you can redistribute it and/or modify
                            Severity: Minor
                            Found in src/server/routes/entity/work.ts - About 3 hrs to fix

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

                                  render() {
                                      const ShowServiceOption = (optionData) => {
                                          const {
                                              service, value, title, details
                                          } = optionData;
                              Severity: Major
                              Found in src/client/components/pages/externalService.js - About 3 hrs to fix

                                File edition-group.ts has 291 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                /*
                                 * Copyright (C) 2015       Ben Ockmore
                                 *               2015-2016  Sean Burke
                                 *
                                 * This program is free software; you can redistribute it and/or modify
                                Severity: Minor
                                Found in src/server/routes/entity/edition-group.ts - About 3 hrs to fix

                                  File entity.tsx has 291 lines of code (exceeds 250 allowed). Consider refactoring.
                                  Open

                                  /*
                                   * Copyright (C) 2016  Daniel Hsing
                                   *                  2019  Akhilesh Kumar (@akhilesh26)
                                   *
                                   * This program is free software; you can redistribute it and/or modify
                                  Severity: Minor
                                  Found in src/client/helpers/entity.tsx - About 3 hrs to fix

                                    Function renderBasicInfo has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        renderBasicInfo() {
                                            const {user, editor} = this.props;
                                            const {
                                                cachedMetabrainzName,
                                                metabrainzUserId,
                                    Severity: Major
                                    Found in src/client/components/pages/parts/editor-profile.js - About 2 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language