bookbrainz/bookbrainz-site

View on GitHub
src/server/routes/entity/edition.ts

Summary

Maintainability
F
6 days
Test Coverage

File edition.ts has 459 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (C) 2015       Ben Ockmore
 *               2015-2016  Sean Burke
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Minor
Found in src/server/routes/entity/edition.ts - About 7 hrs to fix

    Function editionToFormState has 111 lines of code (exceeds 25 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: Major
    Found in src/server/routes/entity/edition.ts - About 4 hrs to fix

      Function render has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              async function render(props) {
                  const {initialState} = props;
                  initialState.nameSection = {
                      disambiguation: '',
                      exactMatches: null,
      Severity: Major
      Found in src/server/routes/entity/edition.ts - About 2 hrs to fix

        Function transformNewForm has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function transformNewForm(data) {
            const aliases = entityRoutes.constructAliases(
                data.aliasEditor, data.nameSection
            );
        
        
        Severity: Major
        Found in src/server/routes/entity/edition.ts - About 2 hrs to fix

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

          export function transformNewForm(data) {
              const aliases = entityRoutes.constructAliases(
                  data.aliasEditor, data.nameSection
              );
          
          
          Severity: Minor
          Found in src/server/routes/entity/edition.ts - About 25 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

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

              edition.relationships.forEach((relationship) => (
                  relationshipSection.relationships[`n${relationship.id}`] = {
                      attributeSetId: relationship.attributeSetId,
                      attributes: relationship.attributeSet ? relationship.attributeSet.relationshipAttributes : [],
                      relationshipType: relationship.type,
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 4 other locations - About 4 hrs to fix
          src/server/routes/entity/author.ts on lines 306..315
          src/server/routes/entity/edition-group.ts on lines 295..304
          src/server/routes/entity/publisher.ts on lines 309..318
          src/server/routes/entity/work.ts on lines 321..330

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

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

                  if (req.query.work) {
                      propsPromise.work =
                          Work.forge({bbid: req.query.work})
                              .fetch({require: false, withRelated: 'defaultAlias'})
                              .then((data) => data && utils.entityToOption(data.toJSON()));
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 3 other locations - About 3 hrs to fix
          src/server/routes/entity/edition.ts on lines 184..189
          src/server/routes/entity/work.ts on lines 110..115
          src/server/routes/entity/work.ts on lines 117..122

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

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

                  if (req.query.publisher) {
                      propsPromise.publisher =
                          Publisher.forge({bbid: req.query.publisher})
                              .fetch({require: false, withRelated: 'defaultAlias'})
                              .then((data) => data && utils.entityToOption(data.toJSON()));
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 3 other locations - About 3 hrs to fix
          src/server/routes/entity/edition.ts on lines 191..196
          src/server/routes/entity/work.ts on lines 110..115
          src/server/routes/entity/work.ts on lines 117..122

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

          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

              if (!authorCreditEnable) {
                  authorCredit = null;
              }
              else if (!_.isNil(data.authorCredit)) {
                  // When merging entities, we use a separate reducer "authorCredit"
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 1 other location - About 3 hrs to fix
          src/server/routes/entity/edition-group.ts on lines 67..76

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

          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

                  function render(props) {
                      const editorMarkup = entityEditorMarkup(props);
                      const {markup} = editorMarkup;
                      const updatedProps = editorMarkup.props;
                      return res.send(target({
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 1 other location - About 2 hrs to fix
          src/server/routes/entity/work.ts on lines 188..199

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

          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.post(
              '/:bbid/delete/handler', auth.isAuthenticatedForHandler, auth.isAuthorized(ENTITY_EDITOR),
              (req, res) => {
                  const {orm} = req.app.locals;
                  const {EditionHeader, EditionRevision} = orm;
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 5 other locations - About 2 hrs to fix
          src/server/routes/entity/author.ts on lines 226..235
          src/server/routes/entity/edition-group.ts on lines 220..229
          src/server/routes/entity/publisher.ts on lines 232..241
          src/server/routes/entity/series.ts on lines 221..230
          src/server/routes/entity/work.ts on lines 245..254

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

          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/delete', auth.isAuthenticated, auth.isAuthorized(ENTITY_EDITOR), (req, res, next) => {
              if (!res.locals.entity.dataId) {
                  return next(new ConflictError('This entity has already been deleted'));
              }
              _setEditionTitle(res);
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 5 other locations - About 2 hrs to fix
          src/server/routes/entity/author.ts on lines 218..224
          src/server/routes/entity/edition-group.ts on lines 212..218
          src/server/routes/entity/publisher.ts on lines 224..230
          src/server/routes/entity/series.ts on lines 213..219
          src/server/routes/entity/work.ts on lines 237..243

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

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

          router.get('/:bbid/revisions/revisions', (req, res, next) => {
              const {EditionRevision} = req.app.locals.orm;
              _setEditionTitle(res);
              entityRoutes.updateDisplayedRevisions(req, res, next, EditionRevision);
          });
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 11 other locations - About 1 hr to fix
          src/server/routes/entity/author.ts on lines 237..241
          src/server/routes/entity/author.ts on lines 243..247
          src/server/routes/entity/edition-group.ts on lines 231..235
          src/server/routes/entity/edition-group.ts on lines 237..241
          src/server/routes/entity/edition.ts on lines 376..380
          src/server/routes/entity/publisher.ts on lines 243..247
          src/server/routes/entity/publisher.ts on lines 249..253
          src/server/routes/entity/series.ts on lines 232..236
          src/server/routes/entity/series.ts on lines 238..242
          src/server/routes/entity/work.ts on lines 256..260
          src/server/routes/entity/work.ts on lines 262..266

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

          router.get('/:bbid/revisions', (req, res, next) => {
              const {EditionRevision} = req.app.locals.orm;
              _setEditionTitle(res);
              entityRoutes.displayRevisions(req, res, next, EditionRevision);
          });
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 11 other locations - About 1 hr to fix
          src/server/routes/entity/author.ts on lines 237..241
          src/server/routes/entity/author.ts on lines 243..247
          src/server/routes/entity/edition-group.ts on lines 231..235
          src/server/routes/entity/edition-group.ts on lines 237..241
          src/server/routes/entity/edition.ts on lines 382..386
          src/server/routes/entity/publisher.ts on lines 243..247
          src/server/routes/entity/publisher.ts on lines 249..253
          src/server/routes/entity/series.ts on lines 232..236
          src/server/routes/entity/series.ts on lines 238..242
          src/server/routes/entity/work.ts on lines 256..260
          src/server/routes/entity/work.ts on lines 262..266

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

              const identifiers = edition.identifierSet ?
                  edition.identifierSet.identifiers.map(({type, ...rest}) => ({
                      type: type.id,
                      ...rest
                  })) : [];
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 5 other locations - About 1 hr to fix
          src/server/routes/entity/author.ts on lines 277..281
          src/server/routes/entity/edition-group.ts on lines 271..275
          src/server/routes/entity/publisher.ts on lines 283..287
          src/server/routes/entity/series.ts on lines 270..274
          src/server/routes/entity/work.ts on lines 295..299

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

          function _setEditionTitle(res) {
              res.locals.title = utils.createEntityPageTitle(
                  res.locals.entity,
                  'Edition',
                  utils.template`Edition “${'name'}”`
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 5 other locations - About 1 hr to fix
          src/server/routes/entity/author.ts on lines 205..211
          src/server/routes/entity/edition-group.ts on lines 198..204
          src/server/routes/entity/publisher.ts on lines 190..196
          src/server/routes/entity/series.ts on lines 199..205
          src/server/routes/entity/work.ts on lines 224..230

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

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

              const aliases = edition.aliasSet ?
                  edition.aliasSet.aliases.map(({languageId, ...rest}) => ({
                      ...rest,
                      language: languageId
                  })) : [];
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 4 other locations - About 1 hr to fix
          src/server/routes/entity/author.ts on lines 252..256
          src/server/routes/entity/edition-group.ts on lines 246..250
          src/server/routes/entity/publisher.ts on lines 258..262
          src/server/routes/entity/work.ts on lines 270..274

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

          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

                  languages: edition.languageSet ? edition.languageSet.languages.map(
                      ({id, name}) => ({label: name, value: id})
                  ) : [],
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 1 other location - About 1 hr to fix
          src/server/routes/entity/work.ts on lines 307..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 58.

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

                      if (entity.editionSection.format) {
                          entity.editionSection.format = await utils.getIdByField(EditionFormat, 'label', entity.editionSection.format);
                      }
          Severity: Major
          Found in src/server/routes/entity/edition.ts and 4 other locations - About 45 mins to fix
          src/server/routes/entity/author.ts on lines 160..162
          src/server/routes/entity/author.ts on lines 163..165
          src/server/routes/entity/publisher.ts on lines 147..149
          src/server/routes/entity/publisher.ts on lines 153..155

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

          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 (_.isEmpty(authorCreditEditor) && edition.creditSection) {
                  authorCreditEditor.n0 = {
                      author: null,
                      joinPhrase: '',
                      name: ''
          Severity: Minor
          Found in src/server/routes/entity/edition.ts and 1 other location - About 45 mins to fix
          src/server/routes/entity/edition-group.ts on lines 325..331

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

          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