RocketChat/Rocket.Chat

View on GitHub
apps/meteor/server/models/raw/Users.js

Summary

Maintainability
F
3 wks
Test Coverage

File Users.js has 2523 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { ILivechatAgentStatus } from '@rocket.chat/core-typings';
import { Subscriptions } from '@rocket.chat/models';
import { escapeRegExp } from '@rocket.chat/string-helpers';

import { BaseRaw } from './BaseRaw';
Severity: Major
Found in apps/meteor/server/models/raw/Users.js - About 1 wk to fix

    UsersRaw has 215 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class UsersRaw extends BaseRaw {
        constructor(db, trash) {
            super(db, 'users', trash, {
                collectionNameResolver(name) {
                    return name;
    Severity: Major
    Found in apps/meteor/server/models/raw/Users.js - About 4 days to fix

      Function countAllAgentsStatus has 86 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          countAllAgentsStatus({ departmentId = undefined }) {
              const match = {
                  $match: {
                      roles: { $in: ['livechat-agent'] },
                  },
      Severity: Major
      Found in apps/meteor/server/models/raw/Users.js - About 3 hrs to fix

        Function getNextLeastBusyAgent has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async getNextLeastBusyAgent(department, ignoreAgentId) {
                const aggregate = [
                    {
                        $match: {
                            status: { $exists: true, $ne: 'offline' },
        Severity: Major
        Found in apps/meteor/server/models/raw/Users.js - About 2 hrs to fix

          Function saveUserById has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              saveUserById(_id, data) {
                  const setData = {};
                  const unsetData = {};
          
                  if (data.name != null) {
          Severity: Minor
          Found in apps/meteor/server/models/raw/Users.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 findActiveByUsernameOrNameRegexWithExceptionsAndConditions has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              findActiveByUsernameOrNameRegexWithExceptionsAndConditions(termRegex, exceptions, conditions, options) {
                  if (exceptions == null) {
                      exceptions = [];
                  }
                  if (conditions == null) {
          Severity: Minor
          Found in apps/meteor/server/models/raw/Users.js - About 1 hr to fix

            Function findAgentsWithDepartments has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                findAgentsWithDepartments(role, query, options) {
                    const roles = [].concat(role);
            
                    Object.assign(query, { roles: { $in: roles } });
            
            
            Severity: Minor
            Found in apps/meteor/server/models/raw/Users.js - About 1 hr to fix

              Function getAgentAndAmountOngoingChats has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async getAgentAndAmountOngoingChats(userId) {
                      const aggregate = [
                          {
                              $match: {
                                  _id: userId,
              Severity: Minor
              Found in apps/meteor/server/models/raw/Users.js - About 1 hr to fix

                Function modelIndexes has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    modelIndexes() {
                        return [
                            { key: { __rooms: 1 }, sparse: 1 },
                            { key: { roles: 1 }, sparse: 1 },
                            { key: { name: 1 } },
                Severity: Minor
                Found in apps/meteor/server/models/raw/Users.js - About 1 hr to fix

                  Function getTotalOfRegisteredUsersByDate has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      getTotalOfRegisteredUsersByDate({ start, end, options = {} }) {
                          const params = [
                              {
                                  $match: {
                                      createdAt: { $gte: start, $lte: end },
                  Severity: Minor
                  Found in apps/meteor/server/models/raw/Users.js - About 1 hr to fix

                    Function saveUserById has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        saveUserById(_id, data) {
                            const setData = {};
                            const unsetData = {};
                    
                            if (data.name != null) {
                    Severity: Minor
                    Found in apps/meteor/server/models/raw/Users.js - About 1 hr to fix

                      Function getLastAvailableAgentRouted has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          async getLastAvailableAgentRouted(department, ignoreAgentId) {
                              const aggregate = [
                                  {
                                      $match: {
                                          status: { $exists: true, $ne: 'offline' },
                      Severity: Minor
                      Found in apps/meteor/server/models/raw/Users.js - About 1 hr to fix

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

                            findByActiveUsersExcept(searchTerm, exceptions, options, searchFields, extraQuery = [], { startsWith = false, endsWith = false } = {}) {
                                if (exceptions == null) {
                                    exceptions = [];
                                }
                                if (options == null) {
                        Severity: Minor
                        Found in apps/meteor/server/models/raw/Users.js - About 1 hr to fix

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

                              findPaginatedByActiveUsersExcept(
                                  searchTerm,
                                  exceptions,
                                  options,
                                  searchFields,
                          Severity: Minor
                          Found in apps/meteor/server/models/raw/Users.js - About 1 hr to fix

                            Function findPaginatedByActiveUsersExcept has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                findPaginatedByActiveUsersExcept(
                                    searchTerm,
                                    exceptions,
                                    options,
                                    searchFields,
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js - About 35 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 findByActiveUsersExcept has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                findByActiveUsersExcept(searchTerm, exceptions, options, searchFields, extraQuery = [], { startsWith = false, endsWith = false } = {}) {
                                    if (exceptions == null) {
                                        exceptions = [];
                                    }
                                    if (options == null) {
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js - About 35 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

                                findByActiveUsersExcept(searchTerm, exceptions, options, searchFields, extraQuery = [], { startsWith = false, endsWith = false } = {}) {
                                    if (exceptions == null) {
                                        exceptions = [];
                                    }
                                    if (options == null) {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 day to fix
                            apps/meteor/server/models/raw/Users.js on lines 292..333

                            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 294.

                            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

                                findPaginatedByActiveUsersExcept(
                                    searchTerm,
                                    exceptions,
                                    options,
                                    searchFields,
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 day to fix
                            apps/meteor/server/models/raw/Users.js on lines 256..290

                            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 294.

                            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

                                setNickname(_id, nickname = '') {
                                    const update = {
                                        ...(nickname.trim()
                                            ? {
                                                    $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 2 hrs to fix
                            apps/meteor/server/models/raw/Users.js on lines 2677..2692

                            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 80.

                            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

                                setBio(_id, bio = '') {
                                    const update = {
                                        ...(bio.trim()
                                            ? {
                                                    $set: {
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 2 hrs to fix
                            apps/meteor/server/models/raw/Users.js on lines 2694..2709

                            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 80.

                            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

                                    if (data.email != null) {
                                        if (data.email.trim()) {
                                            setData.emails = [{ address: data.email.trim() }];
                                        } else {
                                            unsetData.emails = 1;
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 2 hrs to fix
                            apps/meteor/server/models/raw/Users.js on lines 2792..2798

                            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 2 locations. Consider refactoring.
                            Open

                                    if (data.phone != null) {
                                        if (data.phone.trim()) {
                                            setData.phone = [{ phoneNumber: data.phone.trim() }];
                                        } else {
                                            unsetData.phone = 1;
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 2 hrs to fix
                            apps/meteor/server/models/raw/Users.js on lines 2784..2790

                            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 2 locations. Consider refactoring.
                            Open

                                async closeOffice() {
                                    // TODO: Create class Agent
                                    const promises = [];
                                    await this.findAgents().forEach((agent) => promises.push(this.setLivechatStatus(agent._id, 'not-available')));
                                    await Promise.all(promises);
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 2 hrs to fix
                            apps/meteor/server/models/raw/Users.js on lines 1758..1763

                            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 76.

                            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

                                async openOffice() {
                                    // TODO: Create class Agent
                                    const promises = [];
                                    await this.findAgents().forEach((agent) => promises.push(this.setLivechatStatus(agent._id, 'available')));
                                    await Promise.all(promises);
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 2 hrs to fix
                            apps/meteor/server/models/raw/Users.js on lines 1751..1756

                            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 76.

                            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

                                removeBusinessHourByAgentIds(agentIds = [], businessHourId) {
                                    const query = {
                                        _id: { $in: agentIds },
                                        roles: 'livechat-agent',
                                    };
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Users.js on lines 945..958

                            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 70.

                            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

                                addBusinessHourByAgentIds(agentIds = [], businessHourId) {
                                    const query = {
                                        _id: { $in: agentIds },
                                        roles: 'livechat-agent',
                                    };
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Users.js on lines 979..992

                            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 70.

                            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

                                closeBusinessHourToAgentsWithoutDepartment(agentIdsWithDepartment = [], businessHourId) {
                                    const query = {
                                        _id: { $nin: agentIdsWithDepartment },
                                    };
                            
                            
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Users.js on lines 994..1006

                            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 65.

                            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

                                openBusinessHourToAgentsWithoutDepartment(agentIdsWithDepartment = [], businessHourId) {
                                    const query = {
                                        _id: { $nin: agentIdsWithDepartment },
                                    };
                            
                            
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Users.js on lines 1008..1020

                            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 65.

                            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

                                openAgentsBusinessHoursByBusinessHourId(businessHourIds) {
                                    const query = {
                                        roles: 'livechat-agent',
                                    };
                            
                            
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Users.js on lines 1022..1034

                            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 59.

                            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

                                setUtcOffset(_id, utcOffset) {
                                    const query = {
                                        _id,
                                        utcOffset: {
                                            $ne: utcOffset,
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Users.js on lines 872..885

                            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 59.

                            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

                                closeAgentsBusinessHoursByBusinessHourIds(businessHourIds) {
                                    const query = {
                                        roles: 'livechat-agent',
                                    };
                            
                            
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Users.js on lines 916..928

                            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 59.

                            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

                                updateStatusByAppId(appId, status) {
                                    const query = {
                                        appId,
                                        status: { $ne: status },
                                    };
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Users.js on lines 2755..2770

                            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 59.

                            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

                                findUsersInRolesWithQuery(roles, query, options) {
                                    roles = [].concat(roles);
                            
                                    Object.assign(query, { roles: { $in: roles } });
                            
                            
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Users.js on lines 180..186

                            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 56.

                            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

                                removeBannerById(_id, bannerId) {
                                    const update = {
                                        $unset: {
                                            [`banners.${bannerId}`]: true,
                                        },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Users.js on lines 2848..2856

                            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 56.

                            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

                                setBannerReadById(_id, bannerId) {
                                    const update = {
                                        $set: {
                                            [`banners.${bannerId}.read`]: true,
                                        },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Users.js on lines 2858..2866

                            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 56.

                            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

                                findPaginatedUsersInRolesWithQuery(roles, query, options) {
                                    roles = [].concat(roles);
                            
                                    Object.assign(query, { roles: { $in: roles } });
                            
                            
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 1 hr to fix
                            apps/meteor/server/models/raw/Users.js on lines 167..173

                            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 56.

                            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

                                    const query = {
                                        active: true,
                                        type: { $nin: ['app'] },
                                        roles: {
                                            $eq: 'guest',
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 55 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 2244..2252

                            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 53.

                            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

                                    const query = {
                                        active: true,
                                        type: { $nin: ['app'] },
                                        roles: {
                                            $eq: 'guest',
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 55 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 2222..2230

                            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 53.

                            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

                                enableEmail2FAByUserId(userId) {
                                    return this.updateOne(
                                        {
                                            _id: userId,
                                        },
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 55 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 1907..1921

                            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 53.

                            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

                                        {
                                            $match: {
                                                status: { $exists: true, $ne: 'offline' },
                                                statusLivechat: 'available',
                                                roles: 'livechat-agent',
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 55 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 462..469

                            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 53.

                            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

                                setAsFederated(uid) {
                                    const query = {
                                        _id: uid,
                                    };
                            
                            
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 55 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 1269..1279

                            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 53.

                            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

                                unsetExtension(userId) {
                                    const query = {
                                        _id: userId,
                                    };
                                    const update = {
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 55 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 1327..1338

                            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 53.

                            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

                                        {
                                            $match: {
                                                status: { $exists: true, $ne: 'offline' },
                                                statusLivechat: 'available',
                                                roles: 'livechat-agent',
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 55 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 528..535

                            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 53.

                            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

                                disableEmail2FAByUserId(userId) {
                                    return this.updateOne(
                                        {
                                            _id: userId,
                                        },
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 55 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 1891..1905

                            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 53.

                            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

                                findUsersInRoles(roles, scope, options) {
                                    roles = [].concat(roles);
                            
                                    const query = {
                                        roles: { $in: roles },
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 50 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 137..145

                            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 51.

                            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

                                addRoomByUserId(_id, rid) {
                                    return this.updateOne(
                                        {
                                            _id,
                                            __rooms: { $ne: rid },
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 50 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 2878..2890

                            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 51.

                            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

                                updateDefaultStatus(_id, statusDefault) {
                                    return this.updateOne(
                                        {
                                            _id,
                                            statusDefault: { $ne: statusDefault },
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 50 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 1490..1500

                            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 51.

                            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

                                findPaginatedUsersInRoles(roles, options) {
                                    roles = [].concat(roles);
                            
                                    const query = {
                                        roles: { $in: roles },
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 50 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 127..135

                            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 51.

                            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

                                    if (idExceptions) {
                                        if (!Array.isArray(idExceptions)) {
                                            idExceptions = [idExceptions];
                                        }
                            
                            
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 45 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 2254..2260

                            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 50.

                            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

                                    if (idExceptions) {
                                        if (!Array.isArray(idExceptions)) {
                                            idExceptions = [idExceptions];
                                        }
                            
                            
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 45 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 2232..2238

                            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 50.

                            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

                                addPersonalAccessTokenToUser({ userId, loginTokenObject }) {
                                    return this.updateOne(
                                        { _id: userId },
                                        {
                                            $push: {
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 45 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 1548..1557

                            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 50.

                            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

                                removePersonalAccessTokenOfUser({ userId, loginTokenObject }) {
                                    return this.updateOne(
                                        { _id: userId },
                                        {
                                            $pull: {
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 45 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 1537..1546

                            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 50.

                            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

                                removeRolesByUserId(uid, roles) {
                                    const query = {
                                        _id: uid,
                                    };
                            
                            
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 40 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 1256..1267

                            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 48.

                            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 3 locations. Consider refactoring.
                            Open

                                            available: {
                                                $sum: {
                                                    $cond: [
                                                        {
                                                            $and: [{ $eq: ['$status', 'online'] }, { $eq: ['$statusLivechat', 'available'] }],
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 2 other locations - About 40 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 737..747
                            apps/meteor/server/models/raw/Users.js on lines 748..758

                            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 48.

                            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 3 locations. Consider refactoring.
                            Open

                                            away: {
                                                $sum: {
                                                    $cond: [
                                                        {
                                                            $and: [{ $eq: ['$status', 'away'] }, { $eq: ['$statusLivechat', 'available'] }],
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 2 other locations - About 40 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 748..758
                            apps/meteor/server/models/raw/Users.js on lines 759..769

                            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 48.

                            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

                                setExtension(userId, extension) {
                                    const query = {
                                        _id: userId,
                                    };
                            
                            
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 40 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 1179..1191

                            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 48.

                            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 3 locations. Consider refactoring.
                            Open

                                            busy: {
                                                $sum: {
                                                    $cond: [
                                                        {
                                                            $and: [{ $eq: ['$status', 'busy'] }, { $eq: ['$statusLivechat', 'available'] }],
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 2 other locations - About 40 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 737..747
                            apps/meteor/server/models/raw/Users.js on lines 759..769

                            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 48.

                            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 6 locations. Consider refactoring.
                            Open

                                setReason(_id, reason) {
                                    const update = {
                                        $set: {
                                            reason,
                                        },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 5 other locations - About 35 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 862..870
                            apps/meteor/server/models/raw/Users.js on lines 2449..2457
                            apps/meteor/server/models/raw/Users.js on lines 2490..2494
                            apps/meteor/server/models/raw/Users.js on lines 2532..2540
                            apps/meteor/server/models/raw/Users.js on lines 2657..2665

                            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 47.

                            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

                                    if (department) {
                                        aggregate.push({ $unwind: '$departments' });
                                        aggregate.push({ $match: { 'departments.departmentId': department } });
                                    }
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 35 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 511..514

                            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 47.

                            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 6 locations. Consider refactoring.
                            Open

                                setLanguage(_id, language) {
                                    const update = {
                                        $set: {
                                            language,
                                        },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 5 other locations - About 35 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 862..870
                            apps/meteor/server/models/raw/Users.js on lines 2449..2457
                            apps/meteor/server/models/raw/Users.js on lines 2490..2494
                            apps/meteor/server/models/raw/Users.js on lines 2532..2540
                            apps/meteor/server/models/raw/Users.js on lines 2817..2825

                            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 47.

                            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

                                    if (department) {
                                        aggregate.push({ $unwind: '$departments' });
                                        aggregate.push({ $match: { 'departments.departmentId': department } });
                                    }
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Users.js and 1 other location - About 35 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 548..551

                            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 47.

                            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 6 locations. Consider refactoring.
                            Open

                                updateStatusText(_id, statusText) {
                                    const update = {
                                        $set: {
                                            statusText,
                                        },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 5 other locations - About 35 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 2449..2457
                            apps/meteor/server/models/raw/Users.js on lines 2490..2494
                            apps/meteor/server/models/raw/Users.js on lines 2532..2540
                            apps/meteor/server/models/raw/Users.js on lines 2657..2665
                            apps/meteor/server/models/raw/Users.js on lines 2817..2825

                            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 47.

                            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 6 locations. Consider refactoring.
                            Open

                                setUsername(_id, username) {
                                    const update = { $set: { username } };
                            
                                    return this.updateOne({ _id }, update);
                                }
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 5 other locations - About 35 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 862..870
                            apps/meteor/server/models/raw/Users.js on lines 2449..2457
                            apps/meteor/server/models/raw/Users.js on lines 2532..2540
                            apps/meteor/server/models/raw/Users.js on lines 2657..2665
                            apps/meteor/server/models/raw/Users.js on lines 2817..2825

                            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 47.

                            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 6 locations. Consider refactoring.
                            Open

                                setName(_id, name) {
                                    const update = {
                                        $set: {
                                            name,
                                        },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 5 other locations - About 35 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 862..870
                            apps/meteor/server/models/raw/Users.js on lines 2449..2457
                            apps/meteor/server/models/raw/Users.js on lines 2490..2494
                            apps/meteor/server/models/raw/Users.js on lines 2657..2665
                            apps/meteor/server/models/raw/Users.js on lines 2817..2825

                            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 47.

                            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 6 locations. Consider refactoring.
                            Open

                                updateInviteToken(_id, inviteToken) {
                                    const update = {
                                        $set: {
                                            inviteToken,
                                        },
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Users.js and 5 other locations - About 35 mins to fix
                            apps/meteor/server/models/raw/Users.js on lines 862..870
                            apps/meteor/server/models/raw/Users.js on lines 2490..2494
                            apps/meteor/server/models/raw/Users.js on lines 2532..2540
                            apps/meteor/server/models/raw/Users.js on lines 2657..2665
                            apps/meteor/server/models/raw/Users.js on lines 2817..2825

                            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 47.

                            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