bookbrainz/bookbrainz-site

View on GitHub

Showing 365 of 1,033 total issues

Function CoverTab has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function CoverTab(props:CoverProps) {
    const {publisherValue: publishers, onPublisherChange, identifierEditorVisible,
        onClearPublisher, handleClearPublishers, modalIsOpen, ...rest} = props;
    const publisherValue:EntitySelect[] = Object.values(convertMapToObject(publishers ?? {}));
    const onChangeHandler = React.useCallback((value:EntitySelect[], action) => {
Severity: Minor
Found in src/client/unified-form/cover-tab/cover-tab.tsx - About 1 hr to fix

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

        render() {
            const {baseUrl, sourceUrl, originalUrl, formBody} = this.props;
            const formInputs = [];
            for (const field in formBody) {
                if (Object.hasOwnProperty.call(formBody, field)) {
    Severity: Minor
    Found in src/client/components/forms/preview.js - About 1 hr to fix

      Function makeEntityLoader has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function makeEntityLoader(modelName: string, additionalRels: Array<string>, errMessage: string) {
          const relations = [
              'aliasSet.aliases.language',
              'annotation.lastRevision',
              'defaultAlias',
      Severity: Minor
      Found in src/server/helpers/middleware.ts - About 1 hr to fix

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

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

              async handleAddToCollection() {
                  const {bbids} = this.props;
                  const {selectedCollections} = this.state;
                  if (selectedCollections.length) {
                      try {
          Severity: Minor
          Found in src/client/components/pages/parts/add-to-collection-modal.js - About 1 hr to fix

            Function formatChange has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                static formatChange(change) {
                    const isChangeADate = change.key.toLowerCase().match(/\bdate\b/);
                    if (change.kind === 'N') {
                        return (
                            <tr className="table-success" key={change.key}>
            Severity: Minor
            Found in src/client/components/pages/revision.js - About 1 hr to fix

              Function renderContent has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  renderContent() {
                      return (
                          <Container>
                              <Row>
                                  <Col lg={{offset: 2, span: 8}}>
              Severity: Minor
              Found in src/client/components/pages/index.js - About 1 hr to fix

                Function ErrorPage has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function ErrorPage(props) {
                    const {error} = props;
                    let {detailedMessage} = error;
                
                    if (typeof detailedMessage === 'string') {
                Severity: Minor
                Found in src/client/components/pages/error.js - About 1 hr to fix

                  Function fetchOptions has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      async fetchOptions(query) {
                          if (!query) {
                              return {
                                  options: []
                              };
                  Severity: Minor
                  Found in src/client/entity-editor/common/entity-search-field-option.js - About 1 hr to fix

                    Function getChangedProps has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export async function getChangedProps(
                        orm, transacting, isNew, currentEntity, body, entityType,
                        newRevision, derivedProps
                    ) {
                        const aliasSetPromise =
                    Severity: Minor
                    Found in src/server/routes/entity/entity.tsx - About 1 hr to fix

                      Function parseInitialState has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export async function parseInitialState(req, type):Promise<Record<string, any>> {
                          const emptyState = {
                              nameSection: {
                                  disambiguation: '',
                                  exactMatches: null,
                      Severity: Minor
                      Found in src/server/helpers/utils.ts - About 1 hr to fix

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

                            render() {
                                const hasPermissions = this.accessToken !== null;
                                const modalBody = this.getModalBody(hasPermissions);
                                const modalFooter = this.getModalFooter(hasPermissions);
                        
                        
                        Severity: Minor
                        Found in src/client/components/pages/entities/cbReviewModal.tsx - About 1 hr to fix

                          Function renderNavContent has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              renderNavContent() {
                                  const {homepage, hideSearch, user} = this.props;
                          
                                  /*
                                   * GOTCHA: Usage of react-bootstrap FormGroup component inside
                          Severity: Minor
                          Found in src/client/containers/layout.js - About 1 hr to fix

                            Function reducer has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function reducer(
                                state: State = Immutable.OrderedMap(),
                                action
                            ) {
                                const {type, payload} = action;
                            Severity: Minor
                            Found in src/client/entity-editor/identifier-editor/reducer.ts - About 1 hr to fix

                              Function submitReviewToCB has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export async function submitReviewToCB(
                                  accessToken: string,
                                  review: Record<string, any>
                              ): Promise<any> {
                                  const cbEntityType = mapEntityType[review.entityType];
                              Severity: Minor
                              Found in src/server/helpers/critiquebrainz.ts - About 1 hr to fix

                                Function testTiers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                Open

                                async function testTiers(orm, signal, editorId, tiers) {
                                    const tierPromise = tiers.map(async (tier) => {
                                        if (signal >= tier.threshold) {
                                            try {
                                                const achievementUnlock = await awardAchievement(orm, editorId, tier.name);
                                Severity: Minor
                                Found in src/server/helpers/achievement.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 handleCreateMultipleEntities has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export async function handleCreateMultipleEntities(
                                    req: PassportRequest,
                                    res: $Response
                                ) {
                                    const {orm}: {orm?: any} = req.app.locals;
                                Severity: Minor
                                Found in src/server/routes/entity/process-unified-form.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 getAssociatedEntityRevisions has a Cognitive Complexity of 12 (exceeds 5 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

                                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 processMergeOperation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export async function processMergeOperation(orm, transacting, session, mainEntity, allEntities, relationshipSets) {
                                    const {Edition, bookshelf} = orm;
                                    const {mergingEntities} = session.mergeQueue;
                                    if (!mergingEntities) {
                                        throw new Error('Merge handler called with no merge queue, aborting');
                                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 constructPrivsChangeStatement has a Cognitive Complexity of 12 (exceeds 5 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

                                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