bookbrainz/bookbrainz-site

View on GitHub

Showing 365 of 1,033 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 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 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 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 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 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 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 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 renderBasicInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        renderBasicInfo() {
            const {user, editor} = this.props;
            const {
                cachedMetabrainzName,
                metabrainzUserId,
    Severity: Minor
    Found in src/client/components/pages/parts/editor-profile.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 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 format has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        change, setProp, itemProp, newSetFormatter, addDeleteFormatter,
        modifyFormatter
    Severity: Minor
    Found in src/server/helpers/diffFormatters/set.js - About 45 mins to fix

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

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

        export function CoverTab(props:CoverProps) {
            const {publisherValue: publishers, onPublisherChange, identifierEditorVisible,
                onClearPublisher, handleClearPublishers, modalIsOpen, ...rest} = props;
            const publisherValue:EntitySelect[] = Object.values(convertMapToObject(publishers ?? {}));
            const onChangeHandler = React.useCallback((value:EntitySelect[], action) => {
        Severity: Minor
        Found in src/client/unified-form/cover-tab/cover-tab.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 UnifiedForm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export function UnifiedForm(props:UnifiedFormProps) {
            const {allIdentifierTypes, validator, onSubmit, formValid,
                languageOptions, contentTabEmpty, coverTabValid, coverTabEmpty, detailTabValid, detailTabEmpty} = props;
            const rest = omit(props, ['contentTabEmpty', 'coverTabValid', 'coverTabEmpty', 'detailTabValid', 'formValid', 'detailTabEmpty']);
            React.useMemo(() => {
        Severity: Minor
        Found in src/client/unified-form/unified-form.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 SearchAdminPage has a Cognitive Complexity of 8 (exceeds 5 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: Minor
        Found in src/client/components/pages/searchAdmin.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

        Severity
        Category
        Status
        Source
        Language