bookbrainz/bookbrainz-site

View on GitHub

Showing 365 of 1,033 total issues

Function CallToAction has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function CallToAction(props) {
    const seedingParameters = new URLSearchParams({name: props.query});
    function renderEntityLink(type) {
        return (
            <a href={`/${camelCase(type)}/create?${seedingParameters}`}>
Severity: Minor
Found in src/client/components/pages/parts/call-to-action.js - About 1 hr to fix

    Function createRootReducer has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function createRootReducer() {
        return (state: Immutable.Map<string, any>, action) => {
            // first pass the state to our cross slice reducer to handle UF specific actions.
            const intermediateState = crossSliceReducer(state, action);
            return combineReducers({
    Severity: Minor
    Found in src/client/unified-form/helpers.ts - About 1 hr to fix

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

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

        Function mapDispatchToProps has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function mapDispatchToProps(dispatch: Dispatch<Action>): DispatchProps {
            return {
                onAuthorCreditChange: (selectedAuthorCredit:AuthorCredit) => {
                    dispatch(updateAuthorCredit(selectedAuthorCredit));
                },
        Severity: Minor
        Found in src/client/entity-editor/edition-section/edition-section-merge.tsx - About 1 hr to fix

          Function fetchOptions has a Cognitive Complexity of 10 (exceeds 5 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

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

          export async function collectionCreateOrEditHandler(req, res, next) {
              try {
                  const {UserCollection, UserCollectionCollaborator} = req.app.locals.orm;
                  const isNew = !res.locals.collection;
                  let newCollection;
          Severity: Minor
          Found in src/server/helpers/collectionRouteUtils.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 editionGroupToFormState has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          export function editionGroupToFormState(editionGroup) {
              /** The front-end expects a language id rather than the language object. */
              const aliases = editionGroup.aliasSet ?
                  editionGroup.aliasSet.aliases.map(({languageId, ...rest}) => ({
                      ...rest,
          Severity: Minor
          Found in src/server/routes/entity/edition-group.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 crossSliceReducer has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function crossSliceReducer(state:State, action:Action) {
              const {type} = action;
              let intermediateState = state;
              const activeEntityState = {
                  aliasEditor: state.get('aliasEditor'),
          Severity: Minor
          Found in src/client/unified-form/helpers.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 unflatten has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          export function unflatten(flattenObj) {
              const result = {};
              let cur;
              let prop;
              let parts;
          Severity: Minor
          Found in src/common/helpers/utils.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 displayEntity has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          export function displayEntity(req: PassportRequest, res: $Response) {
              const {orm}: {orm?: any} = req.app.locals;
              const {AchievementUnlock, EditorEntityVisits} = orm;
              const {locals: resLocals}: {locals: any} = res;
              const {entity}: {entity: any} = resLocals;
          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 getBrowsedRelationships has a Cognitive Complexity of 10 (exceeds 5 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

          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 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function mapDispatchToProps(dispatch: Dispatch<Action>): DispatchProps {
              return {
                  onAuthorCreditChange: (selectedAuthorCredit:AuthorCredit) => {
                      dispatch(updateAuthorCredit(selectedAuthorCredit));
                  },
          Severity: Minor
          Found in src/client/entity-editor/edition-section/edition-section-merge.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 dateObjectToISOString has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          export function dateObjectToISOString(value: DateObject) {
              if (_.isNil(value) || isNullDate(value)) {
                  return null;
              }
              // if year is missing or not a number, return invalid date
          Severity: Minor
          Found in src/client/helpers/utils.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 triggerSearch has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              triggerSearch(newFrom = this.state.from, newSize = this.state.size) {
                  const searchParams = new URLSearchParams(this.props.querySearchParams);
                  searchParams.set('size', newSize);
                  searchParams.set('from', newFrom);
                  const newSearchParamsString = `?${searchParams.toString()}`;
          Severity: Minor
          Found in src/client/components/pages/parts/pager.js - About 1 hr to fix

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

                render() {
                    return (
                        <div id="pageWithPagination">
                            <CollectionsTable
                                entityTypes={this.props.entityTypes}
            Severity: Minor
            Found in src/client/components/pages/collections.js - About 1 hr to fix

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

                Function renderRelationship has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function renderRelationship(relationship: Relationship) {
                    const inputsInvalid =
                        !relationship.source || !relationship.target ||
                        !isString(get(relationship, 'type.linkPhrase'));
                    if (inputsInvalid) {
                Severity: Minor
                Found in src/server/helpers/render.ts - About 1 hr to fix

                  Function fetchAccessToken has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

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

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

                        const handleSubmit = useCallback(async (event: FormEvent<HTMLFormElement>) => {
                            event.preventDefault();
                            if (!isValid()) {
                                setShowIncompleteFormError(true);
                                return;
                    Severity: Minor
                    Found in src/client/components/forms/type-editor/relationship-type.tsx - About 1 hr to fix

                      Function transformISODateForDisplay has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function transformISODateForDisplay(ISODateString) {
                          if (_isNil(ISODateString)) {
                              return ISODateString;
                          }
                          const dateStringWithoutSign = ISODateString.slice(1);
                      Severity: Minor
                      Found in src/client/helpers/entity.tsx - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language