Asymmetrik/mean2-starter

View on GitHub

Showing 230 of 230 total issues

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

    function filterResourcesByAccess(ids, user) {
        if (!_.isArray(ids)) {
            return q([]);
        }
        else {
Severity: Minor
Found in src/server/app/resources/services/resources.server.service.js - About 1 hr to fix

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

    module.exports = function(columns) {
    
        // Create a stream to turn Mongo records into CSV rows
        var stream = through2.obj(function (chunk, enc, callback) {
            var row = [];
    Severity: Minor
    Found in src/server/app/util/services/csv-stream.server.service.js - About 1 hr to fix

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

              auditService.audit('message updated', 'message', 'update',
                  User.auditCopy(req.user, util.getHeaderField(req.headers, 'x-real-ip')),
                  { before: originalMessage, after: Message.auditCopy(message) }, req.headers);
      src/server/app/admin/controllers/users/users.profile.server.controller.js on lines 337..339

      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

                  auditService.audit('admin user updated', 'user', 'admin update',
                      User.auditCopy(req.user, util.getHeaderField(req.headers, 'x-real-ip')),
                      { before: originalUser, after: User.auditCopy(user) }, req.headers);
      src/server/app/messages/controllers/message.server.controller.js on lines 118..120

      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

      let
          async = require('async'),
          crypto = require('crypto'),
          path = require('path'),
      
      
      src/server/app/admin/controllers/users/users.profile.server.controller.js on lines 3..14

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

      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

      let _ = require('lodash'),
          path = require('path'),
          q = require('q'),
      
          deps = require(path.resolve('./src/server/dependencies.js')),
      src/server/app/admin/controllers/users/users.password.server.controller.js on lines 3..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 66.

      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

              req.on('close', () => {
                  logger.info('Plaintext export aborted because client dropped the connection');
                  if (s != null) {
                      s.destroy();
                  }
      src/server/app/util/controllers/export-config.server.controller.js on lines 84..91

      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

              req.on('close', () => {
                  logger.info('CSV export aborted because client dropped the connection');
                  if (s != null) {
                      s.destroy();
                  }
      src/server/app/util/controllers/export-config.server.controller.js on lines 124..131

      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

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

          protected handleErrorResponse(err: any, _caught: Observable<any>): Observable<any> {
              let errData = _.isString(err._body) ? JSON.parse(err._body) : err._body;
              switch (err.status) {
                  case 401:
      
      
      Severity: Minor
      Found in src/client/app/shared/asy-http.service.ts - About 1 hr to fix

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

        module.exports.searchEuas = (req, res) => {
        
            // Handle the query/search/page
            let query = req.body.q;
            let search = req.body.s;
        Severity: Minor
        Found in src/server/app/admin/controllers/users/eua.server.controller.js - About 1 hr to fix

          Function pagingQuery has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function pagingQuery(schema, find, projection, options, sort, limit, offset, runCount) {
          
              // Build the query
              var baseQuery = schema.find(find);
              var findQuery = schema.find(find, projection, options).sort(sort).skip(offset).limit(limit).maxscan(config.maxScan);
          Severity: Minor
          Found in src/server/app/util/services/query.server.service.js - About 1 hr to fix

            Function getTimeFilterQueryObject has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                private getTimeFilterQueryObject(): any {
                    let timeQuery: any = null;
            
                    if (this.dateRangeFilter.selected === 'choose') {
                        if (null != this.queryStartDate) {
            Severity: Minor
            Found in src/client/app/audit/audit.component.ts - 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 initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public initialize() {
            
                    // Subscribe to state changes
                    this.notificationStateService.notificationsCleared$
                        .subscribe((clear) => {
            Severity: Minor
            Found in src/client/app/notifications/notification-handler.service.ts - About 1 hr to fix

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

              exports.search = function(req, res) {
                  // Handle the query/search/page
                  let query = req.body.q;
                  let search = req.body.s;
              
              
              Severity: Minor
              Found in src/server/app/messages/controllers/message.server.controller.js - About 1 hr to fix

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

                exports.matchUsers = (req, res) => {
                    // Handle the query/search/page
                    let query = req.body.q;
                    let search = req.body.s;
                
                

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

                  function searchUsers(req, res, copyUserFn) {
                  
                      // Handle the query/search/page
                      let query = req.body.q;
                      let search = req.body.s;

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

                    module.exports.searchEntries = function(req, res) {
                    
                        // Handle the query/search/page
                        var query = req.body.q;
                        var search = req.body.s;

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

                      exports.matchEntries = function(req, res) {
                          // Handle the query/search/page
                          var query = req.body.q;
                          var search = req.body.s;
                      
                      

                        Function ngOnInit has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            ngOnInit() {
                                this.dateRangeOptions = [
                                    { value: -1, display: 'Last 24 Hours' },
                                    { value: -3, display: 'Last 3 Days' },
                                    { value: -7, display: 'Last 7 Days' },
                        Severity: Minor
                        Found in src/client/app/audit/audit.component.ts - About 1 hr to fix

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

                                              updateUser(dn, { externalRoles: [], externalGroups: [] }).then(function(updatedUser) {
                                                      // Audit user signup
                                                      return auditService.audit('user updated from access checker', 'user', 'update',
                                                          User.auditCopy(localUser),
                                                          User.auditCopy(updatedUser)).then(function() {
                          Severity: Major
                          Found in src/server/lib/strategies/proxy-pki.js and 1 other location - About 1 hr to fix
                          src/server/lib/strategies/proxy-pki.js on lines 218..225

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

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language