bookbrainz/bookbrainz-site

View on GitHub

Showing 1,033 of 1,033 total issues

Function fetchOptions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    async fetchOptions(query) {
        if (!query) {
            return {
                options: []
            };
Severity: Minor
Found in src/client/entity-editor/common/entity-search-field-option.js - 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 collectionCreateOrEditHandler has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export async function collectionCreateOrEditHandler(req, res, next) {
    try {
        const {UserCollection, UserCollectionCollaborator} = req.app.locals.orm;
        const isNew = !res.locals.collection;
        let newCollection;
Severity: Minor
Found in src/server/helpers/collectionRouteUtils.js - 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 editionGroupToFormState has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export function editionGroupToFormState(editionGroup) {
    /** The front-end expects a language id rather than the language object. */
    const aliases = editionGroup.aliasSet ?
        editionGroup.aliasSet.aliases.map(({languageId, ...rest}) => ({
            ...rest,
Severity: Minor
Found in src/server/routes/entity/edition-group.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 crossSliceReducer has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function crossSliceReducer(state:State, action:Action) {
    const {type} = action;
    let intermediateState = state;
    const activeEntityState = {
        aliasEditor: state.get('aliasEditor'),
Severity: Minor
Found in src/client/unified-form/helpers.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 unflatten has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export function unflatten(flattenObj) {
    const result = {};
    let cur;
    let prop;
    let parts;
Severity: Minor
Found in src/common/helpers/utils.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 displayEntity has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export function displayEntity(req: PassportRequest, res: $Response) {
    const {orm}: {orm?: any} = req.app.locals;
    const {AchievementUnlock, EditorEntityVisits} = orm;
    const {locals: resLocals}: {locals: any} = res;
    const {entity}: {entity: any} = resLocals;
Severity: Minor
Found in src/server/routes/entity/entity.tsx - 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 getBrowsedRelationships has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export async function getBrowsedRelationships(orm, locals, browsedEntityType,
                                              getEntityInfoMethod, fetchRelated, filterRelationshipMethod) {
    const {entity, relationships} = locals;

    if (!relationships.length > 0) {
Severity: Minor
Found in src/api/helpers/utils.js - 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 mapDispatchToProps has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function mapDispatchToProps(dispatch: Dispatch<Action>): DispatchProps {
    return {
        onAuthorCreditChange: (selectedAuthorCredit:AuthorCredit) => {
            dispatch(updateAuthorCredit(selectedAuthorCredit));
        },
Severity: Minor
Found in src/client/entity-editor/edition-section/edition-section-merge.tsx - 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 dateObjectToISOString has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export function dateObjectToISOString(value: DateObject) {
    if (_.isNil(value) || isNullDate(value)) {
        return null;
    }
    // if year is missing or not a number, return invalid date
Severity: Minor
Found in src/client/helpers/utils.tsx - 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 triggerSearch has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    triggerSearch(newFrom = this.state.from, newSize = this.state.size) {
        const searchParams = new URLSearchParams(this.props.querySearchParams);
        searchParams.set('size', newSize);
        searchParams.set('from', newFrom);
        const newSearchParamsString = `?${searchParams.toString()}`;
Severity: Minor
Found in src/client/components/pages/parts/pager.js - About 1 hr to fix

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

        render() {
            return (
                <div id="pageWithPagination">
                    <CollectionsTable
                        entityTypes={this.props.entityTypes}
    Severity: Minor
    Found in src/client/components/pages/collections.js - About 1 hr to fix

      Function testTiers has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function testTiers(orm, signal, editorId, tiers) {
          const tierPromise = tiers.map(async (tier) => {
              if (signal >= tier.threshold) {
                  try {
                      const achievementUnlock = await awardAchievement(orm, editorId, tier.name);
      Severity: Minor
      Found in src/server/helpers/achievement.js - About 1 hr to fix

        Function renderRelationship has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function renderRelationship(relationship: Relationship) {
            const inputsInvalid =
                !relationship.source || !relationship.target ||
                !isString(get(relationship, 'type.linkPhrase'));
            if (inputsInvalid) {
        Severity: Minor
        Found in src/server/helpers/render.ts - About 1 hr to fix

          Function fetchAccessToken has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export async function fetchAccessToken(
              code: string,
              editorId: number,
              orm: Record<string, any>
          ) : Promise<any> {
          Severity: Minor
          Found in src/server/helpers/critiquebrainz.ts - About 1 hr to fix

            Function handleSubmit has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                const handleSubmit = useCallback(async (event: FormEvent<HTMLFormElement>) => {
                    event.preventDefault();
                    if (!isValid()) {
                        setShowIncompleteFormError(true);
                        return;
            Severity: Minor
            Found in src/client/components/forms/type-editor/relationship-type.tsx - About 1 hr to fix

              Function transformISODateForDisplay has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function transformISODateForDisplay(ISODateString) {
                  if (_isNil(ISODateString)) {
                      return ISODateString;
                  }
                  const dateStringWithoutSign = ISODateString.slice(1);
              Severity: Minor
              Found in src/client/helpers/entity.tsx - About 1 hr to fix

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

                EditionGroupDisplayPage.propTypes = {
                    entity: PropTypes.object.isRequired,
                    identifierTypes: PropTypes.array,
                    user: PropTypes.object.isRequired,
                    wikipediaExtract: PropTypes.object
                Severity: Major
                Found in src/client/components/pages/entities/edition-group.js and 4 other locations - About 1 hr to fix
                src/client/components/pages/entities/author.js on lines 214..219
                src/client/components/pages/entities/edition.js on lines 201..206
                src/client/components/pages/entities/publisher.js on lines 127..132
                src/client/components/pages/entities/work.js on lines 177..182

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

                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

                EditionDisplayPage.propTypes = {
                    entity: PropTypes.object.isRequired,
                    identifierTypes: PropTypes.array,
                    user: PropTypes.object.isRequired,
                    wikipediaExtract: PropTypes.object
                Severity: Major
                Found in src/client/components/pages/entities/edition.js and 4 other locations - About 1 hr to fix
                src/client/components/pages/entities/author.js on lines 214..219
                src/client/components/pages/entities/edition-group.js on lines 184..189
                src/client/components/pages/entities/publisher.js on lines 127..132
                src/client/components/pages/entities/work.js on lines 177..182

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

                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

                PublisherDisplayPage.propTypes = {
                    entity: PropTypes.object.isRequired,
                    identifierTypes: PropTypes.array,
                    user: PropTypes.object.isRequired,
                    wikipediaExtract: PropTypes.object
                Severity: Major
                Found in src/client/components/pages/entities/publisher.js and 4 other locations - About 1 hr to fix
                src/client/components/pages/entities/author.js on lines 214..219
                src/client/components/pages/entities/edition-group.js on lines 184..189
                src/client/components/pages/entities/edition.js on lines 201..206
                src/client/components/pages/entities/work.js on lines 177..182

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

                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

                WorkDisplayPage.propTypes = {
                    entity: PropTypes.object.isRequired,
                    identifierTypes: PropTypes.array,
                    user: PropTypes.object.isRequired,
                    wikipediaExtract: PropTypes.object
                Severity: Major
                Found in src/client/components/pages/entities/work.js and 4 other locations - About 1 hr to fix
                src/client/components/pages/entities/author.js on lines 214..219
                src/client/components/pages/entities/edition-group.js on lines 184..189
                src/client/components/pages/entities/edition.js on lines 201..206
                src/client/components/pages/entities/publisher.js on lines 127..132

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

                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