bookbrainz/bookbrainz-site

View on GitHub

Showing 365 of 1,033 total issues

Avoid too many return statements within this function.
Open

        return out.rowCount;
Severity: Major
Found in src/server/routes/editor.tsx - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return getConsecutiveDaysWithEdits(orm, editorId, 6);
    Severity: Major
    Found in src/server/routes/editor.tsx - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return 'Unnamed';
      Severity: Major
      Found in src/client/helpers/entity.tsx - About 30 mins to fix

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

            render() {
                const {baseUrl, sourceUrl, originalUrl, formBody} = this.props;
                const formInputs = [];
                for (const field in formBody) {
                    if (Object.hasOwnProperty.call(formBody, field)) {
        Severity: Minor
        Found in src/client/components/forms/preview.js - About 25 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 EditionGroupTableRow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

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

            static getEntityDiff(diff) {
                let mergeBadge = null;
                let deleteBadge = null;
                if (diff.isDeletion) {
                    if (diff.entityRevision.isMerge) {
        Severity: Minor
        Found in src/client/components/pages/revision.js - About 25 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 formatIdentifier has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function formatIdentifier(change) {
            const identifierSetAdded =
                change.kind === 'N' && _.isEqual(change.path, ['identifierSet']);
            if (identifierSetAdded) {
                return formatNewIdentifierSet(change);
        Severity: Minor
        Found in src/server/helpers/diffFormatters/entity.js - About 25 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 handleSubmit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            async handleSubmit() {
                const {privs, note} = this.state;
                const oldPrivs = this.props.targetUser.privs;
                if (privs === oldPrivs) {
                    return;
        Severity: Minor
        Found in src/client/components/pages/parts/privs-edit-modal.js - About 25 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 getOrderedCollectionsForEditorPage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function getOrderedCollectionsForEditorPage(from, size, entityType, req) {
            const {Editor, UserCollection} = req.app.locals.orm;
            // If editor isn't present, throw an error
            await new Editor({id: req.params.id})
                .fetch()
        Severity: Minor
        Found in src/server/helpers/collections.js - About 25 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 getInitState has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function getInitState(
            baseEntity: Entity, initRelationship: _Relationship | null | undefined
        ): RelationshipModalState {
            if (_.isNull(initRelationship)) {
                return {
        Severity: Minor
        Found in src/client/entity-editor/relationship-editor/relationship-editor.tsx - About 25 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 seriesToFormState has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export function seriesToFormState(series) {
            const aliases = series.aliasSet ?
                series.aliasSet.aliases.map(({languageId, ...rest}) => ({
                    ...rest,
                    language: languageId
        Severity: Minor
        Found in src/server/routes/entity/series.ts - About 25 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 getCachedJSON has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function getCachedJSON<T>(cacheKey: string) {
            if (redisClient.isReady) {
                const cachedValue = await redisClient.get(cacheKey);
                if (cachedValue) {
                    try {
        Severity: Minor
        Found in src/common/helpers/cache.ts - About 25 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 SeriesSection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function SeriesSection({
            entity,
            entityName,
            entityType,
            hideItemSelect,
        Severity: Minor
        Found in src/client/entity-editor/series-section/series-section.tsx - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function reducer(
            state: State = Immutable.Map({
                orderType: 1,
                seriesItems: Immutable.OrderedMap(),
                seriesType: 'Work'
        Severity: Minor
        Found in src/client/entity-editor/series-section/reducer.ts - About 25 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 parseInitialState has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function parseInitialState(req, type):Promise<Record<string, any>> {
            const emptyState = {
                nameSection: {
                    disambiguation: '',
                    exactMatches: null,
        Severity: Minor
        Found in src/server/helpers/utils.ts - About 25 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 loadWikipediaExtract has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function loadWikipediaExtract(req: $Request, res: $Response, next: NextFunction) {
            const {entity} = res.locals;
            if (!entity) {
                return next(new error.SiteError('Failed to load entity'));
            }
        Severity: Minor
        Found in src/server/helpers/middleware.ts - About 25 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 preprocessForm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function preprocessForm(body:Record<string, any>, orm):Promise<Record<string, any>> {
            async function processForm(currentForm) {
                const {id, type} = currentForm;
                const isNew = _.get(currentForm, '__isNew__', true);
                // if new entity, no need to process further
        Severity: Minor
        Found in src/server/routes/entity/process-unified-form.ts - About 25 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 getEditorActivity has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function getEditorActivity(editorId, startDate, Revision, endDate = Date.now()) {
            if (!isValid(startDate)) {
                throw new Error('Start date is invalid');
            }
            if (!isValid(endDate)) {
        Severity: Minor
        Found in src/server/routes/editor.tsx - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function reducer(
            state: State = Immutable.OrderedMap(),
            action
        ) {
            const {type, payload} = action;
        Severity: Minor
        Found in src/client/entity-editor/identifier-editor/reducer.ts - About 25 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 validateForm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export function validateForm(
            formData: any, identifierTypes?: Array<_IdentifierType> | null | undefined,
            isMerge?:boolean
        ): boolean {
            let validAuthorCredit;
        Severity: Minor
        Found in src/client/entity-editor/validators/edition-group.ts - About 25 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