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

    constructor(message) {
        super();

        /*
         * We can't access the subclass's default message before calling super,
Severity: Major
Found in src/common/helpers/error.js and 1 other location - About 1 hr to fix
src/common/helpers/error.js on lines 173..183

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

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

    constructor(message) {
        super();

        /*
         * We can't access the subclass's default message before calling super,
Severity: Major
Found in src/common/helpers/error.js and 1 other location - About 1 hr to fix
src/common/helpers/error.js 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 61.

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

EditionGroupTable.propTypes = {
    editionGroups: PropTypes.array.isRequired,
    onToggleRow: PropTypes.func,
    selectedEntities: PropTypes.array,
    showAddedAtColumn: PropTypes.bool,
Severity: Major
Found in src/client/components/pages/entities/editionGroup-table.js and 1 other location - About 1 hr to fix
src/client/components/pages/parts/revisions-table.js on lines 146..152

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

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

RevisionsTable.propTypes = {
    results: PropTypes.array.isRequired,
    showEntities: PropTypes.bool,
    showRevisionEditor: PropTypes.bool,
    showRevisionNote: PropTypes.bool,
Severity: Major
Found in src/client/components/pages/parts/revisions-table.js and 1 other location - About 1 hr to fix
src/client/components/pages/entities/editionGroup-table.js on lines 120..126

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

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

                    if (relationship.sourceBbid === entityBBID) {
                        accumulator.push(relationship.targetBbid);
                    }
                    else if (relationship.targetBbid === entityBBID) {
                        accumulator.push(relationship.sourceBbid);
Severity: Major
Found in src/server/routes/entity/entity.tsx and 1 other location - About 1 hr to fix
src/server/routes/entity/entity.tsx on lines 356..361

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

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

            if (relationship.sourceBbid === mainBBID) {
                otherBBIDs.push(relationship.targetBbid);
            }
            else if (relationship.targetBbid === mainBBID) {
                otherBBIDs.push(relationship.sourceBbid);
Severity: Major
Found in src/server/routes/entity/entity.tsx and 1 other location - About 1 hr to fix
src/server/routes/entity/entity.tsx on lines 548..553

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

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

async function getLast30DaysEntities(orm) {
    try {
        const entityModels = commonUtils.getEntityModels(orm);
        const countPromises = Object.keys(entityModels).map(async (modelName) => {
            const model = entityModels[modelName];
Severity: Minor
Found in src/server/routes/statistics.js - About 1 hr to fix

    Function ReviewCard has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function ReviewCard(props) {
        if (!props?.reviewData || _.isEmpty(props.reviewData)) {
            return null;
        }
        const {reviewData} = props;
    Severity: Minor
    Found in src/client/components/pages/entities/cb-review.js - About 1 hr to fix

      Function formatEditionChange has 32 lines of code (exceeds 25 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 1 hr to fix

        Function addInitialRelationship has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function addInitialRelationship(props, relationshipTypeId, relationshipIndex, targetEntity) {
            // Prepend 'i' here to indicate initail relationship row identifier
            const rowId = `i${relationshipIndex || 0}`;
            const relationship = props.relationshipTypes.find(
                relationshipType => relationshipType.id === relationshipTypeId
        Severity: Minor
        Found in src/server/helpers/entityRouteUtils.tsx - About 1 hr to fix

          Function getEditorActivity has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export async function getEditorActivity(editorId, startDate, Revision, endDate = Date.now()) {
              if (!isValid(startDate)) {
                  throw new Error('Start date is invalid');
              }
              if (!isValid(endDate)) {
          Severity: Minor
          Found in src/server/routes/editor.tsx - About 1 hr to fix

            Function render has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                render() {
                    const messageComponent =
                        this.state.message.text ? (
                            <Alert
                                className="margin-top-1"
            Severity: Minor
            Found in src/client/components/pages/collection.js - About 1 hr 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 processSingleEntity has a Cognitive Complexity of 11 (exceeds 5 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: Minor
            Found in src/server/routes/entity/entity.tsx - About 1 hr 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 editionToFormState has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            export function editionToFormState(edition) {
                /** The front-end expects a language id rather than the language object. */
                const aliases = edition.aliasSet ?
                    edition.aliasSet.aliases.map(({languageId, ...rest}) => ({
                        ...rest,
            Severity: Minor
            Found in src/server/routes/entity/edition.ts - About 1 hr 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 processEditionSets has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            async function processEditionSets(
                orm: any,
                currentEntity: Record<string, unknown> | null | undefined,
                body: ProcessEditionSetsBody,
                transacting: Transaction
            Severity: Minor
            Found in src/server/routes/entity/entity.tsx - About 1 hr 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 getProgress has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            async function getProgress(achievementId, editorId, orm) {
                const revisionist = [1, 2, 3];
                if (revisionist.includes(achievementId)) {
                    const {Editor} = orm;
                    const editor = await new Editor({id: editorId})
            Severity: Minor
            Found in src/server/routes/editor.tsx - About 1 hr 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 addAuthorCreditRow has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function addAuthorCreditRow(state, newItemKey) {
                // Add a new empty author credit row
                let returnedState = state.set(newItemKey, EMPTY_CREDIT_ROW);
            
                const autoJoinPhraseRegex = /^(| & |, )$/;
            Severity: Minor
            Found in src/client/entity-editor/author-credit-editor/reducer.ts - About 1 hr 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 10 locations. Consider refactoring.
            Open

                            <Col lg={3}>
                                <dl>
                                    <dt>Type</dt>
                                    <dd>{type}</dd>
                                </dl>
            Severity: Major
            Found in src/client/components/pages/entities/publisher.js and 9 other locations - About 1 hr to fix
            src/client/components/pages/entities/edition-group.js on lines 52..57
            src/client/components/pages/entities/edition-group.js on lines 58..63
            src/client/components/pages/entities/edition.js on lines 94..99
            src/client/components/pages/entities/publisher.js on lines 49..54
            src/client/components/pages/entities/publisher.js on lines 61..66
            src/client/components/pages/entities/series.js on lines 49..54
            src/client/components/pages/entities/work.js on lines 54..59
            src/client/components/pages/entities/work.js on lines 60..65
            src/client/components/pages/entities/work.js on lines 66..71

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

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

                            <Col lg={3}>
                                <dl>
                                    <dt>Language</dt>
                                    <dd>{languages}</dd>
                                </dl>
            Severity: Major
            Found in src/client/components/pages/entities/work.js and 9 other locations - About 1 hr to fix
            src/client/components/pages/entities/edition-group.js on lines 52..57
            src/client/components/pages/entities/edition-group.js on lines 58..63
            src/client/components/pages/entities/edition.js on lines 94..99
            src/client/components/pages/entities/publisher.js on lines 49..54
            src/client/components/pages/entities/publisher.js on lines 55..60
            src/client/components/pages/entities/publisher.js on lines 61..66
            src/client/components/pages/entities/series.js on lines 49..54
            src/client/components/pages/entities/work.js on lines 54..59
            src/client/components/pages/entities/work.js on lines 60..65

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

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

                            <Col lg={3}>
                                <dl>
                                    <dt>Area</dt>
                                    <dd>{area}</dd>
                                </dl>
            Severity: Major
            Found in src/client/components/pages/entities/publisher.js and 9 other locations - About 1 hr to fix
            src/client/components/pages/entities/edition-group.js on lines 52..57
            src/client/components/pages/entities/edition-group.js on lines 58..63
            src/client/components/pages/entities/edition.js on lines 94..99
            src/client/components/pages/entities/publisher.js on lines 49..54
            src/client/components/pages/entities/publisher.js on lines 55..60
            src/client/components/pages/entities/series.js on lines 49..54
            src/client/components/pages/entities/work.js on lines 54..59
            src/client/components/pages/entities/work.js on lines 60..65
            src/client/components/pages/entities/work.js on lines 66..71

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

            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