bookbrainz/bookbrainz-site

View on GitHub

Showing 365 of 1,033 total issues

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

function getEntityRelations(entityType) {
    const authorRelations = [
        'defaultAlias.language',
        'disambiguation',
        'authorType',
Severity: Minor
Found in src/server/routes/collection.js - About 1 hr to fix

    Function EditionSection has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    function EditionSection({
        depthValue,
        editionFormats,
        editionStatuses,
        formatValue,
    Severity: Minor
    Found in src/client/entity-editor/edition-section/edition-section.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 mapDispatchToProps has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    function mapDispatchToProps(dispatch):ISBNDispatchProps {
        let autoAddedISBN:dispatchResultProps|null;
        function onChange(value:string, autoISBN = false) {
            const isbn10rgx = new
            RegExp('^(?:ISBN(?:-10)?:?●)?(?=[0-9X]{10}$|(?=(?:[0-9]+[-●]){3})[-●0-9X]{13}$)[0-9]{1,5}[-●]?[0-9]+[-●]?[0-9]+[-●]?[0-9X]$');
    Severity: Minor
    Found in src/client/unified-form/cover-tab/isbn-field.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 getEntityDiff has 43 lines of code (exceeds 25 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 1 hr to fix

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

      function init(app, config) {
          const influxConfig = config.influx;
      
          const influx = new Influx.InfluxDB({
              database: influxConfig.database || 'bookbrainz',
      Severity: Minor
      Found in src/server/influx.js - About 1 hr to fix

        Function renderEntitySelect has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            renderEntitySelect() {
                const {baseEntity, relationshipTypes} = this.props;
                const {targetEntity} = this.state;
                const types = getValidOtherEntityTypes(relationshipTypes, baseEntity);
                if (!types.length) {

          Function getBrowsedRelationships has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export async function getBrowsedRelationships(orm, locals, browsedEntityType,
                                                        getEntityInfoMethod, fetchRelated, filterRelationshipMethod) {
              const {entity, relationships} = locals;
          
              if (!relationships.length > 0) {
          Severity: Minor
          Found in src/api/helpers/utils.js - About 1 hr to fix

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

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

              Function AdminLogsTable has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function AdminLogsTable(props) {
                  const {results, tableHeading} = props;
                  return (
                      <div>
                          <div>
              Severity: Minor
              Found in src/client/components/pages/parts/admin-logs-table.js - About 1 hr to fix

                Function DevelopPage has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function DevelopPage(): JSX.Element {
                    return (
                        <div>
                            <div className="page-header">
                                <h1>Developing with BookBrainz</h1>
                Severity: Minor
                Found in src/client/components/pages/develop.tsx - About 1 hr to fix

                  Function formatAliasModified has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function formatAliasModified(change) {
                      if (change.path.length > 3 && change.path[3] === 'name') {
                          return [
                              base.formatChange(
                                  change,
                  Severity: Minor
                  Found in src/server/helpers/diffFormatters/entity.js - About 1 hr to fix

                    Function promises has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            async (revision) => {
                                const dataId = revision.get('dataId');
                                const revisionEntity = revision.related('entity');
                                const entityBBID = revisionEntity.get('bbid');
                                const entity = await orm.func.entity.getEntity(orm, entityType, entityBBID);
                    Severity: Minor
                    Found in src/server/routes/revision.js - About 1 hr to fix

                      Function handleAddToNewCollection has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          handleAddToNewCollection(evt) {
                              evt.preventDefault();
                      
                              if (!this.isValid()) {
                                  this.setState({
                      Severity: Minor
                      Found in src/client/components/pages/parts/add-to-collection-modal.js - About 1 hr to fix

                        Function generateRelationshipSelection has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function generateRelationshipSelection(
                            relationshipTypes: Array<RelationshipType>,
                            entityA: Entity,
                            entityB: Entity
                        ): Array<RelationshipWithLabel> {

                          Function alertPromise has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              let alertPromise = editorEntityVisitPromise.then((visitAlert) => {
                                  let alertIds = [];
                                  if (visitAlert.alert) {
                                      alertIds = alertIds.concat(visitAlert.alert.split(',').map(
                                          (id) => parseInt(id, 10)
                          Severity: Minor
                          Found in src/server/routes/entity/entity.tsx - About 1 hr to fix

                            Function SearchEntityCreate has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function SearchEntityCreate(props:SearchEntityCreateProps) {
                                const {type, nextId, onModalOpen, onModalClose, onSubmitEntity, rowId, onOpenCallback, ...rest} = props;
                                const createLabel = React.useCallback((input) => `Create ${type} "${input}"`, [type]);
                                const [showModal, setShowModal] = React.useState(false);
                                const getNewOptionData = React.useCallback((_, label) => ({
                            Severity: Minor
                            Found in src/client/unified-form/common/search-entity-create-select.tsx - About 1 hr to fix

                              Function getEntityFetchPropertiesByType has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export function getEntityFetchPropertiesByType(entityType) {
                                  switch (entityType) {
                                      case 'Author':
                                          return ['authorType', 'beginArea', 'endArea', 'gender'];
                                      case 'Edition':
                              Severity: Minor
                              Found in src/server/helpers/merge.js - About 1 hr to fix

                                Function identifierTypeCreateOrEditHandler has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export async function identifierTypeCreateOrEditHandler(req, res) {
                                    try {
                                        const {IdentifierType} = req.app.locals.orm;
                                        let newIdentifierType;
                                        let method;
                                Severity: Minor
                                Found in src/server/helpers/typeRouteUtils.ts - About 1 hr to fix

                                  Function getAssociatedEntityRevisions has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export async function getAssociatedEntityRevisions(revisions, orm) {
                                      const revisionIDs = revisions.map(({revisionId}) => revisionId);
                                      const RevisionModels = getRevisionModels(orm);
                                      const {Entity} = orm;
                                      for (let i = 0; i < RevisionModels.length; i++) {
                                  Severity: Minor
                                  Found in src/server/helpers/revisions.ts - About 1 hr to fix

                                    Function getEntityRelationships has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    export function getEntityRelationships(entity: any) {
                                        return _.isNil(entity) ? null :
                                            {
                                                bbid: _.get(entity, 'bbid', null),
                                                relationships: _.get(entity, 'relationshipSet.relationships', []).map((relationship) => {
                                    Severity: Minor
                                    Found in src/api/helpers/formatEntityData.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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language