HabitRPG/habitrpg

View on GitHub

Showing 686 of 3,397 total issues

File index.js has 3873 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 1992 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 1902 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 5 days to fix

          File armoire.js has 1855 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 moment from 'moment';
          import upperFirst from 'lodash/upperFirst';
          Severity: Major
          Found in website/common/script/content/gear/sets/armoire.js - About 5 days to fix

            File pets.js has 1650 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import t from '../translation';
            
            const QUEST_PETS = {
              alligator: {
                text: t('questAlligatorText'),
            Severity: Major
            Found in website/common/script/content/quests/pets.js - About 4 days to fix

              Function scoreTask has a Cognitive Complexity of 187 (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 3 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.js has 1283 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 payments.test.js has 1278 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import moment from 'moment';
                
                import * as sender from '../../../../../website/server/libs/email';
                import common from '../../../../../website/common';
                import api from '../../../../../website/server/libs/payments/payments';
                Severity: Major
                Found in test/api/unit/libs/payments/payments.test.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 groups.js has 796 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

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

                        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

                          File masterclasser.js has 728 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import t from '../translation';
                          
                          const QUEST_MASTERCLASSER = {
                            dilatoryDistress1: {
                              text: t('questDilatoryDistress1Text'),
                          Severity: Major
                          Found in website/common/script/content/quests/masterclasser.js - About 1 day to fix

                            File POST-register_local.test.js has 718 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 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

                                File user.test.js has 704 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

                                  Function getItemInfo has 322 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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language