RackHD/on-http

View on GitHub

Showing 440 of 440 total issues

Function getSelLogService has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var getSelLogService = controller(function(req, res)  {
    var identifier = req.swagger.params.identifier.value;

    return redfish.getVendorNameById(identifier)
    .then(function(result){
Severity: Minor
Found in lib/api/redfish-1.0/systems.js - About 1 hr to fix

    Function UPnPService has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function UPnPService(options) {
            this.options = options || {};
            this.options.ssdpSig = 'node.js/' + nodeVersion + ' uPnP/1.1 on-http';
            this.options.ssdpTtl = 2;
            this.northbound = _.filter(configuration.get('httpEndpoints', []), 
    Severity: Minor
    Found in lib/services/upnp-service.js - About 1 hr to fix

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

      var profilesPutLibByName  = controller({success: 201}, function(req) {
          return profilesApiService.profilesPutLibByName(req.swagger.params.name.raw, req, req.swagger.query.scope);
      });
      Severity: Major
      Found in lib/api/2.0/profiles.js and 1 other location - About 1 hr to fix
      lib/api/2.0/templates.js on lines 30..32

      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

      var templatesLibPut = controller({success: 201}, function(req) {
          return templateApiService.templatesLibPut(req.swagger.params.name.raw, req, req.swagger.query.scope);
      });
      Severity: Major
      Found in lib/api/2.0/templates.js and 1 other location - About 1 hr to fix
      lib/api/2.0/profiles.js on lines 31..33

      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

      Function create has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function create(fittingDef, bagpipes) {
          var swaggerNodeRunner = bagpipes.config.swaggerNodeRunner;
          var appRoot = swaggerNodeRunner.config.swagger.appRoot;
          var serdesDirs = fittingDef.serdesDirs.map(function(dir) {
              return path.resolve(appRoot, dir);
      Severity: Minor
      Found in lib/fittings/swagger_serdes.js - About 1 hr to fix

        Function profileApiServiceFactory has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function profileApiServiceFactory(
            Promise,
            Logger,
            Errors,
            _,
        Severity: Minor
        Found in lib/services/profiles-api-service.js - About 1 hr to fix

          Function create has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function create(fittingDef) {
              var validate = validator();
              return function swagger_validator(context, next) {    // jshint ignore:line
                  if (!context.response.headersSent) {
                      var schemaNameKey = fittingDef.schemaNameKey;
          Severity: Minor
          Found in lib/fittings/rackhd_validator.js - About 1 hr to fix

            Function createHttpProxy has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function createHttpProxy(app, httpProxy){
                    var sep = path.sep; //The platform-specific file separator. '\\' or '/'
                    try {
                        var localPath = httpProxy.localPath || sep,
                            remotePath = httpProxy.remotePath || sep,
            Severity: Minor
            Found in lib/services/http-service.js - About 1 hr to fix

              Function templateApiServiceFactory has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function templateApiServiceFactory(
                  Promise,
                  Errors,
                  _,
                  taskgraphService,
              Severity: Minor
              Found in lib/services/templates-api-service.js - About 1 hr to fix

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

                    return function error_handler(context, next) {    // jshint ignore:line
                        if (!util.isError(context.error)) { return next(); }
                
                        var err = context.error;
                        var ERROR_STATUS = 400;
                Severity: Minor
                Found in lib/fittings/error_handler.js - About 1 hr to fix

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

                      AccountApiService.prototype.start = function() {
                          var acl = this.acl;
                          var self = this;
                          var endpoints = configuration.get('httpEndpoints', []);
                          var authEnabled = _(endpoints).filter(function(endpoint) {
                  Severity: Minor
                  Found in lib/services/account-api-service.js - About 1 hr to fix

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

                        return Promise.try(function() {
                            if(!req.isAuthenticated || !req.isAuthenticated()) {
                                throw new Errors.UnauthorizedError('Unauthorized');
                            }
                            return accountService.getUserByName(name);
                    Severity: Major
                    Found in lib/api/2.0/users.js and 1 other location - About 1 hr to fix
                    lib/api/redfish-1.0/account-service.js on lines 123..151

                    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

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

                        return Promise.try(function() {
                            if(!req.isAuthenticated || !req.isAuthenticated()) {
                                throw new Errors.UnauthorizedError('Unauthorized');
                            }
                            return accountService.getUserByName(name);
                    Severity: Major
                    Found in lib/api/redfish-1.0/account-service.js and 1 other location - About 1 hr to fix
                    lib/api/2.0/users.js on lines 53..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 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 redfishApiServiceFactory has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function redfishApiServiceFactory(
                        configuration,
                        Logger,
                        Promise,
                        _,
                    Severity: Minor
                    Found in lib/services/redfish-api-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 setSecureBoot has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    var setSecureBoot = controller(function(req, res)  {
                        //TODO Write logic for non racadm
                        var identifier = req.swagger.params.identifier.value;
                        var options = redfish.makeOptions(req, res, identifier);
                        var graphName = 'Graph.Dell.Wsman.ConfigureBios';
                    Severity: Minor
                    Found in lib/api/redfish-1.0/systems.js - About 1 hr to fix

                      Function unregisterPack has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          SkuPackService.prototype.unregisterPack = function(skuid, conf) {
                              var promises = [];
                              var self = this;
                              var skuRoot = self.confRoot + '/' + skuid;
                              var cleanup;
                      Severity: Minor
                      Found in lib/services/sku-pack-service.js - About 1 hr to fix

                        Function getFile has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            FileStreamer.prototype.getFile = function(req, res, id) {
                                var self = this;
                                var uuidFound;
                        
                                if (id.match(Constants.Regex.uuid)) {
                        Severity: Minor
                        Found in lib/services/file-service.js - About 1 hr to fix

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

                                  return Promise.resolve().then(function() {
                                      assert.string(tagName, 'tag must be a string');
                                  })
                                  .then(function() {
                                      return waterline.nodes.findByTag(tagName);
                          Severity: Major
                          Found in lib/services/nodes-api-service.js and 1 other location - About 1 hr to fix
                          lib/services/nodes-api-service.js on lines 690..699

                          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

                                  return Promise.resolve().then(function() {
                                      assert.isMongoId(id, 'the id must be a valid mongo id');
                                  })
                                  .then(function() {
                                      return waterline.nodes.needByIdentifier(id);
                          Severity: Major
                          Found in lib/services/nodes-api-service.js and 1 other location - About 1 hr to fix
                          lib/services/nodes-api-service.js on lines 663..674

                          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

                          Function swagger_validator has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              return function swagger_validator(context, next) {    // jshint ignore:line
                                  if (!context.response.headersSent) {
                                      var schemaNameKey = fittingDef.schemaNameKey;
                                      var operation = context.request.swagger.operation;
                                      var schemaName = operation[schemaNameKey];
                          Severity: Minor
                          Found in lib/fittings/rackhd_validator.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language