bookbrainz/bookbrainz-site

View on GitHub

Showing 1,033 of 1,033 total issues

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

export function validateSeriesSection(data: any): boolean {
    return (
        validateSeriesSectionOrderingType(get(data, 'orderType', null)) &&
        validateSeriesSectionEntityType(get(data, 'seriesType', null))

Severity: Minor
Found in src/client/entity-editor/validators/series.ts and 2 other locations - About 35 mins to fix
src/client/entity-editor/validators/common.ts on lines 178..185
src/client/entity-editor/validators/work.ts on lines 41..46

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

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 3 locations. Consider refactoring.
Open

                <a className="contact-text" href="mailto:bookbrainz@metabrainz.org">
                    <FontAwesomeIcon
                        className="contact-text"
                        icon={faEnvelope}
                        size="2x"
Severity: Minor
Found in src/client/components/pages/about.tsx and 2 other locations - About 35 mins to fix
src/client/components/pages/about.tsx on lines 103..110
src/client/components/pages/about.tsx on lines 115..122

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

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 2 locations. Consider refactoring.
Open

                    <Tab eventKey="detail" title={<ValidationLabel hideIcon empty={detailTabEmpty} error={!detailTabValid}>Details</ValidationLabel>}>
                        <DetailTab {...rest}/>
                    </Tab>
Severity: Minor
Found in src/client/unified-form/unified-form.tsx and 1 other location - About 35 mins to fix
src/client/unified-form/unified-form.tsx on lines 66..68

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

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 2 locations. Consider refactoring.
Open

                    <Tab eventKey="cover" title={<ValidationLabel hideIcon empty={coverTabEmpty} error={!coverTabValid}>Cover</ValidationLabel>}>
                        <CoverTab {...rest} identifierTypes={editionIdentifierTypes as IdentifierType[]}/>
                    </Tab>
Severity: Minor
Found in src/client/unified-form/unified-form.tsx and 1 other location - About 35 mins to fix
src/client/unified-form/unified-form.tsx on lines 69..71

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

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 3 locations. Consider refactoring.
Open

export function validateSubmissionSection(
    data: any
): boolean {
    return (
        validateSubmissionSectionNote(get(data, 'note', null)) &&
Severity: Minor
Found in src/client/entity-editor/validators/common.ts and 2 other locations - About 35 mins to fix
src/client/entity-editor/validators/series.ts on lines 42..48
src/client/entity-editor/validators/work.ts on lines 41..46

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

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

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

function AuthorTableRow({author, showAddedAtColumn, showCheckboxes, selectedEntities, onToggleRow, genderOptions}) {
    const name = getEntityLabel(author);
    const disambiguation = getEntityDisambiguation(author);
    const number = author.number || '?';
    const authorType = author.authorType?.label || author.authorType || '?';
Severity: Minor
Found in src/client/components/pages/entities/author-table.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 formatAlias has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function formatAlias(change) {
    const aliasSetAdded =
        change.kind === 'N' && _.isEqual(change.path, ['aliasSet']);
    if (aliasSetAdded) {
        return formatNewAliasSet(change);
Severity: Minor
Found in src/server/helpers/diffFormatters/entity.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 render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    render() {
        let reviewContent;
        const mapEntityType = {
            Author: 'author',
            EditionGroup: 'edition-group',
Severity: Minor
Found in src/client/components/pages/entities/cb-review.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 EditionDisplayPage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) {
    // relationshipTypeId = 10 refers the relation (<Work> is contained by <Edition>)
    const relationshipTypeId = 10;
    const worksContainedByEdition = getRelationshipTargetByTypeId(entity, relationshipTypeId);
    const worksContainedByEditionWithAuthors = addAuthorsDataToWorks(entity.authorsData, worksContainedByEdition);
Severity: Minor
Found in src/client/components/pages/entities/edition.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 PublisherTableRow has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function PublisherTableRow({showAddedAtColumn, publisher, showCheckboxes, selectedEntities, onToggleRow}) {
    const name = getEntityLabel(publisher);
    const number = publisher.number || '?';
    const disambiguation = getEntityDisambiguation(publisher);
    const publisherType = publisher.publisherType ? publisher.publisherType.label : '?';
Severity: Minor
Found in src/client/components/pages/entities/publisher-table.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 WorkTableRow has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function WorkTableRow({showAddedAtColumn, work, showCheckboxes, selectedEntities, onToggleRow}) {
    const name = getEntityLabel(work);
    const authorData = work.authorsData;
    const number = work.number || '?';
    const disambiguation = getEntityDisambiguation(work);
Severity: Minor
Found in src/client/components/pages/entities/work-table.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 render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    render() {
        if (this.state.collaborators.length === 0) {
            this.handleAddCollaborator();
        }

Severity: Minor
Found in src/client/components/forms/userCollection.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 RevisionsTable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function RevisionsTable(props) {
    const {results, showEntities, showRevisionNote, showRevisionEditor, tableHeading} = props;
    return (
        <div>
            <div>
Severity: Minor
Found in src/client/components/pages/parts/revisions-table.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 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

Severity
Category
Status
Source
Language