bookbrainz/bookbrainz-site

View on GitHub

Showing 365 of 1,033 total issues

Function workToFormState has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function workToFormState(work) {
    /** The front-end expects a language id rather than the language object. */
    const aliases = work.aliasSet ?
        work.aliasSet.aliases.map(({languageId, ...rest}) => ({
            ...rest,
Severity: Minor
Found in src/server/routes/entity/work.ts - About 35 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

Function checkConfigOverwrite has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function checkConfigOverwrite() {
    const args = process.argv;
    const configIndex = args.indexOf('--config');

    // Check for '--config' followed by 'configPathFile'
Severity: Minor
Found in src/common/helpers/config.js - About 35 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

Function generateEntityProps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function generateEntityProps(
    entityType: string,
    req: PassportRequest, res: $Response,
    additionalProps: any,
    initialStateCallback: (entity: any) => any = () => new Object()
Severity: Minor
Found in src/server/helpers/entityRouteUtils.tsx - About 35 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

Function loadSeriesItems has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function loadSeriesItems(req: $Request, res: $Response, next: NextFunction) {
    try {
        const {entity} = res.locals;
        if (entity.dataId) {
            const {relationships} = entity;
Severity: Minor
Found in src/server/helpers/middleware.ts - About 35 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

Function validateBBIDsForCollectionRemove has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function validateBBIDsForCollectionRemove(req, res, next) {
    const {bbids = []} = req.body;
    if (!bbids.length) {
        return next(new error.BadRequestError('BBIDs array is empty'));
    }
Severity: Minor
Found in src/server/helpers/middleware.ts - About 35 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

Function parseLanguages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export async function parseLanguages(sourceEntitySection:Record<string, any>, orm):Promise<Record<string, any>> {
    if (!sourceEntitySection) { return sourceEntitySection; }
    const {Language} = orm;
    const languages = [];
    for (const langKey in sourceEntitySection) {
Severity: Minor
Found in src/server/helpers/utils.ts - About 35 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

Function getValidOtherEntityTypes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function getValidOtherEntityTypes(
    relTypes: Array<RelationshipType>,
    baseEntity: Entity
) {
    let relationshipTypes = relTypes;
Severity: Minor
Found in src/client/entity-editor/relationship-editor/relationship-editor.tsx - About 35 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

Function AuthorCreditRow has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function AuthorCreditRow({
    index,
    author,
    joinPhrase,
    name,
Severity: Minor
Found in src/client/entity-editor/author-credit-editor/author-credit-row.tsx - About 35 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

Function getPrivsChanged has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function getPrivsChanged(newPrivs: number, oldPrivs: number) {
    const privsRemoved = [];
    const privsAdded = [];
    const totalBits = Object.keys(PrivilegeTypes).length;

Severity: Minor
Found in src/client/helpers/adminLogs.tsx - About 35 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

Function render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    render() {
        const noResults = !this.props.results || this.props.results.length === 0;
        const results = this.props.results.map((result) => {
            if (!result) {
                return null;
Severity: Minor
Found in src/client/components/pages/parts/admin-panel-search-results.tsx - About 35 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

Function getEntityLabel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function getEntityLabel(entity, returnHTML = true) {
    if (entity.defaultAlias) {
        return `${entity.defaultAlias.name}`;
    }

Severity: Minor
Found in src/client/helpers/entity.tsx - About 35 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

Avoid too many return statements within this function.
Open

    return null;
Severity: Major
Found in src/server/helpers/diffFormatters/entity.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return baseFormatter.formatScalarChange(
                change, _.startCase(change.path[0])
            );
    Severity: Major
    Found in src/server/routes/revision.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return formatChangedAnnotation(change);
      Severity: Major
      Found in src/server/helpers/diffFormatters/entity.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return {errorMessage: 'Month is not valid', isValid: false};
        Severity: Major
        Found in src/client/entity-editor/validators/date.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return null;
          Severity: Major
          Found in src/server/helpers/diffFormatters/entity.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return authorCreditFormatter.format(change);
            Severity: Major
            Found in src/server/helpers/diffFormatters/entity.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return baseFormatter.formatAreaChange(change, 'End Area');
              Severity: Major
              Found in src/server/routes/revision.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return baseFormatter.formatScalarChange(change, 'Page Count');
                Severity: Major
                Found in src/server/routes/revision.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return null;
                  Severity: Major
                  Found in src/server/routes/revision.js - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language