bookbrainz/bookbrainz-site

View on GitHub

Showing 365 of 1,033 total issues

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 relationshipTypeCreateOrEditHandler has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function relationshipTypeCreateOrEditHandler(req, res, next) {
    try {
        const {RelationshipType, RelationshipTypeAttributeType, bookshelf} = req.app.locals.orm;
        const trx = await bookshelf.transaction();
        let newRelationshipType;
Severity: Major
Found in src/server/helpers/typeRouteUtils.ts - About 2 hrs to fix

    File content-tab.tsx has 266 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import * as Bootstrap from 'react-bootstrap/';
    import {ContentTabDispatchProps, ContentTabProps, ContentTabStateProps, State} from '../interface/type';
    import {addBulkSeriesItems, addSeriesItem, removeAllSeriesItems, updateOrderType, updateSeriesType} from '../../entity-editor/series-section/actions';
    import {addSeries, addWork, duplicateWork, removeSeries} from './action';
    import {closeEntityModal, dumpEdition, loadEdition, openEntityModal} from '../action';
    Severity: Minor
    Found in src/client/unified-form/content-tab/content-tab.tsx - About 2 hrs to fix

      Function Footer has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Footer(props) {
          const {repositoryUrl, siteRevision} = props;
      
          return (
              <footer className="footer">
      Severity: Major
      Found in src/client/components/footer.js - About 2 hrs to fix

        Function UnifiedForm has 59 lines of code (exceeds 25 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: Major
        Found in src/client/unified-form/unified-form.tsx - About 2 hrs to fix

          Function renderBadges has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              renderBadges() {
                  const {achievement} = this.props;
                  let achievementBsSize = 12;
                  if (achievement.length === 1) {
                      achievementBsSize = 8;
          Severity: Major
          Found in src/client/components/pages/parts/editor-profile.js - About 2 hrs to fix

            Function handleCreateMultipleEntities has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export async function handleCreateMultipleEntities(
                req: PassportRequest,
                res: $Response
            ) {
                const {orm}: {orm?: any} = req.app.locals;
            Severity: Major
            Found in src/server/routes/entity/process-unified-form.ts - About 2 hrs to fix

              File author-section.tsx has 263 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /*
               * Copyright (C) 2016  Ben Ockmore
               *
               * This program is free software; you can redistribute it and/or modify
               * it under the terms of the GNU General Public License as published by
              Severity: Minor
              Found in src/client/entity-editor/author-section/author-section.tsx - About 2 hrs to fix

                Function collectionCreateOrEditHandler has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export async function collectionCreateOrEditHandler(req, res, next) {
                    try {
                        const {UserCollection, UserCollectionCollaborator} = req.app.locals.orm;
                        const isNew = !res.locals.collection;
                        let newCollection;
                Severity: Major
                Found in src/server/helpers/collectionRouteUtils.js - About 2 hrs to fix

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

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

                    Function getProgress has 57 lines of code (exceeds 25 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: Major
                    Found in src/server/routes/editor.tsx - About 2 hrs to fix

                      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

                      File helpers.ts has 260 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import {ADD_AUTHOR, ADD_PUBLISHER} from './cover-tab/action';
                      import {Action, State} from './interface/type';
                      import {CLOSE_ENTITY_MODAL, DUMP_EDITION, LOAD_EDITION, OPEN_ENTITY_MODAL} from './action';
                      import {ISBNReducer, authorsReducer, autoISBNReducer, publishersReducer} from './cover-tab/reducer';
                      import {seriesReducer, worksReducer} from './content-tab/reducer';
                      Severity: Minor
                      Found in src/client/unified-form/helpers.ts - About 2 hrs to fix

                        Function init has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function init(app) {
                            const {orm} = app.locals;
                            try {
                                let strategy;
                                // eslint-disable-next-line node/no-process-env
                        Severity: Major
                        Found in src/server/helpers/auth.ts - About 2 hrs to fix

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

                              render() {
                                  const switches = Object.values(PrivilegeTypes).map(priv => (
                                      <Form.Check
                                          checked={this.state.privs & priv.value}
                                          id={`bit${priv.bit}`}
                          Severity: Major
                          Found in src/client/components/pages/parts/privs-edit-modal.js - About 2 hrs to fix

                            File index.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            /*
                             * Copyright (C) 2016  Daniel Hsing
                             *               2016  Ben Ockmore
                             *               2015  Sean Burke
                             *               2015  Leo Verto
                            Severity: Minor
                            Found in src/client/components/pages/index.js - About 2 hrs to fix

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

                                  render() {
                                      const {
                                          homepage,
                                          siteRevision,
                                          repositoryUrl,
                              Severity: Major
                              Found in src/client/containers/layout.js - About 2 hrs to fix

                                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

                                Severity
                                Category
                                Status
                                Source
                                Language