HabitRPG/habitrpg

View on GitHub
website/server/controllers/api-v3/user.js

Summary

Maintainability
F
1 wk
Test Coverage

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

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

    Function handler has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async handler (req, res) {
        const user = await res.locals.user.toJSONWithInbox();
        user.stats.toNextLevel = common.tnl(user.stats.lvl);
        user.stats.maxHealth = common.maxHealth;
        user.stats.maxMP = common.statsComputed(res.locals.user).maxMP;
    Severity: Minor
    Found in website/server/controllers/api-v3/user.js - About 1 hr to fix

      Function handler has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async handler (req, res) {
          const { user } = res.locals;
          const { plan } = user.purchased;
      
          const { password } = req.body;
      Severity: Minor
      Found in website/server/controllers/api-v3/user.js - About 1 hr to fix

        Function handler has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async handler (req, res) {
            req.checkParams('path', res.t('taskIdRequired')).notEmpty();
            req.checkParams('position', res.t('positionRequired')).notEmpty().isNumeric();
        
            const validationErrors = req.validationErrors();
        Severity: Minor
        Found in website/server/controllers/api-v3/user.js - About 1 hr to fix

          Function handler has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            async handler (req, res) {
              const { user } = res.locals;
              const { plan } = user.purchased;
          
              const { password } = req.body;
          Severity: Minor
          Found in website/server/controllers/api-v3/user.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 handler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            async handler (req, res) {
              req.checkParams('path', res.t('taskIdRequired')).notEmpty();
              req.checkParams('position', res.t('positionRequired')).notEmpty().isNumeric();
          
              const validationErrors = req.validationErrors();
          Severity: Minor
          Found in website/server/controllers/api-v3/user.js - About 45 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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              if (user.auth.local.hashed_password && user.auth.local.email) {
                const isValidPassword = await passwordUtils.compare(user, password);
                if (!isValidPassword) throw new NotAuthorized(res.t('wrongPassword'));
              } else if (
                (user.auth.facebook.id || user.auth.google.id || user.auth.apple.id)
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 1 other location - About 6 hrs to fix
          website/server/controllers/api-v4/user.js on lines 228..236

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 156.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          api.buyQuest = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/buy-quest/:key',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 1 other location - About 4 hrs to fix
          website/server/controllers/api-v3/user.js on lines 669..680

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 127.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          api.buyMysterySet = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/buy-mystery-set/:key',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 1 other location - About 4 hrs to fix
          website/server/controllers/api-v3/user.js on lines 712..723

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 127.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

          api.changeClass = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/change-class',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 4 other locations - About 4 hrs to fix
          website/server/controllers/api-v3/user.js on lines 543..553
          website/server/controllers/api-v3/user.js on lines 1194..1204
          website/server/controllers/api-v3/user.js on lines 1279..1289
          website/server/controllers/api-v3/user.js on lines 1355..1365

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 116.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

          api.buyGear = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/buy-gear/:key',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 4 other locations - About 4 hrs to fix
          website/server/controllers/api-v3/user.js on lines 946..956
          website/server/controllers/api-v3/user.js on lines 1194..1204
          website/server/controllers/api-v3/user.js on lines 1279..1289
          website/server/controllers/api-v3/user.js on lines 1355..1365

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 116.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

          api.userReleasePets = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/release-pets',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 4 other locations - About 4 hrs to fix
          website/server/controllers/api-v3/user.js on lines 543..553
          website/server/controllers/api-v3/user.js on lines 946..956
          website/server/controllers/api-v3/user.js on lines 1279..1289
          website/server/controllers/api-v3/user.js on lines 1355..1365

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 116.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

          api.userReleaseMounts = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/release-mounts',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 4 other locations - About 4 hrs to fix
          website/server/controllers/api-v3/user.js on lines 543..553
          website/server/controllers/api-v3/user.js on lines 946..956
          website/server/controllers/api-v3/user.js on lines 1194..1204
          website/server/controllers/api-v3/user.js on lines 1355..1365

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 116.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

          api.userUnlock = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/unlock',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 4 other locations - About 4 hrs to fix
          website/server/controllers/api-v3/user.js on lines 543..553
          website/server/controllers/api-v3/user.js on lines 946..956
          website/server/controllers/api-v3/user.js on lines 1194..1204
          website/server/controllers/api-v3/user.js on lines 1279..1289

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 116.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          api.userOpenMysteryItem = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/open-mystery-item',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 1 other location - About 3 hrs to fix
          website/server/controllers/api-v3/user.js on lines 1243..1253

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 114.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          api.userReleaseBoth = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/release-both',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 1 other location - About 3 hrs to fix
          website/server/controllers/api-v3/user.js on lines 1162..1172

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 114.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 7 locations. Consider refactoring.
          Open

          api.readCard = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/read-card/:cardType',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 6 other locations - About 3 hrs to fix
          website/server/controllers/api-v3/user.js on lines 854..864
          website/server/controllers/api-v3/user.js on lines 967..977
          website/server/controllers/api-v3/user.js on lines 1312..1322
          website/server/controllers/api-v3/user/stats.js on lines 30..40
          website/server/controllers/api-v3/user/stats.js on lines 70..80
          website/server/controllers/api-v4/user.js on lines 292..302

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 109.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 7 locations. Consider refactoring.
          Open

          api.equip = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/equip/:type/:key',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 6 other locations - About 3 hrs to fix
          website/server/controllers/api-v3/user.js on lines 967..977
          website/server/controllers/api-v3/user.js on lines 1120..1130
          website/server/controllers/api-v3/user.js on lines 1312..1322
          website/server/controllers/api-v3/user/stats.js on lines 30..40
          website/server/controllers/api-v3/user/stats.js on lines 70..80
          website/server/controllers/api-v4/user.js on lines 292..302

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 109.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 7 locations. Consider refactoring.
          Open

          api.disableClasses = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/disable-classes',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 6 other locations - About 3 hrs to fix
          website/server/controllers/api-v3/user.js on lines 854..864
          website/server/controllers/api-v3/user.js on lines 1120..1130
          website/server/controllers/api-v3/user.js on lines 1312..1322
          website/server/controllers/api-v3/user/stats.js on lines 30..40
          website/server/controllers/api-v3/user/stats.js on lines 70..80
          website/server/controllers/api-v4/user.js on lines 292..302

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 109.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 7 locations. Consider refactoring.
          Open

          api.userSell = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/sell/:type/:key',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 6 other locations - About 3 hrs to fix
          website/server/controllers/api-v3/user.js on lines 854..864
          website/server/controllers/api-v3/user.js on lines 967..977
          website/server/controllers/api-v3/user.js on lines 1120..1130
          website/server/controllers/api-v3/user/stats.js on lines 30..40
          website/server/controllers/api-v3/user/stats.js on lines 70..80
          website/server/controllers/api-v4/user.js on lines 292..302

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 109.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              _.each(list, item => {
                _.each(item, (itemPropVal, itemPropKey) => {
                  if (
                    _.isFunction(itemPropVal)
                    && itemPropVal.i18nLangFunc
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 1 other location - About 2 hrs to fix
          website/server/controllers/api-v3/user.js on lines 177..184

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 78.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              _.each(list, item => {
                _.each(item, (itemPropVal, itemPropKey) => {
                  if (
                    _.isFunction(itemPropVal)
                    && itemPropVal.i18nLangFunc
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 1 other location - About 2 hrs to fix
          website/server/controllers/api-v3/user.js on lines 129..136

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 78.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          api.userReroll = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/reroll',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 3 other locations - About 1 hr to fix
          website/server/controllers/api-v4/user.js on lines 108..115
          website/server/controllers/api-v4/user.js on lines 148..155
          website/server/controllers/api-v4/user.js on lines 182..189

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 69.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          api.getUser = {
            method: 'GET',
            middlewares: [authWithHeaders()],
            url: '/user',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 3 other locations - About 1 hr to fix
          website/server/controllers/api-v3/user.js on lines 221..228
          website/server/controllers/api-v3/user.js on lines 1423..1430
          website/server/controllers/api-v3/user.js on lines 1606..1613

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 68.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          api.userReset = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/reset',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 3 other locations - About 1 hr to fix
          website/server/controllers/api-v3/user.js on lines 85..92
          website/server/controllers/api-v3/user.js on lines 221..228
          website/server/controllers/api-v3/user.js on lines 1423..1430

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 68.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          api.userRebirth = {
            method: 'POST',
            middlewares: [authWithHeaders()],
            url: '/user/rebirth',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 3 other locations - About 1 hr to fix
          website/server/controllers/api-v3/user.js on lines 85..92
          website/server/controllers/api-v3/user.js on lines 221..228
          website/server/controllers/api-v3/user.js on lines 1606..1613

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 68.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          api.updateUser = {
            method: 'PUT',
            middlewares: [authWithHeaders()],
            url: '/user',
            async handler (req, res) {
          Severity: Major
          Found in website/server/controllers/api-v3/user.js and 3 other locations - About 1 hr to fix
          website/server/controllers/api-v3/user.js on lines 85..92
          website/server/controllers/api-v3/user.js on lines 1423..1430
          website/server/controllers/api-v3/user.js on lines 1606..1613

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 68.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status