bookbrainz/bookbrainz-site

View on GitHub

Showing 365 of 1,033 total issues

Function processEditionSets has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function processEditionSets(
    orm: any,
    currentEntity: Record<string, unknown> | null | undefined,
    body: ProcessEditionSetsBody,
    transacting: Transaction
Severity: Major
Found in src/server/routes/entity/entity.tsx - About 2 hrs to fix

    File search-results.js has 252 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * Copyright (C) 2015  Ohm Patel
     *               2016  Sean Burke
     *
     * This program is free software; you can redistribute it and/or modify
    Severity: Minor
    Found in src/client/components/pages/parts/search-results.js - About 2 hrs to fix

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

          render() {
              return (
                  this.state.results && this.state.results.length ?
                      <div id="PagerElement">
                          <hr className="thin"/>
      Severity: Minor
      Found in src/client/components/pages/parts/pager.js - About 2 hrs to fix

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

            render() {
                const labelElement = (
                    <ValidationLabel empty={this.props.empty} error={this.props.error}>
                        {this.props.label}
                    </ValidationLabel>
        Severity: Minor
        Found in src/client/entity-editor/common/entity-search-field-option.js - About 1 hr to fix

          Function getInitState has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function getInitState(
              baseEntity: Entity, initRelationship: _Relationship | null | undefined
          ): RelationshipModalState {
              if (_.isNull(initRelationship)) {
                  return {

            Function EntityEditor has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const EntityEditor = (props: Props) => {
                const {
                    aliasEditorVisible,
                    children,
                    heading,
            Severity: Minor
            Found in src/client/entity-editor/entity-editor.tsx - About 1 hr to fix

              Function results has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      const results = this.props.results.map((result) => {
                          if (!result) {
                              return null;
                          }
                          const id = getId(result);
              Severity: Minor
              Found in src/client/components/pages/parts/search-results.js - About 1 hr to fix

                Function renderRelationshipSelect has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    renderRelationshipSelect() {
                        const {baseEntity, relationshipTypes} = this.props;
                
                        const otherEntity = {
                            bbid: _.get(this.state, ['targetEntity', 'id']),

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

                  export async function deleteRelationships(orm: any, transacting: Transaction, mainEntity: any) {
                      const mainBBID = mainEntity.bbid;
                      const {relationshipSet} = mainEntity;
                      const otherBBIDs = [];
                      const otherEntities = [];
                  Severity: Minor
                  Found in src/server/routes/entity/entity.tsx - About 1 hr to fix

                    Function diffRevisionsWithParents has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function diffRevisionsWithParents(orm, entityRevisions, entityType) {
                        // entityRevisions - collection of *entityType*_revisions matching id
                        const promises = entityRevisions.map(
                            async (revision) => {
                                const dataId = revision.get('dataId');
                    Severity: Minor
                    Found in src/server/routes/revision.js - About 1 hr to fix

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

                        Function constructPrivsChangeStatement has 46 lines of code (exceeds 25 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

                          Function loadEntityRelationships has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          async function loadEntityRelationships(entity, orm, transacting): Promise<any> {
                              async function getEntityWithAlias(relEntity) {
                                  const redirectBbid = await orm.func.entity.recursivelyGetRedirectBBID(orm, relEntity.bbid, null);
                                  const model = commonUtils.getEntityModelByType(orm, relEntity.type);
                                  return model.forge({bbid: redirectBbid})
                          Severity: Minor
                          Found in src/server/routes/merge.ts - About 1 hr to fix

                            Function handleDelete has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export function handleDelete(
                                orm: any, req: PassportRequest, res: $Response, HeaderModel: any,
                                RevisionModel: any
                            ) {
                                const {entity}: {entity?: any} = res.locals;
                            Severity: Minor
                            Found in src/server/routes/entity/entity.tsx - About 1 hr to fix

                              Function cleanupOnExit has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function cleanupOnExit(cleanupPromise) {
                                  process.on('asyncExit', () => {
                                      cleanupPromise().then(() => {
                                          console.log('Cleanup process finished');
                                          process.exit(0);
                              Severity: Minor
                              Found in src/common/helpers/appCleanup.js - About 1 hr to fix

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

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

                                      render() {
                                          const {type, query, results} = this.state;
                                          const querySearchParams = `q=${query}${type ? `&type=${type}` : ''}`;
                                          return (
                                              <div id="pageWithPagination">
                                  Severity: Minor
                                  Found in src/client/components/pages/search.tsx - About 1 hr to fix

                                    Function processEdit has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    export async function processEdit(orm, userId, revisionId) {
                                        const revisionist = await processRevisionist(orm, userId);
                                        const authorCreator = await processAuthorCreator(orm, userId);
                                        const limitedEdition = await processLimitedEdition(orm, userId);
                                        const publisher = await processPublisher(orm, userId);
                                    Severity: Minor
                                    Found in src/server/helpers/achievement.js - About 1 hr to fix

                                      Function formatEntityDiffs has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                      export function formatEntityDiffs(diffs, entityType, entityFormatter) {
                                          if (!diffs) {
                                              return [];
                                          }
                                      
                                      
                                      Severity: Minor
                                      Found in src/server/helpers/diffFormatters/entity.js - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language