BookBrainz/bookbrainz-site

View on GitHub

Showing 171 of 837 total issues

Function validateBBIDsForCollectionAdd has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export async function validateBBIDsForCollectionAdd(req, res, next) {
    const {Entity} = req.app.locals.orm;
    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 55 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 reducer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function reducer(
    state = Immutable.Map({
        canEdit: true,
        lastRelationships: null,
        relationshipEditorProps: null,
Severity: Minor
Found in src/client/entity-editor/relationship-editor/reducer.js - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
Open

    render() {
        let messageComponent = null;
        if (this.state.message.text) {
            messageComponent = (
                <div>
Severity: Minor
Found in src/client/components/pages/parts/add-to-collection-modal.js - About 55 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 getDefaultAliasIndex has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export function getDefaultAliasIndex(aliasSet) {
    if (_.isNil(aliasSet)) {
        return null;
    }
    const {aliases, defaultAliasId} = aliasSet;
Severity: Minor
Found in src/server/routes/entity/entity.tsx - About 55 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 formatEntityChange has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function formatEntityChange(entity, change) {
    const aliasChanged =
        _.isEqual(change.path, ['aliasSet']) ||
        _.isEqual(change.path.slice(0, 2), ['aliasSet', 'aliases']) ||
        _.isEqual(change.path.slice(0, 2), ['aliasSet', 'defaultAlias']);
Severity: Minor
Found in src/server/helpers/diffFormatters/entity.js - About 55 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 formatAuthorChange has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function formatAuthorChange(change) {
    if (_.isEqual(change.path, ['beginDate'])) {
        return baseFormatter.formatScalarChange(change, 'Begin Date');
    }

Severity: Minor
Found in src/server/routes/revision.js - About 55 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 ISODateStringToObject has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export function ISODateStringToObject(value: string | DateObject): DateObject {
    if (!_.isString(value)) {
        if (_.isPlainObject(value) && _.has(value, 'year')) {
            return value;
        }
Severity: Minor
Found in src/client/helpers/utils.tsx - About 55 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 ContentTab has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export function ContentTab({works, onChange, onModalClose, onModalOpen, onSeriesChange, series,
     onAddSeriesItem, onSubmitWork, resetSeries, bulkAddSeriesItems, ...rest}:ContentTabProps) {
    const [isChecked, setIsChecked] = React.useState(true);
    const [copyToSeries, setCopyToSeries] = React.useState(false);
    const toggleCheck = React.useCallback(() => {
Severity: Minor
Found in src/client/unified-form/content-tab/content-tab.tsx - About 55 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 formatEditionChange has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function formatEditionChange(change) {
    if (_.isEqual(change.path, ['editionGroupBbid'])) {
        return baseFormatter.formatScalarChange(change, 'EditionGroup');
    }

Severity: Minor
Found in src/server/routes/revision.js - About 45 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 IdentifierButton has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function IdentifierButton({
    identifiersInvalid,
    numIdentifiers,
    isUnifiedForm,
    ...props
Severity: Minor
Found in src/client/entity-editor/button-bar/identifier-button.js - About 45 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 deleteRelationships has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export async function deleteRelationships(orm: any, transacting: Transaction, mainEntity: any) {
    const mainBBID = mainEntity.bbid;
    const {relationshipSet} = mainEntity;
    const otherBBIDs = [];
    const otherEntities = [];
Severity: Minor
Found in src/server/routes/entity/entity.tsx - About 45 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 formatRelationship has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function formatRelationship(entity, change) {
    if (change.kind === 'N') {
        return formatAddOrDeleteRelationshipSet(entity, change);
    }
    if (change.kind === 'A') {
Severity: Minor
Found in src/server/helpers/diffFormatters/entity.js - About 45 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 EditionTableRow has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function EditionTableRow({edition, showAddedAtColumn, showAuthorCreditsColumn, showCheckboxes, selectedEntities, onToggleRow}) {
    const name = getEntityLabel(edition);
    const disambiguation = getEntityDisambiguation(edition);
    const number = edition.number || '?';
    const releaseDate = getEditionReleaseDate(edition);
Severity: Minor
Found in src/client/components/pages/entities/edition-table.js - About 45 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 validateEditionSectionPublisher has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function validateEditionSectionPublisher(value: any): boolean {
    if (!value) {
        return true;
    }
    const publishers = convertMapToObject(value);
Severity: Minor
Found in src/client/entity-editor/validators/edition.ts - About 45 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 processMergeOperation has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

export async function processMergeOperation(orm, transacting, session, mainEntity, allEntities, relationshipSets) {
Severity: Minor
Found in src/server/routes/entity/entity.tsx - About 45 mins to fix

    Function getBrowsedRelationships has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    export async function getBrowsedRelationships(orm, locals, browsedEntityType,
                                                  getEntityInfoMethod, fetchRelated, filterRelationshipMethod) {
    Severity: Minor
    Found in src/api/helpers/utils.js - About 45 mins to fix

      Function validateCollectionParams has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function validateCollectionParams(req, res, next) {
          const {collaborators = [], name, entityType} = req.body;
          const {orm} = req.app.locals;
          const {Editor} = orm;
      
      
      Severity: Minor
      Found in src/server/helpers/middleware.ts - About 45 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 awardTitle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      async function awardTitle(orm, editorId, tier) {
          const {TitleType, TitleUnlock} = orm;
          if (tier.titleName) {
              const title = await new TitleType({title: tier.titleName})
                  .fetch({require: false});
      Severity: Minor
      Found in src/server/helpers/achievement.js - About 45 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 AuthorCreditSection has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function AuthorCreditSection({
          authorCreditEditor: immutableAuthorCreditEditor, onEditAuthorCredit, onEditorClose,
          showEditor, onAuthorChange, isEditable, authorCreditEnable, toggleAuthorCreditEnable,
          onClearHandler, isUnifiedForm, isLeftAlign, ...rest
      }: Props) {
      Severity: Minor
      Found in src/client/entity-editor/author-credit-editor/author-credit-section.tsx - About 45 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 dateIsBefore has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export function dateIsBefore(beginValue: string | DateObject, endValue: string | DateObject): boolean {
          const beginDateObject = ISODateStringToObject(beginValue);
          const endDateObject = ISODateStringToObject(endValue);
          if (isNullDate(beginDateObject) || isNullDate(endDateObject) || !validateDate(beginDateObject).isValid ||
              !validateDate(endDateObject).isValid) {
      Severity: Minor
      Found in src/client/entity-editor/validators/base.ts - About 45 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

      Severity
      Category
      Status
      Source
      Language