Asymmetrik/mean2-starter

View on GitHub

Showing 230 of 230 total issues

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

                    updateUser(dn, copyACGroups(copyACRoles(copyACMetadata({}, acUser), acUser), acUser)).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 196..203

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

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

router.route('/admin/user/:userId')
    .get(   users.hasAdminAccess, users.adminGetUser)
    .post(  users.hasAdminAccess, users.adminUpdateUser)
    .delete(users.hasAdminAccess, users.adminDeleteUser);
Severity: Major
Found in src/server/app/admin/routes/users.server.routes.js and 2 other locations - About 1 hr to fix
src/server/app/admin/routes/eua.server.routes.js on lines 26..29
src/server/app/messages/routes/messages.server.routes.js on lines 22..25

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

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

router.route('/eua/:euaId')
    .get(   users.hasAdminAccess, users.getEuaById)
    .post(  users.hasAdminAccess, users.updateEua)
    .delete(users.hasAdminAccess, users.deleteEua);
Severity: Major
Found in src/server/app/admin/routes/eua.server.routes.js and 2 other locations - About 1 hr to fix
src/server/app/admin/routes/users.server.routes.js on lines 41..44
src/server/app/messages/routes/messages.server.routes.js on lines 22..25

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

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

router.route('/admin/message/:msgId')
    .get(   users.hasAccess, messages.read)
    .post(  users.hasAdminAccess, messages.update)
    .delete(users.hasAdminAccess, messages.delete);
Severity: Major
Found in src/server/app/messages/routes/messages.server.routes.js and 2 other locations - About 1 hr to fix
src/server/app/admin/routes/eua.server.routes.js on lines 26..29
src/server/app/admin/routes/users.server.routes.js on lines 41..44

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

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

    ngOnInit() {
        this.alertService.clearAllAlerts();

        this.user = this.authService.getCurrentUser();

Severity: Minor
Found in src/client/app/teams/list-team-members.component.ts - About 1 hr to fix

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

    exports.search = function(req, res) {
        let search = req.body.s || null;
        let query = req.body.q || {};
        query = util.toMongoose(query);
    
    
    Severity: Minor
    Found in src/server/app/audit/controllers/audit.server.controller.js - About 1 hr to fix

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

      exports.adminGetFeedbackCSV = function(req, res) {
          let exportFileName;
          const exportId = req.params.exportId;
      
          const dateCallback = (value) => (value) ? new Date(value).toISOString(): '';
      Severity: Minor
      Found in src/server/app/core/controllers/core.server.controller.js - About 1 hr to fix

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

        const sendMail = (mailOptions) => {
        
            return new Promise((resolve, reject) => {
                const postData = JSON.stringify(transformMailOptions(mailOptions));
                const options = generateOptions();
        Severity: Minor
        Found in src/server/app/util/providers/email/https-email.server.provider.js - About 1 hr to fix

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

              private getQuery(): any {
                  let query: any;
                  let elements: any[] = [];
          
                  if (this.filters.bypassAC) {
          Severity: Minor
          Found in src/client/app/admin/user-management/admin-list-users.component.ts - About 1 hr to fix

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

            module.exports.signupEmail = function(user, req) {
                let defer = q.defer();
            
                req.app.render('../../admin/templates/user-signup-alert-email', {
                    name: user.name,

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

              module.exports.audit = function(message, eventType, eventAction, eventActor, eventObject, eventMetadata) {
                  let Audit = dbs.admin.model('Audit');
                  let utilService = deps.utilService;
              
                  // Extract additional metadata to audit
              Severity: Minor
              Found in src/server/app/audit/services/audit.server.service.js - About 1 hr to fix

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

                module.exports = function(app, db) {
                
                    // Create a new HTTP server
                    logger.info('Creating HTTP Server');
                    var server = http.createServer(app);
                Severity: Minor
                Found in src/server/lib/socket.io.js - About 1 hr to fix

                  Function searchTeamMembers has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function searchTeamMembers(search, query, queryParams, team) {
                          let page = util.getPage(queryParams);
                          let limit = util.getLimit(queryParams);
                  
                          let offset = page * limit;
                  Severity: Minor
                  Found in src/server/app/teams/services/teams.server.service.js - About 1 hr to fix

                    Function verify has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    module.exports.verify = function(role) {
                    
                        return function(req, res, next) {
                            // Grab the Authentication header
                            var authentication = req.headers.authentication;
                    Severity: Minor
                    Found in src/server/app/util/services/token-auth.server.service.js - About 1 hr to fix

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

                          if (_.isArray(src.tags)) {
                              toReturn.tags = src.tags.map((t) => _.pick(t, ['_id']));
                          }
                      Severity: Major
                      Found in src/server/app/resources/models/resource.server.model.js and 1 other location - About 1 hr to fix
                      src/server/app/resources/models/resource.server.model.js on lines 144..146

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

                      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 (_.isArray(src.tags)) {
                              toReturn.tags = src.tags.map((t) => _.pick(t, ['_id']));
                          }
                      Severity: Major
                      Found in src/server/app/resources/models/resource.server.model.js and 1 other location - About 1 hr to fix
                      src/server/app/resources/models/resource.server.model.js on lines 129..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 57.

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

                      function getValidationErrors(err) {
                          var errors = [];
                      
                          if(null != err.errors) {
                              for (var field in err.errors) {
                      Severity: Minor
                      Found in src/server/app/util/services/util.server.service.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 verify has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                      module.exports.verify = function(role) {
                      
                          return function(req, res, next) {
                              // Grab the Authentication header
                              var authentication = req.headers.authentication;
                      Severity: Minor
                      Found in src/server/app/util/services/token-auth.server.service.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 getGlobbedPaths has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      let getGlobbedPaths = (globPatterns, excludes) => {
                          // URL paths regex
                          let urlRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
                      
                          // The output array
                      Severity: Minor
                      Found in src/server/config.js - About 1 hr to fix

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

                        module.exports.get = function (id) {
                            var defer = q.defer();
                        
                            if(null == id) {
                                return q.reject('id cannot be null or undefined');
                          Severity
                          Category
                          Status
                          Source
                          Language