bookbrainz/bookbrainz-site

View on GitHub

Showing 1,033 of 1,033 total issues

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

                <Col lg={3}>
                    <dl>
                        <AverageRating
                            averageRatings={averageRating}
                            reviewsCount={reviewsCount}
Severity: Major
Found in src/client/components/pages/entities/edition-group.js and 2 other locations - About 55 mins to fix
src/client/components/pages/entities/series.js on lines 73..80
src/client/components/pages/entities/work.js on lines 72..79

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

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

    if (_.isEqual(change.path, ['endArea']) ||
            _.isEqual(change.path, ['endArea', 'name'])) {
        return baseFormatter.formatAreaChange(change, 'End Area');
    }
Severity: Major
Found in src/server/routes/revision.js and 8 other locations - About 55 mins to fix
src/server/routes/revision.js on lines 62..65
src/server/routes/revision.js on lines 67..70
src/server/routes/revision.js on lines 110..113
src/server/routes/revision.js on lines 115..118
src/server/routes/revision.js on lines 135..138
src/server/routes/revision.js on lines 149..152
src/server/routes/revision.js on lines 163..166
src/server/routes/revision.js on lines 172..175

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

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

    if (_.isEqual(change.path, ['editionFormat']) ||
            _.isEqual(change.path, ['editionFormat', 'label'])) {
        return baseFormatter.formatTypeChange(change, 'Edition Format');
    }
Severity: Major
Found in src/server/routes/revision.js and 8 other locations - About 55 mins to fix
src/server/routes/revision.js on lines 62..65
src/server/routes/revision.js on lines 67..70
src/server/routes/revision.js on lines 72..75
src/server/routes/revision.js on lines 115..118
src/server/routes/revision.js on lines 135..138
src/server/routes/revision.js on lines 149..152
src/server/routes/revision.js on lines 163..166
src/server/routes/revision.js on lines 172..175

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

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

    if (_.isEqual(change.path, ['seriesOrderingType']) ||
            _.isEqual(change.path, ['seriesOrderingType', 'label'])) {
        return baseFormatter.formatTypeChange(change, 'Series Ordering Type');
    }
Severity: Major
Found in src/server/routes/revision.js and 8 other locations - About 55 mins to fix
src/server/routes/revision.js on lines 62..65
src/server/routes/revision.js on lines 67..70
src/server/routes/revision.js on lines 72..75
src/server/routes/revision.js on lines 110..113
src/server/routes/revision.js on lines 115..118
src/server/routes/revision.js on lines 135..138
src/server/routes/revision.js on lines 163..166
src/server/routes/revision.js on lines 172..175

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

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

    if (_.isEqual(change.path, ['beginArea']) ||
            _.isEqual(change.path, ['beginArea', 'name'])) {
        return baseFormatter.formatAreaChange(change, 'Begin Area');
    }
Severity: Major
Found in src/server/routes/revision.js and 8 other locations - About 55 mins to fix
src/server/routes/revision.js on lines 62..65
src/server/routes/revision.js on lines 72..75
src/server/routes/revision.js on lines 110..113
src/server/routes/revision.js on lines 115..118
src/server/routes/revision.js on lines 135..138
src/server/routes/revision.js on lines 149..152
src/server/routes/revision.js on lines 163..166
src/server/routes/revision.js on lines 172..175

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

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

    if (_.isEqual(change.path, ['editionStatus']) ||
            _.isEqual(change.path, ['editionStatus', 'label'])) {
        return baseFormatter.formatTypeChange(change, 'Edition Status');
    }
Severity: Major
Found in src/server/routes/revision.js and 8 other locations - About 55 mins to fix
src/server/routes/revision.js on lines 62..65
src/server/routes/revision.js on lines 67..70
src/server/routes/revision.js on lines 72..75
src/server/routes/revision.js on lines 110..113
src/server/routes/revision.js on lines 135..138
src/server/routes/revision.js on lines 149..152
src/server/routes/revision.js on lines 163..166
src/server/routes/revision.js on lines 172..175

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

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

    if (_.isEqual(change.path, ['workType']) ||
            _.isEqual(change.path, ['workType', 'label'])) {
        return baseFormatter.formatTypeChange(change, 'Work Type');
    }
Severity: Major
Found in src/server/routes/revision.js and 8 other locations - About 55 mins to fix
src/server/routes/revision.js on lines 62..65
src/server/routes/revision.js on lines 67..70
src/server/routes/revision.js on lines 72..75
src/server/routes/revision.js on lines 110..113
src/server/routes/revision.js on lines 115..118
src/server/routes/revision.js on lines 135..138
src/server/routes/revision.js on lines 149..152
src/server/routes/revision.js on lines 172..175

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

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

    if (_.isEqual(change.path, ['editionGroupType']) ||
            _.isEqual(change.path, ['editionGroupType', 'label'])) {
        return baseFormatter.formatTypeChange(change, 'Edition Group Type');
    }
