BookBrainz/bookbrainz-site

View on GitHub

Showing 171 of 837 total issues

Function RelationshipTypeEditor has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

function RelationshipTypeEditor({relationshipTypeData, parentTypes, attributeTypes}: RelationshipTypeEditorPropsT) {
    const [formData, setFormData] = useState<RelationshipTypeDataT>(relationshipTypeData);

    // State for the ParentType modal
    const [showModal, setShowModal] = useState<boolean>(false);
Severity: Minor
Found in src/client/components/forms/type-editor/relationship-type.tsx - About 4 hrs 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 dateValidator has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

export function dateValidator(dayObj, monthObj, yearObj) {
    const year = Number.parseInt(yearObj, 10);
    const month = Number.parseInt(monthObj, 10);
    const day = Number.parseInt(dayObj, 10);

Severity: Minor
Found in src/client/entity-editor/validators/date.js - About 3 hrs 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 SingleEntityCard has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

export default function SingleEntityCard({entity, languageOptions}:SingleEntityCardProps) {
    const id2LanguageMap = React.useMemo(() => Object.fromEntries(_.map(languageOptions, (option) => [option.id, option.name])), []);
    // display formatted entity attributes in modal
    function renderField(path, key) {
        let fieldVal = _.get(entity, path, '');
Severity: Minor
Found in src/client/unified-form/submit-tab/single-entity-card.tsx - About 3 hrs 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 IdentifierTypeEditor has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

function IdentifierTypeEditor({identifierTypeData, parentTypes}: IdentifierTypeEditorPropsT) {
    const [formData, setFormData] = useState<IdentifierTypeDataT>(identifierTypeData);

    // State for the ParentType modal
    const [showModal, setShowModal] = useState<boolean>(false);
Severity: Minor
Found in src/client/components/forms/type-editor/identifier-type.tsx - About 3 hrs 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 entitiesToFormState has a Cognitive Complexity of 18 (exceeds 5 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: Minor
Found in src/server/routes/merge.ts - About 2 hrs 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 17 (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) {
Severity: Minor
Found in src/client/components/pages/parts/search-results.js - About 2 hrs 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 SeriesEditor has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function SeriesEditor({baseEntity, relationshipTypes, seriesType, orderType, onRemove, hideItemSelect,
    onAdd, onEdit, onSort, seriesItemsArray, isUnifiedForm}:SeriesItemsProps) {
    const [seriesItem, setSeriesItem] = useState(null);
    const [targetEntity, setTargetEntity] = useState(null);

Severity: Minor
Found in src/client/entity-editor/series-section/series-editor.tsx - About 2 hrs 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 17 (exceeds 5 allowed). Consider refactoring.
Open

function mapDispatchToProps(dispatch: Dispatch<Action>): DispatchProps {
    return {
        onDepthChange: (event) => dispatch(debouncedUpdateDepth(
            event.target.value ? parseInt(event.target.value, 10) : null
        )),
Severity: Minor
Found in src/client/entity-editor/edition-section/edition-section.tsx - About 2 hrs 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 16 (exceeds 5 allowed). Consider refactoring.
Open

    render() {
        const {showLastModified, showOwner, showIfOwnerOrCollaborator, showPrivacy, results, tableHeading, user, ownerId} = this.props;
        const entityTypeSelect = (
            <DropdownButton
                className="margin-bottom-d5"
Severity: Minor
Found in src/client/components/pages/parts/collections-table.js - About 2 hrs 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 _fetchEntityModelsForESResults has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

async function _fetchEntityModelsForESResults(orm, results) {
    const {Area, Editor, UserCollection} = orm;

    if (!results?.hits) {
        return null;
Severity: Minor
Found in src/common/helpers/search.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 validateUnifiedForm has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

function validateUnifiedForm(body:Record<string, any>):boolean {
    for (const entityKey in body) {
        if (Object.prototype.hasOwnProperty.call(body, entityKey)) {
            const entityForm = body[entityKey];
            const entityType = _.camelCase(entityForm.type);
Severity: Minor
Found in src/server/helpers/entityRouteUtils.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 EditionSection has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function EditionSection({
    depthValue,
    editionFormats,
    editionStatuses,
    formatValue,
Severity: Minor
Found in src/client/entity-editor/edition-section/edition-section.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 getEntityRelationships has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export function getEntityRelationships(entity: any) {
    return _.isNil(entity) ? null :
        {
            bbid: _.get(entity, 'bbid', null),
            relationships: _.get(entity, 'relationshipSet.relationships', []).map((relationship) => {
Severity: Minor
Found in src/api/helpers/formatEntityData.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 processMergeOperation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export async function processMergeOperation(orm, transacting, session, mainEntity, allEntities, relationshipSets) {
    const {Edition, bookshelf} = orm;
    const {mergingEntities} = session.mergeQueue;
    if (!mergingEntities) {
        throw new Error('Merge handler called with no merge queue, aborting');
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 testTiers has a Cognitive Complexity of 12 (exceeds 5 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

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

export async function handleCreateMultipleEntities(
    req: PassportRequest,
    res: $Response
) {
    const {orm}: {orm?: any} = req.app.locals;
Severity: Minor
Found in src/server/routes/entity/process-unified-form.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 getAssociatedEntityRevisions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export async function getAssociatedEntityRevisions(revisions, orm) {
    const revisionIDs = revisions.map(({revisionId}) => revisionId);
    const RevisionModels = getRevisionModels(orm);
    const {Entity} = orm;
    for (let i = 0; i < RevisionModels.length; i++) {
Severity: Minor
Found in src/server/helpers/revisions.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 constructPrivsChangeStatement has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function constructPrivsChangeStatement(logData: AdminLogDataT) {
    const {newPrivs, oldPrivs, targetUserId, targetUser, adminId, admin} = logData;
    const {privsAdded, privsRemoved} = getPrivsChanged(newPrivs, oldPrivs);

    let grantStatement = '';
Severity: Minor
Found in src/client/helpers/adminLogs.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 getProgress has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

async function getProgress(achievementId, editorId, orm) {
    const revisionist = [1, 2, 3];
    if (revisionist.includes(achievementId)) {
        const {Editor} = orm;
        const editor = await new Editor({id: editorId})
Severity: Minor
Found in src/server/routes/editor.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 render has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    render() {
        const messageComponent =
            this.state.message.text ? (
                <Alert
                    className="margin-top-1"
Severity: Minor
Found in src/client/components/pages/collection.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

Severity
Category
Status
Source
Language