Zimbra-Community/js-zimbra

View on GitHub

Showing 41 of 41 total issues

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

    try {

        options = new requestOptions.AddRequest().validate(originalOptions);

    } catch (err) {
Severity: Major
Found in lib/api/request.js and 2 other locations - About 5 hrs to fix
lib/api/communication.js on lines 234..270
lib/utils/preauth.js on lines 30..66

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

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

        try {

            options = new preauthOptions.CreatePreauth().validate(options);

        } catch (err) {
Severity: Major
Found in lib/utils/preauth.js and 2 other locations - About 5 hrs to fix
lib/api/communication.js on lines 234..270
lib/api/request.js on lines 66..92

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

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

    try {

        options = new communicationOptions.Auth().validate(originalOptions);

    } catch (err) {
Severity: Major
Found in lib/api/communication.js and 2 other locations - About 5 hrs to fix
lib/api/request.js on lines 66..92
lib/utils/preauth.js on lines 30..66

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

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

File communication.js has 331 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var communicationOptions = require('../options/communication'),
    communicationErrors = require('../errors/communication'),
    commonErrors = require('../errors/common'),
    RequestApi = require('./request'),
    ResponseApi = require('./response'),
Severity: Minor
Found in lib/api/communication.js - About 3 hrs to fix

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

    module.exports = function (grunt) {
    
        // Project configuration.
        grunt.initConfig(
            {
    Severity: Major
    Found in Gruntfile.js - About 3 hrs to fix

      Function send has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      CommunicationApi.prototype.send = function (request, callback) {
      
          var that = this;
      
          LOG.debug('CommunicationApi#send called');
      Severity: Major
      Found in lib/api/communication.js - About 3 hrs to fix

        Function getRequest has 76 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        CommunicationApi.prototype.getRequest = function (originalOptions, callback) {
        
            var options;
        
            LOG.debug('CommunicationApi#getRequest called');
        Severity: Major
        Found in lib/api/communication.js - About 3 hrs to fix

          Function auth has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          CommunicationApi.prototype.auth = function (originalOptions, callback) {
          
              var options;
          
              LOG.debug('CommunicationApi#auth called');
          Severity: Major
          Found in lib/api/communication.js - About 2 hrs to fix

            Function _authSecret has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function (options, callback, err, secret) {
            
                    LOG.debug('CommunicationApi#_authSecret called');
            
                    var that = this;
            Severity: Major
            Found in lib/api/communication.js - About 2 hrs to fix

              Function getRequest has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              RequestApi.prototype.getRequest = function (callback) {
              
                  var request = {
                      Header: {
                          context: this.options.context
              Severity: Minor
              Found in lib/api/request.js - About 1 hr to fix

                Function createPreauth has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    createPreauth: function (options, callback) {
                
                        LOG.debug('preauth#createPreauth called');
                        LOG.debug('Validating options');
                
                
                Severity: Minor
                Found in lib/utils/preauth.js - About 1 hr to fix

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

                                              if (data.Body.Fault.hasOwnProperty('Reason') &&
                                                  data.Body.Fault.Reason.hasOwnProperty('Text')) {
                  
                                                  reason = data.Body.Fault.Reason.Text;
                  
                  
                  Severity: Major
                  Found in lib/api/communication.js and 1 other location - About 1 hr to fix
                  lib/api/communication.js on lines 500..505

                  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

                  Function _createResponseView has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                  ResponseApi.prototype._createResponseView = function () {
                  
                      LOG.debug('ResponseApi#_createResponseView called');
                  
                      if (this.options.request.isBatch()) {
                  Severity: Minor
                  Found in lib/api/response.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 getRequest has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                  RequestApi.prototype.getRequest = function (callback) {
                  
                      var request = {
                          Header: {
                              context: this.options.context
                  Severity: Minor
                  Found in lib/api/request.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

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

                                              if (data.Body.Fault.hasOwnProperty('Code') &&
                                                  data.Body.Fault.Code.hasOwnProperty('Value')) {
                  
                                                  code = data.Body.Fault.Code.Value;
                  
                  
                  Severity: Major
                  Found in lib/api/communication.js and 1 other location - About 1 hr to fix
                  lib/api/communication.js on lines 516..521

                  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

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

                  RequestApi.prototype.addRequest = function (originalOptions, callback) {
                  
                      var options;
                  
                      LOG.debug('RequestApi#addRequest called');
                  Severity: Minor
                  Found in lib/api/request.js - About 1 hr to fix

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

                    ResponseApi.prototype._createResponseView = function () {
                    
                        LOG.debug('ResponseApi#_createResponseView called');
                    
                        if (this.options.request.isBatch()) {
                    Severity: Minor
                    Found in lib/api/response.js - About 1 hr to fix

                      Function getRequest has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                      CommunicationApi.prototype.getRequest = function (originalOptions, callback) {
                      
                          var options;
                      
                          LOG.debug('CommunicationApi#getRequest called');
                      Severity: Minor
                      Found in lib/api/communication.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

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

                          try {
                      
                              this.options =
                                  new requestOptions.Constructor().validate(constructorOptions);
                      
                      
                      Severity: Major
                      Found in lib/api/request.js and 1 other location - About 1 hr to fix
                      lib/api/response.js on lines 27..38

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

                      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

                          try {
                      
                              this.options =
                                  new responseOptions.Constructor().validate(constructorOptions);
                      
                      
                      Severity: Major
                      Found in lib/api/response.js and 1 other location - About 1 hr to fix
                      lib/api/request.js on lines 28..41

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

                      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