bookbrainz/bookbrainz-site

View on GitHub

Showing 365 of 1,033 total issues

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

    handleSubmit() {
        const cleanedEntities = this.getCleanedEntities();
        const bbids = cleanedEntities.map(entity => entity.id);
        if (bbids.length) {
            request.post(`/collection/${this.props.collectionId}/add`)
Severity: Minor
Found in src/client/components/pages/parts/add-entity-to-collection-modal.js - About 1 hr to fix

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

        handleSubmit(event) {
            const {note} = this.state;
            event.preventDefault();
    
            if (!note || !note.length) {
    Severity: Minor
    Found in src/client/components/forms/deletion.js - About 1 hr to fix

      Function saveEntitiesAndFinishRevision has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export async function saveEntitiesAndFinishRevision(
          orm, transacting, isNew: boolean, newRevision: any, mainEntity: any,
          updatedEntities: any[], editorID: number, note: string
      ) {
          const parentRevisionIDs = _.compact(_.uniq(updatedEntities.map(
      Severity: Minor
      Found in src/server/routes/entity/entity.tsx - About 1 hr to fix

        Function refreshAccessToken has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export async function refreshAccessToken(
            editorId: number,
            refreshToken: string,
            orm: Record<string, any>
        ): Promise<any> {
        Severity: Minor
        Found in src/server/helpers/critiquebrainz.ts - About 1 hr to fix

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

          export function transformNewForm(data) {
              const aliases = entityRoutes.constructAliases(
                  data.aliasEditor, data.nameSection
              );
          
          
          Severity: Minor
          Found in src/server/routes/entity/author.ts - About 1 hr to fix

            Function submit has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function submit(
                submissionUrl: string,
                isUnifiedForm = false
            ): SubmitResult {
                return (dispatch, getState) => {
            Severity: Minor
            Found in src/client/entity-editor/submission-section/actions.ts - About 1 hr to fix

              Function validateCollectionParams has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function validateCollectionParams(req, res, next) {
                  const {collaborators = [], name, entityType} = req.body;
                  const {orm} = req.app.locals;
                  const {Editor} = orm;
              
              
              Severity: Minor
              Found in src/server/helpers/middleware.ts - About 1 hr to fix

                Function loadSeriesItems has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function loadSeriesItems(req: $Request, res: $Response, next: NextFunction) {
                    try {
                        const {entity} = res.locals;
                        if (entity.dataId) {
                            const {relationships} = entity;
                Severity: Minor
                Found in src/server/helpers/middleware.ts - About 1 hr to fix

                  Function submitSingleEntity has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function submitSingleEntity(submissionUrl:string, entityType:EntityTypeString, callback:(newEntity)=>void, initialState = {}):SubmitResult {
                      return async (dispatch, getState) => {
                          const rootState = getState();
                          dispatch(setSubmitted(true));
                          const JSONState = rootState.toJS();
                  Severity: Minor
                  Found in src/client/entity-editor/submission-section/actions.ts - About 1 hr to fix

                    Function validateBBIDsForCollectionAdd has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export async function validateBBIDsForCollectionAdd(req, res, next) {
                        const {Entity} = req.app.locals.orm;
                        const {bbids = []} = req.body;
                        if (!bbids.length) {
                            return next(new error.BadRequestError('BBIDs array is empty'));
                    Severity: Minor
                    Found in src/server/helpers/middleware.ts - About 1 hr to fix

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

                          render() {
                              return (
                                  <Row>
                                      <Col lg={{offset: 3, span: 6}}>
                                          <form
                      Severity: Minor
                      Found in src/client/components/pages/parts/admin-panel-search-field.tsx - About 1 hr to fix

                        Function saveEntitiesAndFinishRevision has 8 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            orm, transacting, isNew: boolean, newRevision: any, mainEntity: any,
                            updatedEntities: any[], editorID: number, note: string
                        Severity: Major
                        Found in src/server/routes/entity/entity.tsx - About 1 hr to fix

                          Function getChangedProps has 8 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              orm, transacting, isNew, currentEntity, body, entityType,
                              newRevision, derivedProps
                          Severity: Major
                          Found in src/server/routes/entity/entity.tsx - About 1 hr to fix

                            Function format has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function format(
                                change, setProp, itemProp, newSetFormatter, addDeleteFormatter,
                                modifyFormatter
                            ) {
                                const setAdded =
                            Severity: Minor
                            Found in src/server/helpers/diffFormatters/set.js - About 55 mins 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 reducer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function reducer(
                                state = Immutable.Map({
                                    canEdit: true,
                                    lastRelationships: null,
                                    relationshipEditorProps: null,
                            Severity: Minor
                            Found in src/client/entity-editor/relationship-editor/reducer.js - About 55 mins 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 render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                render() {
                                    let messageComponent = null;
                                    if (this.state.message.text) {
                                        messageComponent = (
                                            <div>
                            Severity: Minor
                            Found in src/client/components/pages/parts/add-to-collection-modal.js - About 55 mins 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 diffRevisionsWithParents has a Cognitive Complexity of 9 (exceeds 5 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 55 mins 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 handleAddToCollection has a Cognitive Complexity of 9 (exceeds 5 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 55 mins 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 formatEntityChange has a Cognitive Complexity of 9 (exceeds 5 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 55 mins 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 formatAuthorChange has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function formatAuthorChange(change) {
                                if (_.isEqual(change.path, ['beginDate'])) {
                                    return baseFormatter.formatScalarChange(change, 'Begin Date');
                                }
                            
                            
                            Severity: Minor
                            Found in src/server/routes/revision.js - About 55 mins 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