bookbrainz/bookbrainz-site

View on GitHub

Showing 365 of 1,033 total issues

Function getEditorActivity has 32 lines of code (exceeds 25 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 1 hr to fix

    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

    Function processSingleEntity has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function processSingleEntity(formBody, JSONEntity, reqSession,
        entityType, orm:any, editorJSON, derivedProps, isMergeOperation, transacting):Promise<any> {
        const {Entity, Revision} = orm;
        let body = sanitizeBody(formBody);
        let currentEntity: {
    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 editionToFormState has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export function editionToFormState(edition) {
        /** The front-end expects a language id rather than the language object. */
        const aliases = edition.aliasSet ?
            edition.aliasSet.aliases.map(({languageId, ...rest}) => ({
                ...rest,
    Severity: Minor
    Found in src/server/routes/entity/edition.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 processEditionSets has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    async function processEditionSets(
        orm: any,
        currentEntity: Record<string, unknown> | null | undefined,
        body: ProcessEditionSetsBody,
        transacting: Transaction
    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 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 addAuthorCreditRow has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function addAuthorCreditRow(state, newItemKey) {
        // Add a new empty author credit row
        let returnedState = state.set(newItemKey, EMPTY_CREDIT_ROW);
    
        const autoJoinPhraseRegex = /^(| & |, )$/;
    Severity: Minor
    Found in src/client/entity-editor/author-credit-editor/reducer.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 mapDispatchToProps has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function mapDispatchToProps(dispatch, {submissionUrl}):ContentTabDispatchProps {
        const type = 'Work';
        return {
            bulkAddSeriesItems: (data) => dispatch(addBulkSeriesItems(data)),
            onAddSeriesItem: (data) => dispatch(addSeriesItem(data, data.rowID)),
    Severity: Minor
    Found in src/client/unified-form/content-tab/content-tab.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 RegistrationAuth has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function RegistrationAuth() {
        return (
            <div>
                <div className="page-header"><h1>Register</h1></div>
                <p>
    Severity: Minor
    Found in src/client/components/pages/registration-auth.js - About 1 hr to fix

      Function renderDuplicateAlert has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          renderDuplicateAlert(warnIfExists, disambiguationDefaultValue, exactMatches, entityType, lgCol) {
              return (
                  <Col lg={lgCol}>
                      {isRequiredDisambiguationEmpty(
                          warnIfExists,
      Severity: Minor
      Found in src/client/entity-editor/name-section/name-section.js - About 1 hr to fix

        Function transformNewForm has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function transformNewForm(data) {
            const aliases = entityRoutes.constructAliases(
                data.aliasEditor, data.nameSection
            );
        
        
        Severity: Minor
        Found in src/server/routes/entity/edition-group.ts - About 1 hr to fix

          Function dateIsBefore has 31 lines of code (exceeds 25 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 1 hr to fix

            Function render has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                render() {
                    const option = this.getSafeOptionValue(this.props.data);
                    const {disambiguation, text, type, unnamedText, language, authors, __isNew__} = option;
                    const nameComponent = text || <i>{unnamedText}</i>;
                    const externalLinkComponent = !__isNew__ &&
            Severity: Minor
            Found in src/client/entity-editor/common/linked-entity.tsx - About 1 hr to fix

              Function renderActivityGraph has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  renderActivityGraph() {
                      const {activityData, totalRevisions} = this.props.editor;
                      const months = keys(activityData);
                      const numberOfRevisions = values(activityData);
              
              
              Severity: Minor
              Found in src/client/components/pages/parts/editor-profile.js - About 1 hr to fix

                Function handleRemoveEntities has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    handleRemoveEntities() {
                        if (this.state.selectedEntities.length) {
                            const bbids = this.state.selectedEntities;
                            const submissionUrl = `/collection/${this.props.collection.id}/remove`;
                            request.post(submissionUrl)
                Severity: Minor
                Found in src/client/components/pages/collection.js - About 1 hr to fix

                  Function getOrderedRevisionsForEntityPage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export async function getOrderedRevisionsForEntityPage(orm: any, from: number, size: number, RevisionModel, bbid: string) {
                      const otherMergedBBIDs = await recursivelyGetMergedEntitiesBBIDs(orm, [bbid]);
                  
                      const revisions = await new RevisionModel()
                          .query((qb) => {
                  Severity: Minor
                  Found in src/server/helpers/revisions.ts - About 1 hr to fix

                    Function makeSortName has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function makeSortName(name: string): string {
                        const articles = ['a', 'an', 'the', 'los', 'las', 'el', 'la'];
                        const suffixes = [
                            'i', 'ii', 'iii', 'iv', 'v', 'vi', 'vii', 'viii', 'ix', 'x', 'xi',
                            'xii', 'xiii', 'xiv', 'xv', 'jr', 'junior', 'sr', 'senior', 'phd', 'md',
                    Severity: Minor
                    Found in src/client/entity-editor/common/sort-name-field.tsx - About 1 hr to fix

                      Function getOrderedRevisionForEditorPage has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export async function getOrderedRevisionForEditorPage(from, size, req) {
                          const {Editor, Revision} = req.app.locals.orm;
                      
                          // If editor isn't present, throw an error
                          await new Editor({id: req.params.id})
                      Severity: Minor
                      Found in src/server/helpers/revisions.ts - About 1 hr to fix

                        Function addAuthorCreditRow has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function addAuthorCreditRow(state, newItemKey) {
                            // Add a new empty author credit row
                            let returnedState = state.set(newItemKey, EMPTY_CREDIT_ROW);
                        
                            const autoJoinPhraseRegex = /^(| & |, )$/;
                        Severity: Minor
                        Found in src/client/entity-editor/author-credit-editor/reducer.ts - About 1 hr to fix

                          Function processSingleEntity has 9 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          export async function processSingleEntity(formBody, JSONEntity, reqSession,
                              entityType, orm:any, editorJSON, derivedProps, isMergeOperation, transacting):Promise<any> {
                          Severity: Major
                          Found in src/server/routes/entity/entity.tsx - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language