bookbrainz/bookbrainz-site

View on GitHub

Showing 365 of 1,033 total issues

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

    Function handleSubmit has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        handleSubmit(evt) {
            evt.preventDefault();
            if (!this.isValid()) {
                this.setState({
                    errorText: 'Incomplete Form'
    Severity: Minor
    Found in src/client/components/forms/userCollection.js - About 1 hr to fix

      Function formatEntityChange has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function formatEntityChange(entity, change) {
          const aliasChanged =
              _.isEqual(change.path, ['aliasSet']) ||
              _.isEqual(change.path.slice(0, 2), ['aliasSet', 'aliases']) ||
              _.isEqual(change.path.slice(0, 2), ['aliasSet', 'defaultAlias']);
      Severity: Minor
      Found in src/server/helpers/diffFormatters/entity.js - About 1 hr to fix

        Function entityDeletePromise has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            const entityDeletePromise = bookshelf.transaction(async (transacting) => {
                if (!body.note || !body.note.length) {
                    throw new error.FormSubmissionError('A revision note is required when deleting an entity');
                }
        
        
        Severity: Minor
        Found in src/server/routes/entity/entity.tsx - About 1 hr to fix

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

                  async function render(props) {
                      if (props.author) {
                          // add initial ralationship with relationshipTypeId = 8 (<Work> is written by <Author>)
                          relationshipTypeId = RelationshipTypes.AuthorWroteWork;
                          addInitialRelationship(props, relationshipTypeId, initialRelationshipIndex++, props.author);
          Severity: Minor
          Found in src/server/routes/entity/work.ts - About 1 hr to fix

            Function renderAboutUs has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                renderAboutUs() {
                    const disableSignUp = this.props.disableSignUp ? {disabled: true} : {};
                    return (
                        <React.Fragment>
                            <Row>
            Severity: Minor
            Found in src/client/components/pages/index.js - About 1 hr to fix

              Function handleAddToCollection has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  handleAddToCollection() {
                      const selectedEntities = this.state.selected;
                      if (selectedEntities.length) {
                          const areAllEntitiesOfSameType = selectedEntities.every(entity => entity.type === selectedEntities[0].type);
                          const entityTypes = ['Author', 'Edition', 'EditionGroup', 'Publisher', 'Series', 'Work'];
              Severity: Minor
              Found in src/client/components/pages/parts/search-results.js - About 1 hr to fix

                Function RelationshipTypeMatrixPage has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function RelationshipTypeMatrixPage() {
                    return (
                        <Card>
                            <Card.Header as="h2">
                                Relationship Types
                Severity: Minor
                Found in src/client/components/pages/relationship-type-matrix.tsx - About 1 hr to fix

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

                    Function formatAddOrDeleteRelationshipSet has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function formatAddOrDeleteRelationshipSet(entity, change) {
                        const changes = [];
                        let allRelationships;
                        if (change.kind === 'N') {
                            allRelationships = change.rhs.relationships;
                    Severity: Minor
                    Found in src/server/helpers/diffFormatters/entity.js - About 1 hr to fix

                      Function renderDocsDropdown has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          renderDocsDropdown() {
                              const docsDropdownTitle = (
                                  <span>
                                      <FontAwesomeIcon icon={faFileLines}/>
                                      {'  Docs'}
                      Severity: Minor
                      Found in src/client/containers/layout.js - About 1 hr to fix

                        Function sortSeriesItems has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function sortSeriesItems(oldIndex, newIndex):any {
                            return (dispatch, getState) => {
                                const state = getState();
                                const seriesItems = state.get('seriesSection').get('seriesItems');
                                const orderTypeValue = state.get('seriesSection').get('orderType');
                        Severity: Minor
                        Found in src/client/entity-editor/series-section/actions.ts - About 1 hr to fix

                          Function checkIfNameExists has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function checkIfNameExists(
                              name: string,
                              entityBBID: string,
                              entityType: string,
                              action: string | null | undefined
                          Severity: Minor
                          Found in src/client/entity-editor/name-section/actions.ts - About 1 hr to fix

                            Function displayRevisions has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export async function displayRevisions(
                                req: PassportRequest, res: $Response, next: NextFunction, RevisionModel: any
                            ) {
                                const size = _.isString(req.query.size) ? parseInt(req.query.size, 10) : 20;
                                const from = _.isString(req.query.from) ? parseInt(req.query.from, 10) : 0;
                            Severity: Minor
                            Found in src/server/routes/entity/entity.tsx - About 1 hr to fix

                              Function handleSubmit has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  const handleSubmit = useCallback(async (event: FormEvent<HTMLFormElement>) => {
                                      event.preventDefault();
                                      if (!isValid()) {
                                          setErrorMsg('Error: Incomplete form! Select Entity Type.');
                                          setTimeout(() => {
                              Severity: Minor
                              Found in src/client/components/forms/type-editor/identifier-type.tsx - About 1 hr to fix

                                Function ISBNField has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export function ISBNField(props:ISBNProps) {
                                    const {value, type, onChange, autoISBN, onAutoISBNChange} = props;
                                    const onChangeHandler = React.useCallback((event:RInputEvent) => onChange(event.target.value, autoISBN), [onChange, autoISBN]);
                                    const onAutoISBNChangeHandler = React.useCallback((event:RInputEvent) => {
                                        onAutoISBNChange(event.target.checked);
                                Severity: Minor
                                Found in src/client/unified-form/cover-tab/isbn-field.tsx - About 1 hr to fix

                                  Function getLast30DaysEntities has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  async function getLast30DaysEntities(orm) {
                                      try {
                                          const entityModels = commonUtils.getEntityModels(orm);
                                          const countPromises = Object.keys(entityModels).map(async (modelName) => {
                                              const model = entityModels[modelName];
                                  Severity: Minor
                                  Found in src/server/routes/statistics.js - About 1 hr to fix

                                    Function ReviewCard has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    function ReviewCard(props) {
                                        if (!props?.reviewData || _.isEmpty(props.reviewData)) {
                                            return null;
                                        }
                                        const {reviewData} = props;
                                    Severity: Minor
                                    Found in src/client/components/pages/entities/cb-review.js - About 1 hr to fix

                                      Function formatEditionChange has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                      function formatEditionChange(change) {
                                          if (_.isEqual(change.path, ['editionGroupBbid'])) {
                                              return baseFormatter.formatScalarChange(change, 'EditionGroup');
                                          }
                                      
                                      
                                      Severity: Minor
                                      Found in src/server/routes/revision.js - About 1 hr to fix

                                        Function addInitialRelationship has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                        export function addInitialRelationship(props, relationshipTypeId, relationshipIndex, targetEntity) {
                                            // Prepend 'i' here to indicate initail relationship row identifier
                                            const rowId = `i${relationshipIndex || 0}`;
                                            const relationship = props.relationshipTypes.find(
                                                relationshipType => relationshipType.id === relationshipTypeId
                                        Severity: Minor
                                        Found in src/server/helpers/entityRouteUtils.tsx - About 1 hr to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language