Severity: Major
Found in src/server/routes/revision.js and 8 other locations - About 55 mins to fix
src/server/routes/revision.js on lines 62..65
src/server/routes/revision.js on lines 67..70
src/server/routes/revision.js on lines 72..75
src/server/routes/revision.js on lines 110..113
src/server/routes/revision.js on lines 115..118
src/server/routes/revision.js on lines 135..138
src/server/routes/revision.js on lines 149..152
src/server/routes/revision.js on lines 163..166

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

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

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

                <Col lg={3}>
                    <dl>
                        <AverageRating
                            averageRatings={averageRating}
                            reviewsCount={reviewsCount}
Severity: Major
Found in src/client/components/pages/entities/series.js and 2 other locations - About 55 mins to fix
src/client/components/pages/entities/edition-group.js on lines 64..71
src/client/components/pages/entities/work.js on lines 72..79

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

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

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

                <Col lg={3}>
                    <dl>
                        <AverageRating
                            averageRatings={averageRating}
                            reviewsCount={reviewsCount}
Severity: Major
Found in src/client/components/pages/entities/work.js and 2 other locations - About 55 mins to fix
src/client/components/pages/entities/edition-group.js on lines 64..71
src/client/components/pages/entities/series.js on lines 73..80

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

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

    if (_.isEqual(change.path, ['publisherType']) ||
            _.isEqual(change.path, ['publisherType', 'label'])) {
        return baseFormatter.formatTypeChange(change, 'Publisher Type');
    }
Severity: Major
Found in src/server/routes/revision.js and 8 other locations - About 55 mins to fix
src/server/routes/revision.js on lines 62..65
src/server/routes/revision.js on lines 67..70
src/server/routes/revision.js on lines 72..75
src/server/routes/revision.js on lines 110..113
src/server/routes/revision.js on lines 115..118
src/server/routes/revision.js on lines 149..152
src/server/routes/revision.js on lines 163..166
src/server/routes/revision.js on lines 172..175

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

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 relationshipsFilterMethod(relatedEntity) {
            if (req.query.orderingtype) {
                return toLower(relatedEntity.seriesOrderingType) === toLower(req.query.orderingtype);
            }
            return true;
Severity: Minor
Found in src/api/routes/series.js and 1 other location - About 55 mins to fix
src/api/routes/author.js on lines 328..334

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

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 relationshipsFilterMethod(relatedEntity) {
            if (req.query.type) {
                return toLower(relatedEntity.authorType) === toLower(req.query.type);
            }

Severity: Minor
Found in src/api/routes/author.js and 1 other location - About 55 mins to fix
src/api/routes/series.js on lines 304..309

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

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

async function processMarathoner(orm, editorId) {
    const rowCount = await getConsecutiveDaysWithEdits(orm, editorId, 29);
    const tiers = [{
        name: 'Marathoner',
        threshold: 30,
Severity: Minor
Found in src/server/helpers/achievement.js and 1 other location - About 55 mins to fix
src/server/helpers/achievement.js on lines 419..429

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

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

async function processFunRunner(orm, editorId) {
    const rowCount = await getConsecutiveDaysWithEdits(orm, editorId, 6);
    const tiers = [
        {
            name: 'Fun Runner',
Severity: Minor
Found in src/server/helpers/achievement.js and 1 other location - About 55 mins to fix
src/server/helpers/achievement.js on lines 431..439

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

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

export function format(
    change, setProp, itemProp, newSetFormatter, addDeleteFormatter,
    modifyFormatter
) {
    const setAdded =
Severity: Minor
Found in src/server/helpers/diffFormatters/set.js - About 55 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 reducer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function reducer(
    state = Immutable.Map({
        canEdit: true,
        lastRelationships: null,
        relationshipEditorProps: null,
Severity: Minor
Found in src/client/entity-editor/relationship-editor/reducer.js - About 55 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 render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    render() {
        let messageComponent = null;
        if (this.state.message.text) {
            messageComponent = (
                <div>
Severity: Minor
Found in src/client/components/pages/parts/add-to-collection-modal.js - About 55 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 diffRevisionsWithParents has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function diffRevisionsWithParents(orm, entityRevisions, entityType) {
    // entityRevisions - collection of *entityType*_revisions matching id
    const promises = entityRevisions.map(
        async (revision) => {
            const dataId = revision.get('dataId');
Severity: Minor
Found in src/server/routes/revision.js - About 55 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 handleAddToCollection has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    handleAddToCollection() {
        const selectedEntities = this.state.selected;
        if (selectedEntities.length) {
            const areAllEntitiesOfSameType = selectedEntities.every(entity => entity.type === selectedEntities[0].type);
            const entityTypes = ['Author', 'Edition', 'EditionGroup', 'Publisher', 'Series', 'Work'];
Severity: Minor
Found in src/client/components/pages/parts/search-results.js - About 55 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