bookbrainz/bookbrainz-site

View on GitHub

Showing 1,033 of 1,033 total issues

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

export function debouncedUpdateEndDate(newEndDate: string): Action {
    return {
        meta: {debounce: 'keystroke'},
        payload: newEndDate,
        type: UPDATE_END_DATE
Severity: Major
Found in src/client/entity-editor/publisher-section/actions.ts and 7 other locations - About 50 mins to fix
src/client/entity-editor/author-section/actions.ts on lines 78..84
src/client/entity-editor/author-section/actions.ts on lines 108..114
src/client/entity-editor/name-section/actions.ts on lines 74..80
src/client/entity-editor/name-section/actions.ts on lines 90..96
src/client/entity-editor/name-section/actions.ts on lines 121..129
src/client/entity-editor/publisher-section/actions.ts on lines 79..85
src/client/unified-form/cover-tab/action.ts on lines 89..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 51.

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

export function debouncedUpdateISBNValue(newValue: string): Action {
    return {
        meta: {debounce: 'keystroke'},
        payload: newValue,
        type: UPDATE_ISBN_VALUE
Severity: Major
Found in src/client/unified-form/cover-tab/action.ts and 7 other locations - About 50 mins to fix
src/client/entity-editor/author-section/actions.ts on lines 78..84
src/client/entity-editor/author-section/actions.ts on lines 108..114
src/client/entity-editor/name-section/actions.ts on lines 74..80
src/client/entity-editor/name-section/actions.ts on lines 90..96
src/client/entity-editor/name-section/actions.ts on lines 121..129
src/client/entity-editor/publisher-section/actions.ts on lines 79..85
src/client/entity-editor/publisher-section/actions.ts on lines 95..101

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

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 const ENTITY_TYPE_ICONS = {
    Area: faGlobe,
    Author: faUser,
    Book: faMagicWandSparkles,
    Collection: faGripVertical,
Severity: Minor
Found in src/client/helpers/entity.tsx and 1 other location - About 50 mins to fix
src/client/unified-form/unified-form.tsx on lines 27..28

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

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 {allIdentifierTypes, validator, onSubmit, formValid,
        languageOptions, contentTabEmpty, coverTabValid, coverTabEmpty, detailTabValid, detailTabEmpty} = props;
Severity: Minor
Found in src/client/unified-form/unified-form.tsx and 1 other location - About 50 mins to fix
src/client/helpers/entity.tsx on lines 264..275

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

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

            <MergeField
                components={{Option: LinkedEntitySelect, SingleValue: EntitySelect}}
                currentValue={areaValue}
                label="Area"
                options={areaOptions}
src/client/entity-editor/edition-section/edition-section-merge.tsx on lines 231..237
src/client/entity-editor/edition-section/edition-section-merge.tsx on lines 244..250

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

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

            <MergeField
                components={{Option: LinkedEntitySelect, SingleValue: EntitySelect}}
                currentValue={editionGroupValue}
                label="Edition Group"
                options={editionGroupOptions}
src/client/entity-editor/edition-section/edition-section-merge.tsx on lines 244..250
src/client/entity-editor/publisher-section/publisher-section-merge.tsx on lines 161..167

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

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 EditionTableRow has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function EditionTableRow({edition, showAddedAtColumn, showAuthorCreditsColumn, showCheckboxes, selectedEntities, onToggleRow}) {
    const name = getEntityLabel(edition);
    const disambiguation = getEntityDisambiguation(edition);
    const number = edition.number || '?';
    const releaseDate = getEditionReleaseDate(edition);
Severity: Minor
Found in src/client/components/pages/entities/edition-table.js - About 45 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 getBrowsedRelationships has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

export async function getBrowsedRelationships(orm, locals, browsedEntityType,
                                              getEntityInfoMethod, fetchRelated, filterRelationshipMethod) {
Severity: Minor
Found in src/api/helpers/utils.js - About 45 mins to fix

    Function IdentifierButton has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function IdentifierButton({
        identifiersInvalid,
        numIdentifiers,
        isUnifiedForm,
        ...props
    Severity: Minor
    Found in src/client/entity-editor/button-bar/identifier-button.js - About 45 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 formatEditionChange has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function formatEditionChange(change) {
        if (_.isEqual(change.path, ['editionGroupBbid'])) {
            return baseFormatter.formatScalarChange(change, 'EditionGroup');
        }
    
    
    Severity: Minor
    Found in src/server/routes/revision.js - About 45 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 renderBasicInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        renderBasicInfo() {
            const {user, editor} = this.props;
            const {
                cachedMetabrainzName,
                metabrainzUserId,
    Severity: Minor
    Found in src/client/components/pages/parts/editor-profile.js - About 45 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 formatRelationship has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function formatRelationship(entity, change) {
        if (change.kind === 'N') {
            return formatAddOrDeleteRelationshipSet(entity, change);
        }
        if (change.kind === 'A') {
    Severity: Minor
    Found in src/server/helpers/diffFormatters/entity.js - About 45 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 format has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        change, setProp, itemProp, newSetFormatter, addDeleteFormatter,
        modifyFormatter
    Severity: Minor
    Found in src/server/helpers/diffFormatters/set.js - About 45 mins to fix

      Function awardTitle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      async function awardTitle(orm, editorId, tier) {
          const {TitleType, TitleUnlock} = orm;
          if (tier.titleName) {
              const title = await new TitleType({title: tier.titleName})
                  .fetch({require: false});
      Severity: Minor
      Found in src/server/helpers/achievement.js - About 45 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 dateIsBefore has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export function dateIsBefore(beginValue: string | DateObject, endValue: string | DateObject): boolean {
          const beginDateObject = ISODateStringToObject(beginValue);
          const endDateObject = ISODateStringToObject(endValue);
          if (isNullDate(beginDateObject) || isNullDate(endDateObject) || !validateDate(beginDateObject).isValid ||
              !validateDate(endDateObject).isValid) {
      Severity: Minor
      Found in src/client/entity-editor/validators/base.ts - About 45 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 validateCollectionParams has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function validateCollectionParams(req, res, next) {
          const {collaborators = [], name, entityType} = req.body;
          const {orm} = req.app.locals;
          const {Editor} = orm;
      
      
      Severity: Minor
      Found in src/server/helpers/middleware.ts - About 45 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 validateEditionSectionPublisher has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export function validateEditionSectionPublisher(value: any): boolean {
          if (!value) {
              return true;
          }
          const publishers = convertMapToObject(value);
      Severity: Minor
      Found in src/client/entity-editor/validators/edition.ts - About 45 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 processMergeOperation has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      export async function processMergeOperation(orm, transacting, session, mainEntity, allEntities, relationshipSets) {
      Severity: Minor
      Found in src/server/routes/entity/entity.tsx - About 45 mins to fix

        Function deleteRelationships has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function deleteRelationships(orm: any, transacting: Transaction, mainEntity: any) {
            const mainBBID = mainEntity.bbid;
            const {relationshipSet} = mainEntity;
            const otherBBIDs = [];
            const otherEntities = [];
        Severity: Minor
        Found in src/server/routes/entity/entity.tsx - About 45 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 CoverTab has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export function CoverTab(props:CoverProps) {
            const {publisherValue: publishers, onPublisherChange, identifierEditorVisible,
                onClearPublisher, handleClearPublishers, modalIsOpen, ...rest} = props;
            const publisherValue:EntitySelect[] = Object.values(convertMapToObject(publishers ?? {}));
            const onChangeHandler = React.useCallback((value:EntitySelect[], action) => {
        Severity: Minor
        Found in src/client/unified-form/cover-tab/cover-tab.tsx - About 45 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

        Severity
        Category
        Status
        Source
        Language