bookbrainz/bookbrainz-site

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

Summary

Maintainability
C
1 day
Test Coverage

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

router.get('/:bbid/identifiers',
    makeEntityLoader('Author', utils.identifiersRelations, authorError),
    async (req, res) => {
        const authorIdentifiersList = await getEntityIdentifiers(res.locals.entity);
        return res.status(200).send(authorIdentifiersList);
Severity: Major
Found in src/api/routes/author.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 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/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/aliases',
    makeEntityLoader('Author', utils.aliasesRelations, authorError),
    async (req, res) => {
        const authorAliasesList = await getEntityAliases(res.locals.entity);
        return res.status(200).send(authorAliasesList);
Severity: Major
Found in src/api/routes/author.js and 17 other locations - About 1 hr to fix
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/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('Author', utils.relationshipsRelations, authorError),
    async (req, res) => {
        const authorRelationshipList = await getEntityRelationships(res.locals.entity);
        return res.status(200).send(authorRelationshipList);
Severity: Major
Found in src/api/routes/author.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/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/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('Author', authorBasicRelations, authorError),
    async (req, res) => {
        const authorBasicInfo = await getAuthorBasicInfo(res.locals.entity);
        return res.status(200).send(authorBasicInfo);
Severity: Major
Found in src/api/routes/author.js and 5 other locations - About 1 hr to fix
src/api/routes/edition-group.js on lines 123..128
src/api/routes/edition.js on lines 159..164
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 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

There are no issues that match your filters.

Category
Status