bookbrainz/bookbrainz-site

View on GitHub

Showing 365 of 1,033 total issues

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

    render() {
        const messageComponent =
            this.state.message.text ? (
                <Alert
                    className="margin-top-1"
Severity: Major
Found in src/client/components/pages/collection.js - About 5 hrs to fix

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

        render() {
            const {entity} = this.props;
            const {note} = this.state;
    
            this.entityUrl = `/${_kebabCase(entity.type)}/${entity.bbid}`;
    Severity: Major
    Found in src/client/components/forms/deletion.js - About 5 hrs to fix

      File identifier-type.tsx has 372 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*
       * Copyright (C) 2023 Shivam Awasthi
       *
       * 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/type-editor/identifier-type.tsx - About 4 hrs to fix

        Function RelationshipTypeEditor has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

        function RelationshipTypeEditor({relationshipTypeData, parentTypes, attributeTypes}: RelationshipTypeEditorPropsT) {
            const [formData, setFormData] = useState<RelationshipTypeDataT>(relationshipTypeData);
        
            // State for the ParentType modal
            const [showModal, setShowModal] = useState<boolean>(false);
        Severity: Minor
        Found in src/client/components/forms/type-editor/relationship-type.tsx - About 4 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 HelpPage has 122 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function HelpPage(): JSX.Element {
            const IRCLink = 'https://kiwiirc.com/nextclient/irc.libera.chat/?#bookbrainz';
            const userGuideLink =
                'https://bookbrainz-user-guide.readthedocs.io/';
        
        
        Severity: Major
        Found in src/client/components/pages/help.tsx - About 4 hrs to fix

          File middleware.ts has 367 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /*
           * Copyright (C) 2015       Ben Ockmore
           *               2015-2016  Sean Burke
           *               2021       Akash Gupta
           *               2022       Ansh Goyal
          Severity: Minor
          Found in src/server/helpers/middleware.ts - About 4 hrs to fix

            Function crossSliceReducer has 118 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function crossSliceReducer(state:State, action:Action) {
                const {type} = action;
                let intermediateState = state;
                const activeEntityState = {
                    aliasEditor: state.get('aliasEditor'),
            Severity: Major
            Found in src/client/unified-form/helpers.ts - About 4 hrs to fix

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

                  render() {
                      const {revision, diffs, user} = this.props;
                      let regularDiffs = diffs;
                      let mergeDiffDivs;
              
              
              Severity: Major
              Found in src/client/components/pages/revision.js - About 4 hrs to fix

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

                    render() {
                        const {
                            disambiguationDefaultValue,
                            entityType,
                            exactMatches: immutableExactMatches,
                Severity: Major
                Found in src/client/entity-editor/name-section/name-section.js - About 4 hrs to fix

                  Function editionToFormState has 111 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

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

                    Function entitiesToFormState has 111 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function entitiesToFormState(entities: any[]) {
                        const [targetEntity, ...otherEntities] = entities;
                        const aliases: any[] = entities.reduce((returnValue, entity) => {
                            if (Array.isArray(_.get(entity, 'aliasSet.aliases'))) {
                                return returnValue.concat(
                    Severity: Major
                    Found in src/server/routes/merge.ts - About 4 hrs to fix

                      Function SearchAdminPage has 111 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export default function SearchAdminPage() {
                          const [loading, setLoading] = useState(false);
                          const [errorMessage, setErrorMessage] = useState<string>();
                          const [success, setSuccess] = useState(false);
                          const indexEntity = useCallback(async (entityType?:string) => {
                      Severity: Major
                      Found in src/client/components/pages/searchAdmin.tsx - About 4 hrs to fix

                        Function RevisionsTable has 109 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function RevisionsTable(props) {
                            const {results, showEntities, showRevisionNote, showRevisionEditor, tableHeading} = props;
                            return (
                                <div>
                                    <div>
                        Severity: Major
                        Found in src/client/components/pages/parts/revisions-table.js - About 4 hrs to fix

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

                              render() {
                                  const loadingElement =
                                      this.state.waiting ? <LoadingSpinner/> : null;
                                  const genderOptions = this.state.genders.map((gender) => ({
                                      id: gender.id,
                          Severity: Major
                          Found in src/client/components/forms/profile.js - About 4 hrs to fix

                            Function processSingleEntity has 99 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export async function processSingleEntity(formBody, JSONEntity, reqSession,
                                entityType, orm:any, editorJSON, derivedProps, isMergeOperation, transacting):Promise<any> {
                                const {Entity, Revision} = orm;
                                let body = sanitizeBody(formBody);
                                let currentEntity: {
                            Severity: Major
                            Found in src/server/routes/entity/entity.tsx - About 3 hrs to fix

                              Function displayEntity has 99 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export function displayEntity(req: PassportRequest, res: $Response) {
                                  const {orm}: {orm?: any} = req.app.locals;
                                  const {AchievementUnlock, EditorEntityVisits} = orm;
                                  const {locals: resLocals}: {locals: any} = res;
                                  const {entity}: {entity: any} = resLocals;
                              Severity: Major
                              Found in src/server/routes/entity/entity.tsx - About 3 hrs to fix

                                File merge.ts has 331 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                /*
                                 * Copyright (C) 2019  Nicolas Pelletier
                                 *
                                 * 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/merge.ts - About 3 hrs to fix

                                  File collection.js has 322 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/pages/collection.js - About 3 hrs to fix

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

                                        render() {
                                            if (this.state.entities.length === 0) {
                                                this.handleAddEntity();
                                            }
                                    
                                    
                                    Severity: Major
                                    Found in src/client/components/pages/parts/add-entity-to-collection-modal.js - About 3 hrs to fix

                                      Function dateValidator has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      export function dateValidator(dayObj, monthObj, yearObj) {
                                          const year = Number.parseInt(yearObj, 10);
                                          const month = Number.parseInt(monthObj, 10);
                                          const day = Number.parseInt(dayObj, 10);
                                      
                                      
                                      Severity: Minor
                                      Found in src/client/entity-editor/validators/date.js - 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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language