bookbrainz/bookbrainz-site

View on GitHub

Showing 1,033 of 1,033 total issues

Similar blocks of code found in 9 locations. Consider refactoring.
Open

                    <Row>
                        <Col lg={lgCol}>
                            <Form.Group>
                                <Form.Label>Validation RegEx</Form.Label>
                                <Form.Control
Severity: Major
Found in src/client/components/forms/type-editor/identifier-type.tsx and 8 other locations - About 4 hrs to fix
src/client/components/forms/type-editor/identifier-type.tsx on lines 213..226
src/client/components/forms/type-editor/identifier-type.tsx on lines 227..240
src/client/components/forms/type-editor/identifier-type.tsx on lines 241..254
src/client/components/forms/type-editor/identifier-type.tsx on lines 269..282
src/client/components/forms/type-editor/relationship-type.tsx on lines 266..279
src/client/components/forms/type-editor/relationship-type.tsx on lines 280..293
src/client/components/forms/type-editor/relationship-type.tsx on lines 294..307
src/client/components/forms/type-editor/relationship-type.tsx on lines 308..321

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 117.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        return combineReducers({
            Authors: authorsReducer,
            EditionGroups: editionGroupsReducer,
            Editions: newEditionReducer,
            ISBN: ISBNReducer,
Severity: Major
Found in src/client/unified-form/helpers.ts and 1 other location - About 4 hrs to fix
src/client/entity-editor/author-section/author-section.tsx on lines 137..161

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 116.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

function AuthorSection({
    beginAreaLabel,
    beginDateLabel,
    beginDateValue,
    beginAreaValue,
Severity: Major
Found in src/client/entity-editor/author-section/author-section.tsx and 1 other location - About 4 hrs to fix
src/client/unified-form/helpers.ts on lines 255..279

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 116.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            <Row>
                <Col lg={lgCol}>
                    <Form.Group>
                        <Form.Label>Type</Form.Label>
                        <Select
src/client/entity-editor/author-section/author-section.tsx on lines 188..202

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 116.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            <Row>
                <Col lg={lgCol}>
                    <Form.Group>
                        <Form.Label>Type</Form.Label>
                        <Select
Severity: Major
Found in src/client/entity-editor/author-section/author-section.tsx and 1 other location - About 4 hrs to fix
src/client/entity-editor/publisher-section/publisher-section.tsx on lines 144..158

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 116.

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

Further Reading

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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            for (let i = 0; i < collaboratorIds.length; i++) {
                const collaboratorId = collaboratorIds[i];
                const isCollaborator = collection.collaborators.find(collaborator => collaborator.id === collaboratorId);
                if (!isCollaborator) {
                    return next(new error.BadRequestError(`User ${collaboratorId} is not a collaborator of collection ${collection.id}`, req));
        Severity: Major
        Found in src/server/helpers/middleware.ts and 1 other location - About 3 hrs to fix
        src/server/helpers/middleware.ts on lines 427..433

        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 111.

        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

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            for (let i = 0; i < bbids.length; i++) {
                const bbid = bbids[i];
                const isBbidInCollection = collection.items.find(item => item.bbid === bbid);
                if (!isBbidInCollection) {
                    return next(new error.BadRequestError(`Entity ${bbid} is not in collection ${collection.id}`, req));
        Severity: Major
        Found in src/server/helpers/middleware.ts and 1 other location - About 3 hrs to fix
        src/server/helpers/middleware.ts on lines 444..450

        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 111.

        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

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                        <PagerElement
                            from={this.props.from}
                            nextEnabled={this.props.nextEnabled}
                            paginationUrl={this.paginationUrl}
                            querySearchParams={querySearchParams}
        Severity: Major
        Found in src/client/components/pages/search.tsx and 1 other location - About 3 hrs to fix
        src/client/components/pages/admin-panel-search.tsx on lines 158..168

        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 110.

        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

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                                <PagerElement
                                    from={this.props.from}
                                    nextEnabled={this.props.nextEnabled}
                                    paginationUrl={this.paginationUrl}
                                    querySearchParams={querySearchParams}
        Severity: Major
        Found in src/client/components/pages/admin-panel-search.tsx and 1 other location - About 3 hrs to fix
        src/client/components/pages/search.tsx on lines 161..171

        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 110.

        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

        Further Reading

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              toggleRow(bbid) {
                  const oldSelected = this.state.selectedEntities;
                  let newSelected;
                  if (oldSelected.find(selectedBBID => selectedBBID === bbid)) {
                      newSelected = oldSelected.filter(selectedBBID => selectedBBID !== bbid);
          Severity: Major
          Found in src/client/components/pages/collection.js and 1 other location - About 3 hrs to fix
          src/client/components/pages/parts/add-to-collection-modal.js on lines 49..61

          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 108.

          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

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              toggleRow(collectionId) {
                  const oldSelected = this.state.selectedCollections;
                  let newSelected;
                  if (oldSelected.find(selectedId => selectedId === collectionId)) {
                      newSelected = oldSelected.filter(selectedId => selectedId !== collectionId);
          Severity: Major
          Found in src/client/components/pages/parts/add-to-collection-modal.js and 1 other location - About 3 hrs to fix
          src/client/components/pages/collection.js on lines 129..141

          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 108.

          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

          Further Reading

          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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            export function getRelationshipTargetByTypeId(entity, relationshipTypeId: number) {
                let targets = [];
                if (Array.isArray(entity.relationships)) {
                    targets = entity.relationships
                        .filter(
            Severity: Major
            Found in src/client/helpers/entity.tsx and 1 other location - About 3 hrs to fix
            src/client/helpers/entity.tsx on lines 396..409

            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 106.

            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

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            export function getRelationshipSourceByTypeId(entity, relationshipTypeId: number) {
                let sources = [];
                if (Array.isArray(entity.relationships)) {
                    sources = entity.relationships
                        .filter(
            Severity: Major
            Found in src/client/helpers/entity.tsx and 1 other location - About 3 hrs to fix
            src/client/helpers/entity.tsx on lines 332..345

            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 106.

            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

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                const markup = ReactDOMServer.renderToString(
                    <Layout {...propHelpers.extractLayoutProps(rest)}>
                        <Provider store={store}>
                            <EntityEditor
                                validate={getValidator(props.entityType)}
            Severity: Major
            Found in src/server/helpers/entityRouteUtils.tsx and 1 other location - About 3 hrs to fix
            src/server/helpers/entityRouteUtils.tsx on lines 204..215

            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 104.

            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

            Further Reading

            Severity
            Category
            Status
            Source
            Language