bookbrainz/bookbrainz-site

View on GitHub

Showing 1,033 of 1,033 total issues

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

async function processWorkerBee(orm, editorId) {
    const {WorkRevision} = orm;
    const rowCount = await getTypeCreation(new WorkRevision(),
        'work_revision',
        editorId);
Severity: Major
Found in src/server/helpers/achievement.js and 5 other locations - About 3 hrs to fix
src/server/helpers/achievement.js on lines 238..257
src/server/helpers/achievement.js on lines 259..278
src/server/helpers/achievement.js on lines 280..301
src/server/helpers/achievement.js on lines 303..324
src/server/helpers/achievement.js on lines 349..370

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

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

    render() {
        let errorComponent = null;
        if (this.state.error) {
            errorComponent =
                <Alert variant="danger">{this.state.error}</Alert>;
Severity: Major
Found in src/client/components/forms/registration-details.js - About 3 hrs to fix

    Function transformFormData has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function transformFormData(data:Record<string, any>):Record<string, any> {
        const newData = {};
        const nextId = 0;
        // add new series
        _.forEach(data.Series, (series, sid) => {
    Severity: Major
    Found in src/client/entity-editor/submission-section/actions.ts - About 3 hrs to fix

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

      function mapStateToProps(rootState, {index}) {
          const state = rootState.get('aliasEditor');
          return {
              languageValue: state.getIn([index, 'language']),
              nameValue: state.getIn([index, 'name']),
      Severity: Major
      Found in src/client/entity-editor/alias-editor/alias-row-merge.js and 1 other location - About 3 hrs to fix
      src/client/entity-editor/alias-editor/alias-row.js on lines 171..179

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

      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 mapStateToProps(rootState, {index}) {
          const state = rootState.get('aliasEditor');
          return {
              languageValue: state.getIn([index, 'language']),
              nameValue: state.getIn([index, 'name']),
      Severity: Major
      Found in src/client/entity-editor/alias-editor/alias-row.js and 1 other location - About 3 hrs to fix
      src/client/entity-editor/alias-editor/alias-row-merge.js on lines 77..85

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

      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

      File collection.js has 299 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*
       * Copyright (C) 2020 Prabal Singh
       *
       * This program is free software; you can redistribute it and/or modify
       * it under the terms of the GNU General Public License as published by
      Severity: Minor
      Found in src/server/routes/collection.js - About 3 hrs to fix

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

            render() {
                const {onCancel, onClose, baseEntity} = this.props;
                const baseEntityTypeForDisplay = _.startCase(baseEntity.type);
                const submitDisabled = this.calculateProgressAmount() < 100;
                const entitySelect = this.renderEntitySelect();
        Severity: Major
        Found in src/client/entity-editor/relationship-editor/relationship-editor.tsx - About 3 hrs to fix

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

          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

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

                  if (req.query.author) {
                      propsPromise.author =
                          Author.forge({bbid: req.query.author})
                              .fetch({require: false, withRelated: 'defaultAlias'})
                              .then((data) => data && utils.entityToOption(data.toJSON()));
          Severity: Major
          Found in src/server/routes/entity/work.ts and 3 other locations - About 3 hrs to fix
          src/server/routes/entity/edition.ts on lines 184..189
          src/server/routes/entity/edition.ts on lines 191..196
          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 2 locations. Consider refactoring.
          Open

              const relationshipPromises = entity.relationships.map(async (relationship) => {
                  const [source, target] = await Promise.all([getEntityWithAlias(relationship.source), getEntityWithAlias(relationship.target)]);
                  relationship.source = source.toJSON();
                  relationship.target = target.toJSON();
          
          
          Severity: Major
          Found in src/server/helpers/middleware.ts and 1 other location - About 3 hrs to fix
          src/server/routes/merge.ts on lines 211..220

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

          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 relationships = await Promise.all(entity.relationships.map(async (relationship) => {
                      const [relationshipSource, relationshipTarget] = await Promise.all([
                          getEntityWithAlias(relationship.source),
                          getEntityWithAlias(relationship.target)
                      ]);
          Severity: Major
          Found in src/server/routes/merge.ts and 1 other location - About 3 hrs to fix
          src/server/helpers/middleware.ts on lines 164..170

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

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

          function IdentifierTypeEditor({identifierTypeData, parentTypes}: IdentifierTypeEditorPropsT) {
              const [formData, setFormData] = useState<IdentifierTypeDataT>(identifierTypeData);
          
              // State for the ParentType modal
              const [showModal, setShowModal] = useState<boolean>(false);
          Severity: Minor
          Found in src/client/components/forms/type-editor/identifier-type.tsx - About 3 hrs 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 SingleEntityCard has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function SingleEntityCard({entity, languageOptions}:SingleEntityCardProps) {
              const id2LanguageMap = React.useMemo(() => Object.fromEntries(_.map(languageOptions, (option) => [option.id, option.name])), []);
              // display formatted entity attributes in modal
              function renderField(path, key) {
                  let fieldVal = _.get(entity, path, '');
          Severity: Minor
          Found in src/client/unified-form/submit-tab/single-entity-card.tsx - About 3 hrs 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

          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

              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-group.ts and 1 other location - About 3 hrs to fix
          src/server/routes/entity/edition.ts on lines 90..99

          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

          Function EditorContainer has 76 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function EditorContainer(props) {
              const {tabActive, editor, children, user} = props;
          
              return (
                  <div>
          Severity: Major
          Found in src/client/containers/editor.js - About 3 hrs to fix

            File work.ts has 292 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/work.ts - About 3 hrs to fix

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

                  render() {
                      const ShowServiceOption = (optionData) => {
                          const {
                              service, value, title, details
                          } = optionData;
              Severity: Major
              Found in src/client/components/pages/externalService.js - About 3 hrs to fix
                Severity
                Category
                Status
                Source
                Language