bookbrainz/bookbrainz-site

View on GitHub

Showing 1,033 of 1,033 total issues

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

router.get(
    '/:bbid/edit', auth.isAuthenticated, auth.isAuthorized(ENTITY_EDITOR), middleware.loadIdentifierTypes,
    middleware.loadEditionGroupTypes, middleware.loadLanguages,
     middleware.loadEntityRelationships, middleware.loadRelationshipTypes,
    (req, res) => {
Severity: Major
Found in src/server/routes/entity/edition-group.ts and 3 other locations - About 4 hrs to fix
src/server/routes/entity/publisher.ts on lines 336..352
src/server/routes/entity/series.ts on lines 328..344
src/server/routes/entity/work.ts on lines 348..364

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

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

function HelpPage(): JSX.Element {
    const IRCLink = 'https://kiwiirc.com/nextclient/irc.libera.chat/?#bookbrainz';
    const userGuideLink =
        'https://bookbrainz-user-guide.readthedocs.io/';

Severity: Major
Found in src/client/components/pages/help.tsx - About 4 hrs to fix

    File middleware.ts has 367 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * Copyright (C) 2015       Ben Ockmore
     *               2015-2016  Sean Burke
     *               2021       Akash Gupta
     *               2022       Ansh Goyal
    Severity: Minor
    Found in src/server/helpers/middleware.ts - About 4 hrs to fix

      Function crossSliceReducer has 118 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function crossSliceReducer(state:State, action:Action) {
          const {type} = action;
          let intermediateState = state;
          const activeEntityState = {
              aliasEditor: state.get('aliasEditor'),
      Severity: Major
      Found in src/client/unified-form/helpers.ts - About 4 hrs to fix

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

            render() {
                const {revision, diffs, user} = this.props;
                let regularDiffs = diffs;
                let mergeDiffDivs;
        
        
        Severity: Major
        Found in src/client/components/pages/revision.js - About 4 hrs to fix

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

              render() {
                  const {
                      disambiguationDefaultValue,
                      entityType,
                      exactMatches: immutableExactMatches,
          Severity: Major
          Found in src/client/entity-editor/name-section/name-section.js - About 4 hrs to fix

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

                if (entity.authorCredit) {
                    authorCreditSection = (
                        <AuthorCreditDisplay
                            names={entity.authorCredit.names}
                        />
            Severity: Major
            Found in src/client/components/pages/entities/edition-group.js and 1 other location - About 4 hrs to fix
            src/client/components/pages/entities/edition.js on lines 119..133

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

            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 (entity.authorCredit) {
                    authorCreditSection = (
                        <AuthorCreditDisplay
                            names={entity.authorCredit.names}
                        />
            Severity: Major
            Found in src/client/components/pages/entities/edition.js and 1 other location - About 4 hrs to fix
            src/client/components/pages/entities/edition-group.js on lines 98..113

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

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

              function entitiesToFormState(entities: any[]) {
                  const [targetEntity, ...otherEntities] = entities;
                  const aliases: any[] = entities.reduce((returnValue, entity) => {
                      if (Array.isArray(_.get(entity, 'aliasSet.aliases'))) {
                          return returnValue.concat(
              Severity: Major
              Found in src/server/routes/merge.ts - About 4 hrs to fix

                Function SearchAdminPage has 111 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function SearchAdminPage() {
                    const [loading, setLoading] = useState(false);
                    const [errorMessage, setErrorMessage] = useState<string>();
                    const [success, setSuccess] = useState(false);
                    const indexEntity = useCallback(async (entityType?:string) => {
                Severity: Major
                Found in src/client/components/pages/searchAdmin.tsx - About 4 hrs to fix

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

                  export function createLimitedEdition() {
                      return new AchievementType(limitedEditionIAttribs)
                          .save(null, {method: 'insert'})
                          .then(
                              () => new AchievementType(limitedEditionIIAttribs)
                  Severity: Major
                  Found in data/test-data.js and 7 other locations - About 4 hrs to fix
                  data/test-data.js on lines 333..348
                  data/test-data.js on lines 350..365
                  data/test-data.js on lines 384..399
                  data/test-data.js on lines 401..416
                  data/test-data.js on lines 418..433
                  data/test-data.js on lines 435..450
                  data/test-data.js on lines 452..467

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

                  export function createExplorer() {
                      return new AchievementType(explorerIAttribs)
                          .save(null, {method: 'insert'})
                          .then(
                              () => new AchievementType(explorerIIAttribs)
                  Severity: Major
                  Found in data/test-data.js and 7 other locations - About 4 hrs to fix
                  data/test-data.js on lines 333..348
                  data/test-data.js on lines 350..365
                  data/test-data.js on lines 367..382
                  data/test-data.js on lines 384..399
                  data/test-data.js on lines 401..416
                  data/test-data.js on lines 418..433
                  data/test-data.js on lines 435..450

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

                  export function createRevisionist() {
                      return new AchievementType(revisionistIAttribs)
                          .save(null, {method: 'insert'})
                          .then(
                              () => new AchievementType(revisionistIIAttribs)
                  Severity: Major
                  Found in data/test-data.js and 7 other locations - About 4 hrs to fix
                  data/test-data.js on lines 350..365
                  data/test-data.js on lines 367..382
                  data/test-data.js on lines 384..399
                  data/test-data.js on lines 401..416
                  data/test-data.js on lines 418..433
                  data/test-data.js on lines 435..450
                  data/test-data.js on lines 452..467

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

                  export function createPublisher() {
                      return new AchievementType(publisherIAttribs)
                          .save(null, {method: 'insert'})
                          .then(
                              () => new AchievementType(publisherIIAttribs)
                  Severity: Major
                  Found in data/test-data.js and 7 other locations - About 4 hrs to fix
                  data/test-data.js on lines 333..348
                  data/test-data.js on lines 350..365
                  data/test-data.js on lines 367..382
                  data/test-data.js on lines 401..416
                  data/test-data.js on lines 418..433
                  data/test-data.js on lines 435..450
                  data/test-data.js on lines 452..467

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

                  export function createAuthorCreator() {
                      return new AchievementType(authorCreatorIAttribs)
                          .save(null, {method: 'insert'})
                          .then(
                              () => new AchievementType(authorCreatorIIAttribs)
                  Severity: Major
                  Found in data/test-data.js and 7 other locations - About 4 hrs to fix
                  data/test-data.js on lines 333..348
                  data/test-data.js on lines 367..382
                  data/test-data.js on lines 384..399
                  data/test-data.js on lines 401..416
                  data/test-data.js on lines 418..433
                  data/test-data.js on lines 435..450
                  data/test-data.js on lines 452..467

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

                  export function createWorkerBee() {
                      return new AchievementType(workerBeeIAttribs)
                          .save(null, {method: 'insert'})
                          .then(
                              () => new AchievementType(workerBeeIIAttribs)
                  Severity: Major
                  Found in data/test-data.js and 7 other locations - About 4 hrs to fix
                  data/test-data.js on lines 333..348
                  data/test-data.js on lines 350..365
                  data/test-data.js on lines 367..382
                  data/test-data.js on lines 384..399
                  data/test-data.js on lines 418..433
                  data/test-data.js on lines 435..450
                  data/test-data.js on lines 452..467

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

                  export function createSeriesCreator() {
                      return new AchievementType(seriesCreatorIAttribs)
                          .save(null, {method: 'insert'})
                          .then(
                              () => new AchievementType(seriesCreatorIIAttribs)
                  Severity: Major
                  Found in data/test-data.js and 7 other locations - About 4 hrs to fix
                  data/test-data.js on lines 333..348
                  data/test-data.js on lines 350..365
                  data/test-data.js on lines 367..382
                  data/test-data.js on lines 384..399
                  data/test-data.js on lines 401..416
                  data/test-data.js on lines 435..450
                  data/test-data.js on lines 452..467

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

                  export function createPublisherCreator() {
                      return new AchievementType(publisherCreatorIAttribs)
                          .save(null, {method: 'insert'})
                          .then(
                              () => new AchievementType(publisherCreatorIIAttribs)
                  Severity: Major
                  Found in data/test-data.js and 7 other locations - About 4 hrs to fix
                  data/test-data.js on lines 333..348
                  data/test-data.js on lines 350..365
                  data/test-data.js on lines 367..382
                  data/test-data.js on lines 384..399
                  data/test-data.js on lines 401..416
                  data/test-data.js on lines 418..433
                  data/test-data.js on lines 452..467

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

                      work.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/work.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/edition.ts on lines 513..522
                  src/server/routes/entity/publisher.ts on lines 309..318

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language