HabitRPG/habitrpg

View on GitHub

Showing 635 of 3,337 total issues

File quests.js has 3904 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import defaults from 'lodash/defaults';
import each from 'lodash/each';
import find from 'lodash/find';
import moment from 'moment';
import sortBy from 'lodash/sortBy';
Severity: Major
Found in website/common/script/content/quests.js - About 1 wk to fix

    File index.js has 3235 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import moment from 'moment';
    import pickBy from 'lodash/pickBy';
    import defaults from 'lodash/defaults';
    import find from 'lodash/find';
    import upperFirst from 'lodash/upperFirst';
    Severity: Major
    Found in website/common/script/content/gear/sets/special/index.js - About 1 wk to fix

      Function getLoginIncentives has a Cognitive Complexity of 314 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function getLoginIncentives (api) {
        const loginIncentives = {
          1: {
            rewardKey: ['armor_special_bardRobes'],
            reward: [api.gear.flat.armor_special_bardRobes],
      Severity: Minor
      Found in website/common/script/content/loginIncentives.js - About 6 days 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

      File group.test.js has 1991 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import moment from 'moment';
      import { v4 as generateUUID } from 'uuid';
      import validator from 'validator';
      import { sleep, translationCheck } from '../../../helpers/api-unit.helper';
      import {
      Severity: Major
      Found in test/api/unit/models/group.test.js - About 5 days to fix

        Function getLoginIncentives has 1076 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function getLoginIncentives (api) {
          const loginIncentives = {
            1: {
              rewardKey: ['armor_special_bardRobes'],
              reward: [api.gear.flat.armor_special_bardRobes],
        Severity: Major
        Found in website/common/script/content/loginIncentives.js - About 5 days to fix

          File cron.test.js has 1830 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /* eslint-disable global-require */
          import moment from 'moment';
          import nconf from 'nconf';
          import requireAgain from 'require-again';
          import { recoverCron, cron } from '../../../../website/server/libs/cron';
          Severity: Major
          Found in test/api/unit/libs/cron.test.js - About 4 days to fix

            File armoire.js has 1466 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import defaults from 'lodash/defaults';
            import find from 'lodash/find';
            import forEach from 'lodash/forEach';
            import upperFirst from 'lodash/upperFirst';
            import { ownsItem } from '../gear-helper';
            Severity: Major
            Found in website/common/script/content/gear/sets/armoire.js - About 3 days to fix

              File group.js has 1342 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import moment from 'moment';
              import mongoose from 'mongoose';
              import _ from 'lodash';
              import validator from 'validator';
              import nconf from 'nconf';
              Severity: Major
              Found in website/server/models/group.js - About 3 days to fix

                File loginIncentives.js has 1080 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import range from 'lodash/range';
                import { MAX_INCENTIVES } from '../constants';
                
                // NOTE do not import this file alone but only access it through common.content
                // so that it's already compiled
                Severity: Major
                Found in website/common/script/content/loginIncentives.js - About 2 days to fix

                  File shouldDo.test.js has 1020 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import moment from 'moment';
                  import { shouldDo, DAY_MAPPING } from '../../website/common/script/cron';
                  import 'moment-recur';
                  
                  describe('shouldDo', () => {
                  Severity: Major
                  Found in test/common/shouldDo.test.js - About 2 days to fix

                    Function shouldDo has a Cognitive Complexity of 99 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function shouldDo (day, dailyTask, options = {}) {
                      if (dailyTask.type !== 'daily' || dailyTask.startDate === null || dailyTask.everyX < 1 || dailyTask.everyX > 9999) {
                        return false;
                      }
                      const o = sanitizeOptions(options);
                    Severity: Minor
                    Found in website/common/script/cron.js - About 1 day 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

                    File group-payments-create.test.js has 768 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import moment from 'moment';
                    import stripeModule from 'stripe';
                    import nconf from 'nconf';
                    
                    import * as sender from '../../../../../../website/server/libs/email';
                    Severity: Major
                    Found in test/api/unit/libs/payments/group-plans/group-payments-create.test.js - About 1 day to fix

                      Function scoreTask has a Cognitive Complexity of 90 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export default function scoreTask (options = {}, req = {}, analytics) {
                        const {
                          user, task, direction, times = 1, cron = false,
                        } = options;
                        let delta = 0;
                      Severity: Minor
                      Found in website/common/script/ops/scoreTask.js - About 1 day 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

                      File POST-register_local.test.js has 723 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import { v4 as uuid } from 'uuid';
                      import { each } from 'lodash';
                      import {
                        generateUser,
                        requester,
                      Severity: Major
                      Found in test/api/v3/integration/user/auth/POST-register_local.test.js - About 1 day to fix

                        File groups.js has 717 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import _ from 'lodash';
                        import nconf from 'nconf';
                        import { authWithHeaders } from '../../middlewares/auth';
                        import {
                          model as Group,
                        Severity: Major
                        Found in website/server/controllers/api-v3/groups.js - About 1 day to fix

                          File POST-tasks_user.test.js has 716 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import { v4 as generateUUID } from 'uuid';
                          import {
                            generateUser,
                            sleep,
                            translate as t,
                          Severity: Major
                          Found in test/api/v3/integration/tasks/POST-tasks_user.test.js - About 1 day to fix

                            Function getItemInfo has 321 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export default function getItemInfo (user, type, item, officialPinnedItems, language = 'en') {
                              if (officialPinnedItems === undefined) {
                                officialPinnedItems = getOfficialPinnedItems(user); // eslint-disable-line no-param-reassign
                              }
                            
                            
                            Severity: Major
                            Found in website/common/script/libs/getItemInfo.js - About 1 day to fix

                              File user.test.js has 697 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import moment from 'moment';
                              import { model as User } from '../../../../website/server/models/user';
                              import { model as NewsPost } from '../../../../website/server/models/newsPost';
                              import { model as Group } from '../../../../website/server/models/group';
                              import common from '../../../../website/common';
                              Severity: Major
                              Found in test/api/unit/models/user.test.js - About 1 day to fix

                                File POST-register_local.test.js has 693 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                import { v4 as uuid } from 'uuid';
                                import { each } from 'lodash';
                                import {
                                  generateUser,
                                  requester,
                                Severity: Major
                                Found in test/api/v4/user/auth/POST-register_local.test.js - About 1 day to fix

                                  File spells.js has 677 lines of code (exceeds 250 allowed). Consider refactoring.
                                  Open

                                  import each from 'lodash/each';
                                  import moment from 'moment';
                                  import t from './translation';
                                  import { NotAuthorized, BadRequest } from '../libs/errors';
                                  import statsComputed from '../libs/statsComputed'; // eslint-disable-line import/no-cycle
                                  Severity: Major
                                  Found in website/common/script/content/spells.js - About 1 day to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language