maestro-server/audit-app

View on GitHub

Showing 20 of 20 total issues

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

        patch(req, res, next) {
            let {body, params} = req;

            params = transfID(params, 'id');
            const {id:entity_id, entity, user} = _.defaults(params, {user: dUser});
Severity: Major
Found in app/audit/applications/persistenceAudit.js and 1 other location - About 1 day to fix
app/audit/applications/persistenceAudit.js on lines 55..73

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

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

        update(req, res, next) {
            let {body, params} = req;

            params = transfID(params, 'id');
            const {id:entity_id, entity, user} = _.defaults(params, {user: dUser});
Severity: Major
Found in app/audit/applications/persistenceAudit.js and 1 other location - About 1 day to fix
app/audit/applications/persistenceAudit.js on lines 75..93

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

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

Query.prototype.include = function (key, value) {
    if (Array.isArray(key)) {
        let projection = key;
        projection.forEach((k) => this.include(k));

Severity: Major
Found in app/core/repositories/daos/connector/query.js and 1 other location - About 6 hrs to fix
app/core/repositories/daos/connector/query.js on lines 82..99

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

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

Query.prototype.exclude = function (key, value) {

    if (Array.isArray(key)) {
        let projection = key;
        projection.forEach((k) => this.exclude(k));
Severity: Major
Found in app/core/repositories/daos/connector/query.js and 1 other location - About 6 hrs to fix
app/core/repositories/daos/connector/query.js on lines 64..80

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

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

    updateFactory(entity, entry, options) {

        return this._collection()
            .then((collection) => {
                const subs = entry ? {[entry]: this.get()} : this.get();
Severity: Major
Found in app/core/repositories/daos/DBConnector.js and 1 other location - About 3 hrs to fix
app/core/repositories/daos/DBConnector.js on lines 189..200

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

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

    updateManyFactory(entity, entry, options) {

        return this._collection()
            .then((collection) => {
                const subs = entry ? {[entry]: this.get()} : this.get();
Severity: Major
Found in app/core/repositories/daos/DBConnector.js and 1 other location - About 3 hrs to fix
app/core/repositories/daos/DBConnector.js on lines 176..187

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

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 DBRepository has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const DBRepository = (Entity, options = {}) => {

    const DB = Entity.dao;

    return {
Severity: Major
Found in app/core/repositories/DBRepository.js - About 3 hrs to fix

    Function ApplicationAudit has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const ApplicationAudit = (EntityStorage) => (Entity, PersistenceServices = DPersistenceServices) => {
    
        const AuditTrackCharged = AuditTrack(PersistenceServices(Entity));
        const dUser = "MaestroServer";
    
    
    Severity: Major
    Found in app/audit/applications/persistenceAudit.js - About 2 hrs to fix

      Function Persistence has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const Persistence = (Entity, FactoryDBRepository = DFactoryDBRepository) => {
      
          const DBRepository = FactoryDBRepository(Entity);
      
          return {
      Severity: Major
      Found in app/core/services/PersistenceServices.js - About 2 hrs to fix

        Function find has 50 lines of code (exceeds 25 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 2 hrs to fix

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

                  patch (entity_id, post) {
          
                      return new Promise((resolve, reject) => {
                          const fill = _.slice(Entity.singleFilled, 2);
          
          
          Severity: Major
          Found in app/core/services/PersistenceServices.js and 1 other location - About 1 hr to fix
          app/core/services/PersistenceServices.js on lines 54..64

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

          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

                  update (entity_id, post) {
          
                      return new Promise((resolve, reject) => {
                          const fill = _.slice(Entity.singleFilled, 2);
          
          
          Severity: Major
          Found in app/core/services/PersistenceServices.js and 1 other location - About 1 hr to fix
          app/core/services/PersistenceServices.js on lines 66..76

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

          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 HTTPService has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          const HTTPService = (url) => (header = {}) => {
          
              Object.assign(header, {Authorization: privateToken.token}); // inject private token, used to autheticate on private services
          
              const factoryRequest = (caller, path, args) => {
          Severity: Minor
          Found in app/core/services/HTTPService.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 HTTPService has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const HTTPService = (url) => (header = {}) => {
          
              Object.assign(header, {Authorization: privateToken.token}); // inject private token, used to autheticate on private services
          
              const factoryRequest = (caller, path, args) => {
          Severity: Minor
          Found in app/core/services/HTTPService.js - About 1 hr to fix

            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

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

              module.exports = (PersistenceStorage) => (body, entity, entity_id, user, created=false) => {
              
                  return new Promise((resolve, reject) => {
              
                      if (!_.isEmpty(body)) {
              Severity: Minor
              Found in app/audit/services/libs/recordTrack.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 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 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

              Function isID has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              const isID = (obj, relation, key = '_id') => {
                  const exist = _.get(obj, relation);
              
                  if(_.isArray(exist)) {
                      const interator = obj[relation].map(e=>isID(e, '', key));
              Severity: Minor
              Found in app/core/applications/transforms/mapRelationToObjectID.js - About 25 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 exports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = function () {
                  const passport = new Passport();
              
                  const strategy = new Strategy(config.jwtSecret, function (payload, done) {
              
              
              Severity: Minor
              Found in app/audit/config/auth_conector_private.js - About 25 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