bookbrainz/bookbrainz-site

View on GitHub

Showing 1,033 of 1,033 total issues

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

                        <FormControl
                            className="other-date-field"
                            maxLength="2"
                            placeholder="DD"
                            type="text"
Severity: Major
Found in src/client/entity-editor/common/new-date-field.js and 1 other location - About 1 hr to fix
src/client/entity-editor/common/new-date-field.js on lines 154..162

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

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

                        <FormControl
                            className="other-date-field"
                            maxLength="2"
                            placeholder="MM"
                            type="text"
Severity: Major
Found in src/client/entity-editor/common/new-date-field.js and 1 other location - About 1 hr to fix
src/client/entity-editor/common/new-date-field.js on lines 166..174

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

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 SeriesEditor({baseEntity, relationshipTypes, seriesType, orderType, onRemove, hideItemSelect,
    onAdd, onEdit, onSort, seriesItemsArray, isUnifiedForm}:SeriesItemsProps) {
    const [seriesItem, setSeriesItem] = useState(null);
    const [targetEntity, setTargetEntity] = useState(null);

Severity: Major
Found in src/client/entity-editor/series-section/series-editor.tsx and 1 other location - About 1 hr to fix
src/client/entity-editor/publisher-section/publisher-section-merge.tsx on lines 105..194

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

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 credits = editionGroup.authorCredit ? editionGroup.authorCredit.names.map(
        ({author, ...rest}) => ({
            author: utils.entityToOption(author),
            ...rest
        })
Severity: Major
Found in src/server/routes/entity/edition-group.ts and 1 other location - About 1 hr to fix
src/server/routes/entity/edition.ts on lines 436..441

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

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 PublisherSectionMerge({
    areaValue,
    beginDateValue,
    endDateValue,
    endedChecked,
src/client/entity-editor/series-section/series-editor.tsx on lines 144..256

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

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 credits = edition.authorCredit ? edition.authorCredit.names.map(
        ({author, ...rest}) => ({
            author: utils.entityToOption(author),
            ...rest
        })
Severity: Major
Found in src/server/routes/entity/edition.ts and 1 other location - About 1 hr to fix
src/server/routes/entity/edition-group.ts on lines 311..316

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

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 toggleExpand(identifierTypeId) {
        setExpandedIdentifierTypeIds((prevExpandedIds) => {
            if (prevExpandedIds.includes(identifierTypeId)) {
                return prevExpandedIds.filter((id) => id !== identifierTypeId);
            }
Severity: Major
Found in src/client/components/pages/parts/identifier-types-tree.tsx and 1 other location - About 1 hr to fix
src/client/components/pages/parts/relationship-types-tree.tsx on lines 34..41

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

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 toggleExpand(relTypeId) {
        setExpandedRelationshipTypeIds((prevExpandedIds) => {
            if (prevExpandedIds.includes(relTypeId)) {
                return prevExpandedIds.filter((id) => id !== relTypeId);
            }
src/client/components/pages/parts/identifier-types-tree.tsx on lines 33..40

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

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

    renderNavContent() {
        const {homepage, hideSearch, user} = this.props;

        /*
         * GOTCHA: Usage of react-bootstrap FormGroup component inside
Severity: Minor
Found in src/client/containers/layout.js - About 1 hr to fix

    Function reducer has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function reducer(
        state: State = Immutable.OrderedMap(),
        action
    ) {
        const {type, payload} = action;
    Severity: Minor
    Found in src/client/entity-editor/identifier-editor/reducer.ts - About 1 hr to fix

      Function submitReviewToCB has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export async function submitReviewToCB(
          accessToken: string,
          review: Record<string, any>
      ): Promise<any> {
          const cbEntityType = mapEntityType[review.entityType];
      Severity: Minor
      Found in src/server/helpers/critiquebrainz.ts - About 1 hr to fix

        Function testTiers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        async function testTiers(orm, signal, editorId, tiers) {
            const tierPromise = tiers.map(async (tier) => {
                if (signal >= tier.threshold) {
                    try {
                        const achievementUnlock = await awardAchievement(orm, editorId, tier.name);
        Severity: Minor
        Found in src/server/helpers/achievement.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 handleCreateMultipleEntities has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function handleCreateMultipleEntities(
            req: PassportRequest,
            res: $Response
        ) {
            const {orm}: {orm?: any} = req.app.locals;
        Severity: Minor
        Found in src/server/routes/entity/process-unified-form.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 getAssociatedEntityRevisions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function getAssociatedEntityRevisions(revisions, orm) {
            const revisionIDs = revisions.map(({revisionId}) => revisionId);
            const RevisionModels = getRevisionModels(orm);
            const {Entity} = orm;
            for (let i = 0; i < RevisionModels.length; i++) {
        Severity: Minor
        Found in src/server/helpers/revisions.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 processMergeOperation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function processMergeOperation(orm, transacting, session, mainEntity, allEntities, relationshipSets) {
            const {Edition, bookshelf} = orm;
            const {mergingEntities} = session.mergeQueue;
            if (!mergingEntities) {
                throw new Error('Merge handler called with no merge queue, aborting');
        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 constructPrivsChangeStatement has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function constructPrivsChangeStatement(logData: AdminLogDataT) {
            const {newPrivs, oldPrivs, targetUserId, targetUser, adminId, admin} = logData;
            const {privsAdded, privsRemoved} = getPrivsChanged(newPrivs, oldPrivs);
        
            let grantStatement = '';
        Severity: Minor
        Found in src/client/helpers/adminLogs.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 getOrderedCollectionsForEditorPage has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export async function getOrderedCollectionsForEditorPage(from, size, entityType, req) {
            const {Editor, UserCollection} = req.app.locals.orm;
            // If editor isn't present, throw an error
            await new Editor({id: req.params.id})
                .fetch()
        Severity: Minor
        Found in src/server/helpers/collections.js - About 1 hr to fix

          Function handleSubmit has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              handleSubmit(evt) {
                  evt.preventDefault();
                  if (!this.isValid()) {
                      this.setState({
                          errorText: 'Incomplete Form'
          Severity: Minor
          Found in src/client/components/forms/userCollection.js - About 1 hr to fix

            Function formatEntityChange has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function formatEntityChange(entity, change) {
                const aliasChanged =
                    _.isEqual(change.path, ['aliasSet']) ||
                    _.isEqual(change.path.slice(0, 2), ['aliasSet', 'aliases']) ||
                    _.isEqual(change.path.slice(0, 2), ['aliasSet', 'defaultAlias']);
            Severity: Minor
            Found in src/server/helpers/diffFormatters/entity.js - About 1 hr to fix

              Function entityDeletePromise has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  const entityDeletePromise = bookshelf.transaction(async (transacting) => {
                      if (!body.note || !body.note.length) {
                          throw new error.FormSubmissionError('A revision note is required when deleting an entity');
                      }
              
              
              Severity: Minor
              Found in src/server/routes/entity/entity.tsx - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language