maestro-server/server-app

View on GitHub

Showing 102 of 102 total issues

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

module.exports = {
    create: Joi.object().keys(Object.assign({}, sharedS, createS)),
    update: Joi.object().keys(sharedS),
    delete: {},
    list: {}
Severity: Major
Found in app/reports/validators/scheduler.js and 1 other location - About 1 hr to fix
app/identity/validators/users.js on lines 26..31

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

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

module.exports = {
    create: Joi.object().keys(Object.assign({}, sharedS, createS)),
    update: Joi.object().keys(sharedS),
    delete: {},
    list: {}
Severity: Major
Found in app/identity/validators/users.js and 1 other location - About 1 hr to fix
app/reports/validators/scheduler.js on lines 46..51

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

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

Function mailerConnector has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const mailerConnector = (mailer = DMailer) => {

    if (!mailer.isConnected()) {
        try {
            factoryValid(
Severity: Minor
Found in app/core/repositories/smtp/mailerConnector.js - About 1 hr to fix

    Function persistenceSystem has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const persistenceSystem = (IEntity) => (Entity) => {
    
        return {
            create(req, res, next) {
                PersistenceServices(Entity)
    Severity: Minor
    Found in app/inventory/applications/persistenceRelationSystem.js - About 1 hr to fix

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

                  AccessServices(Entity, user)
                      .deleteRoles(req.params.id, req.params.idu, req.user)
                      .then(e => res.status(204).json(e))
                      .catch(next);
      Severity: Major
      Found in app/core/applications/accessApplication.js and 1 other location - About 1 hr to fix
      app/inventory/applications/dependenciesApplication.js on lines 39..42

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

      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

                  DepServices(Entity, field)
                      .deleteDep(req.params.id, req.params.idu, req.user)
                      .then(e => res.status(204).json(e))
                      .catch(next);
      Severity: Major
      Found in app/inventory/applications/dependenciesApplication.js and 1 other location - About 1 hr to fix
      app/core/applications/accessApplication.js on lines 50..53

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

      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

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

      module.exports = (Entity) => {
      
          return {
              accessSingleRoleRefs: (collections, _id = false) => {
      
      
      Severity: Minor
      Found in app/core/applications/transforms/hateoasTransform.js - About 1 hr to fix

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

            return PersistenceServices(Events)
                .find(query, user)
                .then((e) => validNotFound(e, e[1], limit, page))
                .then((e) => hateaosTransform(Events).collectionTransform(e[0], e[1], limit, page));
        Severity: Major
        Found in app/reports/services/schedulerEvents.js and 1 other location - About 1 hr to fix
        app/core/applications/persistenceApplication.js on lines 31..34

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

        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

                    PersistenceServices(Entity)
                        .find(query, user)
                        .then((e) => validNotFound(e, e[1], limit, page))
                        .then((e) => hateaosTransform(Entity).collectionTransform(e[0], e[1], limit, page))
        Severity: Major
        Found in app/core/applications/persistenceApplication.js and 1 other location - About 1 hr to fix
        app/reports/services/schedulerEvents.js on lines 17..20

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

        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

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

        const DepsApp = (Entity, DepServices = DDepServices) => {
        
            const field = 'deps';
        
            return {
        Severity: Minor
        Found in app/inventory/applications/dependenciesApplication.js - About 1 hr to fix

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

                  async render(data) {
                      if (!template)
                          template = await populate();
          
                      const {task, _id} = data;
          Severity: Minor
          Found in app/reports/services/templates/connections.js - About 1 hr to fix

            Function MapFileType has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const MapFileType = (type=null) => {
                const tprivate = {
                    "application/json": "json",
                    "text/csv": "csv",
                    "text/plain": "txt"
            Severity: Minor
            Found in app/core/repositories/maps/mapFileType.js - About 1 hr to fix

              Function connect has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  connect() {
              
                      const smtpConfig = {
                          host: process.env.SMTP_HOST,
                          port: process.env.SMTP_PORT,
              Severity: Minor
              Found in app/core/repositories/smtp/factoryMailer.js - About 1 hr to fix

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

                module.exports.encrypt = function(text){
                    const cipher = crypto.createCipher('aes-256-cbc', CIPHER);
                    const crypted = cipher.update(text,'utf8','hex') + cipher.final('hex');
                    return crypted;
                };
                Severity: Minor
                Found in app/core/libs/crypto.js and 1 other location - About 55 mins to fix
                app/core/libs/crypto.js on lines 26..30

                Duplicated Code

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

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

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

                Tuning

                This issue has a mass of 69.

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

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

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

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

                Refactorings

                Further Reading

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

                module.exports.decrypt = function(text){
                    const decipher = crypto.createDecipher('aes-256-cbc', CIPHER);
                    const dec = decipher.update(text,'hex','utf8') + decipher.final('utf8');
                    return dec;
                };
                Severity: Minor
                Found in app/core/libs/crypto.js and 1 other location - About 55 mins to fix
                app/core/libs/crypto.js on lines 20..24

                Duplicated Code

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

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

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

                Tuning

                This issue has a mass of 69.

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

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

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

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

                Refactorings

                Further Reading

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

                        find: (req, res, next) => {
                          req.query[`${Entity.name}._id`] = _.get(req, 'params.id');
                
                          FactoryPesistenceApp(REntity)
                              .find(req, res, next);
                Severity: Minor
                Found in app/core/applications/relationsApplication.js and 1 other location - About 50 mins to fix
                app/core/applications/relationsApplication.js on lines 17..22

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

                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

                        count: (req, res, next) => {
                          req.query[`${Entity.name}._id`] = _.get(req, 'params.id');
                
                          FactoryPesistenceApp(REntity)
                              .count(req, res, next);
                Severity: Minor
                Found in app/core/applications/relationsApplication.js and 1 other location - About 50 mins to fix
                app/core/applications/relationsApplication.js on lines 10..15

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

                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

                Function where has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                Query.prototype.where = function (key, value) {
                    // if object was passed instead of key-value pair
                    // iterate over that object and call .where(key, value)
                    if (_.isObject(key)) {
                        let conditions = key;
                Severity: Minor
                Found in app/core/repositories/daos/connector/query.js - About 45 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function validateFile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                const validateFile = (file, opts) => {
                
                    const defaultParams = {
                        maxsize: process.env.MAESTRO_UPLOAD_MAXSIZE | 16302400, //~10 mb,
                        minsize: process.env.MAESTRO_UPLOAD_MINSIZE | 1, // 1 kbs
                Severity: Minor
                Found in app/core/services/validator/uploadValid.js - About 45 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

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

                Query.prototype.find = function (query, options) {
                    let Model = this.model;
                
                    query = _.assign({}, this.query, query);
                
                
                Severity: Minor
                Found in app/core/repositories/daos/connector/query.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

                Severity
                Category
                Status
                Source
                Language