bookbrainz/bookbrainz-site

View on GitHub

Showing 1,033 of 1,033 total issues

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

            if (response.body.alert) {
                const alertParam = `?alert=${response.body.alert}`;
                window.location.href = `${redirectUrl}${alertParam}`;
            }
            else {
Severity: Major
Found in src/client/entity-editor/submission-section/actions.ts and 1 other location - About 2 hrs to fix
src/client/entity-editor/submission-section/actions.ts on lines 220..226

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

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 6 locations. Consider refactoring.
Open

router.get('/:bbid/delete', auth.isAuthenticated, auth.isAuthorized(ENTITY_EDITOR), (req, res, next) => {
    if (!res.locals.entity.dataId) {
        return next(new ConflictError('This entity has already been deleted'));
    }
    _setAuthorTitle(res);
Severity: Major
Found in src/server/routes/entity/author.ts and 5 other locations - About 2 hrs to fix
src/server/routes/entity/edition-group.ts on lines 212..218
src/server/routes/entity/edition.ts on lines 389..395
src/server/routes/entity/publisher.ts on lines 224..230
src/server/routes/entity/series.ts on lines 213..219
src/server/routes/entity/work.ts on lines 237..243

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

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 6 locations. Consider refactoring.
Open

router.get('/:bbid/delete', auth.isAuthenticated, auth.isAuthorized(ENTITY_EDITOR), (req, res, next) => {
    if (!res.locals.entity.dataId) {
        return next(new ConflictError('This entity has already been deleted'));
    }
    _setPublisherTitle(res);
Severity: Major
Found in src/server/routes/entity/publisher.ts and 5 other locations - About 2 hrs to fix
src/server/routes/entity/author.ts on lines 218..224
src/server/routes/entity/edition-group.ts on lines 212..218
src/server/routes/entity/edition.ts on lines 389..395
src/server/routes/entity/series.ts on lines 213..219
src/server/routes/entity/work.ts on lines 237..243

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

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 6 locations. Consider refactoring.
Open

router.get('/:bbid/delete', auth.isAuthenticated, auth.isAuthorized(ENTITY_EDITOR), (req, res, next) => {
    if (!res.locals.entity.dataId) {
        return next(new ConflictError('This entity has already been deleted'));
    }
    _setSeriesTitle(res);
Severity: Major
Found in src/server/routes/entity/series.ts and 5 other locations - About 2 hrs to fix
src/server/routes/entity/author.ts on lines 218..224
src/server/routes/entity/edition-group.ts on lines 212..218
src/server/routes/entity/edition.ts on lines 389..395
src/server/routes/entity/publisher.ts on lines 224..230
src/server/routes/entity/work.ts on lines 237..243

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

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 6 locations. Consider refactoring.
Open

router.get('/:bbid/delete', auth.isAuthenticated, auth.isAuthorized(ENTITY_EDITOR), (req, res, next) => {
    if (!res.locals.entity.dataId) {
        return next(new ConflictError('This entity has already been deleted'));
    }
    _setWorkTitle(res);
Severity: Major
Found in src/server/routes/entity/work.ts and 5 other locations - About 2 hrs to fix
src/server/routes/entity/author.ts on lines 218..224
src/server/routes/entity/edition-group.ts on lines 212..218
src/server/routes/entity/edition.ts on lines 389..395
src/server/routes/entity/publisher.ts on lines 224..230
src/server/routes/entity/series.ts on lines 213..219

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

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 handleTargetEntityTypeChange = useCallback((selectedOption) => {
        if (selectedOption) {
            setFormData({...formData, targetEntityType: selectedOption.name});
            if (formData.sourceEntityType) {
                setShowIncompleteFormError(false);
src/client/components/forms/type-editor/relationship-type.tsx on lines 179..189

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

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 handleSourceEntityTypeChange = useCallback((selectedOption) => {
        if (selectedOption) {
            setFormData({...formData, sourceEntityType: selectedOption.name});
            if (formData.targetEntityType) {
                setShowIncompleteFormError(false);
src/client/components/forms/type-editor/relationship-type.tsx on lines 191..201

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

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 6 locations. Consider refactoring.
Open

router.get('/:bbid/delete', auth.isAuthenticated, auth.isAuthorized(ENTITY_EDITOR), (req, res, next) => {
    if (!res.locals.entity.dataId) {
        return next(new ConflictError('This entity has already been deleted'));
    }
    _setEditionGroupTitle(res);
Severity: Major
Found in src/server/routes/entity/edition-group.ts and 5 other locations - About 2 hrs to fix
src/server/routes/entity/author.ts on lines 218..224
src/server/routes/entity/edition.ts on lines 389..395
src/server/routes/entity/publisher.ts on lines 224..230
src/server/routes/entity/series.ts on lines 213..219
src/server/routes/entity/work.ts on lines 237..243

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

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 6 locations. Consider refactoring.
Open

router.get('/:bbid/delete', auth.isAuthenticated, auth.isAuthorized(ENTITY_EDITOR), (req, res, next) => {
    if (!res.locals.entity.dataId) {
        return next(new ConflictError('This entity has already been deleted'));
    }
    _setEditionTitle(res);
Severity: Major
Found in src/server/routes/entity/edition.ts and 5 other locations - About 2 hrs to fix
src/server/routes/entity/author.ts on lines 218..224
src/server/routes/entity/edition-group.ts on lines 212..218
src/server/routes/entity/publisher.ts on lines 224..230
src/server/routes/entity/series.ts on lines 213..219
src/server/routes/entity/work.ts on lines 237..243

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

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 entityRouteUtils.tsx has 269 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (C) 2017  Eshan 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/helpers/entityRouteUtils.tsx - About 2 hrs to fix

    Function entitiesToFormState has a Cognitive Complexity of 18 (exceeds 5 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: Minor
    Found in src/server/routes/merge.ts - About 2 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 relationshipTypeCreateOrEditHandler has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function relationshipTypeCreateOrEditHandler(req, res, next) {
        try {
            const {RelationshipType, RelationshipTypeAttributeType, bookshelf} = req.app.locals.orm;
            const trx = await bookshelf.transaction();
            let newRelationshipType;
    Severity: Major
    Found in src/server/helpers/typeRouteUtils.ts - About 2 hrs to fix

      File content-tab.tsx has 266 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import * as Bootstrap from 'react-bootstrap/';
      import {ContentTabDispatchProps, ContentTabProps, ContentTabStateProps, State} from '../interface/type';
      import {addBulkSeriesItems, addSeriesItem, removeAllSeriesItems, updateOrderType, updateSeriesType} from '../../entity-editor/series-section/actions';
      import {addSeries, addWork, duplicateWork, removeSeries} from './action';
      import {closeEntityModal, dumpEdition, loadEdition, openEntityModal} from '../action';
      Severity: Minor
      Found in src/client/unified-form/content-tab/content-tab.tsx - About 2 hrs to fix

        Function Footer has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function Footer(props) {
            const {repositoryUrl, siteRevision} = props;
        
            return (
                <footer className="footer">
        Severity: Major
        Found in src/client/components/footer.js - About 2 hrs to fix

          Function UnifiedForm has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function UnifiedForm(props:UnifiedFormProps) {
              const {allIdentifierTypes, validator, onSubmit, formValid,
                  languageOptions, contentTabEmpty, coverTabValid, coverTabEmpty, detailTabValid, detailTabEmpty} = props;
              const rest = omit(props, ['contentTabEmpty', 'coverTabValid', 'coverTabEmpty', 'detailTabValid', 'formValid', 'detailTabEmpty']);
              React.useMemo(() => {
          Severity: Major
          Found in src/client/unified-form/unified-form.tsx - About 2 hrs to fix

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

                                        {onRemove &&
                                            <Button
                                                className="w-100"
                                                href="#"
                                                role="button"
            src/client/entity-editor/relationship-editor/relationship-section.tsx on lines 84..95

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

            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

                                        {onEdit &&
                                            <Button
                                                className="w-100"
                                                href="#"
                                                role="button"
            src/client/entity-editor/relationship-editor/relationship-section.tsx on lines 96..107

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

            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 renderBadges has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                renderBadges() {
                    const {achievement} = this.props;
                    let achievementBsSize = 12;
                    if (achievement.length === 1) {
                        achievementBsSize = 8;
            Severity: Major
            Found in src/client/components/pages/parts/editor-profile.js - About 2 hrs to fix

              Function handleCreateMultipleEntities has 58 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function handleCreateMultipleEntities(
                  req: PassportRequest,
                  res: $Response
              ) {
                  const {orm}: {orm?: any} = req.app.locals;
              Severity: Major
              Found in src/server/routes/entity/process-unified-form.ts - About 2 hrs to fix

                File author-section.tsx has 263 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/author-section/author-section.tsx - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language