BookBrainz/bookbrainz-site

View on GitHub
src/api/routes/edition.js

Summary

Maintainability
D
1 day
Test Coverage

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

        function relationshipsFilterMethod(relatedEntity) {
            let editionFormatMatched = true;
            let editionLanguageMatched = true;
            if (req.query.format) {
                editionFormatMatched = toLower(relatedEntity.editionFormat) === toLower(req.query.format);
Severity: Major
Found in src/api/routes/edition.js and 1 other location - About 4 hrs to fix
src/api/routes/work.js on lines 331..341

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

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

router.get('/:bbid/aliases',
    makeEntityLoader('Edition', utils.aliasesRelations, editionError),
    async (req, res) => {
        const editionAliasesList = await getEntityAliases(res.locals.entity);
        return res.status(200).send(editionAliasesList);
Severity: Major
Found in src/api/routes/edition.js and 17 other locations - About 1 hr to fix
src/api/routes/author.js on lines 172..177
src/api/routes/author.js on lines 207..212
src/api/routes/author.js on lines 243..248
src/api/routes/edition-group.js on lines 160..165
src/api/routes/edition-group.js on lines 197..202
src/api/routes/edition-group.js on lines 235..240
src/api/routes/edition.js on lines 231..236
src/api/routes/edition.js on lines 267..272
src/api/routes/publisher.js on lines 175..180
src/api/routes/publisher.js on lines 212..217
src/api/routes/publisher.js on lines 249..254
src/api/routes/series.js on lines 154..159
src/api/routes/series.js on lines 190..195
src/api/routes/series.js on lines 226..231
src/api/routes/work.js on lines 172..177
src/api/routes/work.js on lines 209..214
src/api/routes/work.js on lines 247..252

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

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

router.get('/:bbid/relationships',
    makeEntityLoader('Edition', utils.relationshipsRelations, editionError),
    async (req, res) => {
        const editionRelationshipList = await getEntityRelationships(res.locals.entity);
        return res.status(200).send(editionRelationshipList);
Severity: Major
Found in src/api/routes/edition.js and 17 other locations - About 1 hr to fix
src/api/routes/author.js on lines 172..177
src/api/routes/author.js on lines 207..212
src/api/routes/author.js on lines 243..248
src/api/routes/edition-group.js on lines 160..165
src/api/routes/edition-group.js on lines 197..202
src/api/routes/edition-group.js on lines 235..240
src/api/routes/edition.js on lines 195..200
src/api/routes/edition.js on lines 231..236
src/api/routes/publisher.js on lines 175..180
src/api/routes/publisher.js on lines 212..217
src/api/routes/publisher.js on lines 249..254
src/api/routes/series.js on lines 154..159
src/api/routes/series.js on lines 190..195
src/api/routes/series.js on lines 226..231
src/api/routes/work.js on lines 172..177
src/api/routes/work.js on lines 209..214
src/api/routes/work.js on lines 247..252

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

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

router.get('/:bbid/identifiers',
    makeEntityLoader('Edition', utils.identifiersRelations, editionError),
    async (req, res) => {
        const editionIdentifiersList = await getEntityIdentifiers(res.locals.entity);
        return res.status(200).send(editionIdentifiersList);
Severity: Major
Found in src/api/routes/edition.js and 17 other locations - About 1 hr to fix
src/api/routes/author.js on lines 172..177
src/api/routes/author.js on lines 207..212
src/api/routes/author.js on lines 243..248
src/api/routes/edition-group.js on lines 160..165
src/api/routes/edition-group.js on lines 197..202
src/api/routes/edition-group.js on lines 235..240
src/api/routes/edition.js on lines 195..200
src/api/routes/edition.js on lines 267..272
src/api/routes/publisher.js on lines 175..180
src/api/routes/publisher.js on lines 212..217
src/api/routes/publisher.js on lines 249..254
src/api/routes/series.js on lines 154..159
src/api/routes/series.js on lines 190..195
src/api/routes/series.js on lines 226..231
src/api/routes/work.js on lines 172..177
src/api/routes/work.js on lines 209..214
src/api/routes/work.js on lines 247..252

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

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

router.get('/:bbid',
    makeEntityLoader('Edition', editionBasicRelations, editionError),
    async (req, res) => {
        const editionBasicInfo = await getEditionBasicInfo(res.locals.entity);
        return res.status(200).send(editionBasicInfo);
Severity: Major
Found in src/api/routes/edition.js and 5 other locations - About 1 hr to fix
src/api/routes/author.js on lines 135..140
src/api/routes/edition-group.js on lines 123..128
src/api/routes/publisher.js on lines 139..144
src/api/routes/series.js on lines 117..122
src/api/routes/work.js on lines 133..138

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

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

            editionsJSON.map(edition => getEditionBasicInfo(edition))
                .filter(relationshipsFilterMethod)
                .forEach((filteredEdition) => {
                    // added relationship to make the output consistent
                    editionRelationshipList.push({entity: filteredEdition, relationship: {}});
Severity: Major
Found in src/api/routes/edition.js and 2 other locations - About 1 hr to fix
src/api/routes/edition.js on lines 389..394
src/api/routes/publisher.js on lines 364..369

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

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

            editions.map(edition => getEditionBasicInfo(edition))
                .filter(relationshipsFilterMethod)
                .forEach((filteredEdition) => {
                    // added relationship to make the output consistent
                    editionRelationshipList.push({entity: filteredEdition, relationship: {}});
Severity: Major
Found in src/api/routes/edition.js and 2 other locations - About 1 hr to fix
src/api/routes/edition.js on lines 404..409
src/api/routes/publisher.js on lines 364..369

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

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

There are no issues that match your filters.

Category
Status