RackHD/on-http

View on GitHub

Showing 440 of 440 total issues

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

var listDCIMPowerDefault = controller(function (req, res) {
    var identifier = req.swagger.params.identifier.value;
    return nodeApi.getNodeCatalogSourceById(identifier, req.url);
});
Severity: Major
Found in lib/api/redfish-1.0/dcimpower.js and 1 other location - About 1 hr to fix
lib/api/redfish-1.0/dcimcooling.js on lines 73..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 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

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

module.exports = {
    eventServiceRoot: eventServiceRoot,
    createSubscription: createSubscription,
    getEventsCollection: getEventsCollection,
    getEvent: getEvent,
Severity: Major
Found in lib/api/redfish-1.0/event-service.js and 1 other location - About 1 hr to fix
lib/api/2.0/pollers.js on lines 207..217

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

function factory(Promise, Errors, waterline, uuid, assert,  _, fs) {

    fs = Promise.promisifyAll(fs);

    function FileManager(config) {
Severity: Minor
Found in lib/services/files/file-plugin.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 swaggerValidator has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function swaggerValidator() {
        var namespace = '/api/2.0/schemas/';
        var schemaPath = path.resolve(__dirname, '../../static/schemas/2.0');
        var namespace1Added = schemaApiService.addNamespace(schemaPath, namespace);

Severity: Minor
Found in lib/services/swagger-api-service.js - About 1 hr to fix

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

        return function swagger_authn_authz(context, next) {    // jshint ignore:line
            if(context.request.user) {
                ready.then(function() {
                    return authz.aclMethod('isAllowed',
                        context.request.user,
    Severity: Minor
    Found in lib/fittings/swagger_authz.js - About 1 hr to fix

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

      var modifyUser = controller(function(req) {
          var name = req.swagger.params.name.value;
          var userObj = _.pick(req.swagger.params.body.value, ['password', 'role']);
          var configureUsersAllows = ['password', 'role'];
          var configureSelfAllows = ['password'];
      Severity: Minor
      Found in lib/api/2.0/users.js - About 1 hr to fix

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

            AuthService.prototype.authMiddlewareLogin = function(req, res, next) {
                var self = this;
        
                passport.authenticate('local', {
                        session: false
        Severity: Minor
        Found in lib/services/auth-service.js - About 1 hr to fix

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

                  return function handleErrorMiddleware(err, req, res, next) {
                      // TODO - implement custom error type serializers
                      if (err instanceof Error || err instanceof ErrorEvent) {
                          var message = err.message || http.STATUS_CODES[err.status] || 'Unspecified Error';
                          logger.error(message, {
          Severity: Minor
          Found in lib/services/rest-api-service.js - About 1 hr to fix

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

            function LookupFactory (Serializable) {
                function Lookup (defaults) {
                    Serializable.call(
                        this,
                        Lookup.schema,
            Severity: Minor
            Found in lib/serializables/v1/lookup.js - About 1 hr to fix

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

                  FileStreamer.prototype.putFile = function(req, filename) {
                      var self = this;
              
                      return new Promise(function(resolve, reject) {
                          self.put(req, filename)
              Severity: Minor
              Found in lib/services/file-service.js - About 1 hr to fix

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

                                _.forEach(controllers[index], function (ele) {
                                    if (ele.SMART.Identity) {
                                        options.devices.push(ele.SMART);
                                    }
                                });
                Severity: Major
                Found in lib/api/redfish-1.0/systems.js and 1 other location - About 1 hr to fix
                lib/api/redfish-1.0/systems.js on lines 957..961

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

                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 nodesPostSshById = controller({success: 201}, function(req) {
                    return nodes.postNodeSshById(req.swagger.params.identifier.value, req.body);
                });
                Severity: Major
                Found in lib/api/2.0/nodes.js and 1 other location - About 1 hr to fix
                lib/api/2.0/nodes.js on lines 152..154

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

                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

                                    _.forEach(controllers[index], function(ele) {
                                        if(ele.SMART.Identity){
                                            options.devices.push(ele.SMART);
                                        }
                                    });
                Severity: Major
                Found in lib/api/redfish-1.0/systems.js and 1 other location - About 1 hr to fix
                lib/api/redfish-1.0/systems.js on lines 1126..1130

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

                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 nodesPutObmsByNodeId = controller({success: 201}, function(req) {
                    return nodes.putObmsByNodeId(req.swagger.params.identifier.value, req.body);
                });
                Severity: Major
                Found in lib/api/2.0/nodes.js and 1 other location - About 1 hr to fix
                lib/api/2.0/nodes.js on lines 45..47

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

                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

                            else if(node.type === Constants.NodeTypes.Pdu &&
                                    snmpSettings && node.autoDiscover) {
                                return workflowApiService.createAndRunGraph(
                                    {
                                        name: 'Graph.PDU.Discovery',
                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 333..371

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

                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

                            if(node.type === Constants.NodeTypes.Switch &&
                               snmpSettings && node.autoDiscover) {
                                return workflowApiService.createAndRunGraph(
                                    {
                                        name: 'Graph.Switch.Discovery',
                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 345..371

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

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

                    AccountApiService.prototype.modifyUserByName = function(name, info) {
                        var self = this;
                        return Promise.try(function() {
                            assert.string(name);
                            return waterline.localusers.findOne({username: name});
                Severity: Minor
                Found in lib/services/account-api-service.js - About 1 hr to fix

                  Function runClientObserver has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      UPnPService.prototype.runClientObserver = function(address) {
                          var self = this;
                          self.client = new Client({unicastHost:address});
                          self.client.on('response', function inResponse(headers, code, info) {
                              var ttl = parseInt(headers['CACHE-CONTROL'].split('=')[1].trim());
                  Severity: Minor
                  Found in lib/services/upnp-service.js - About 1 hr to fix

                    Function runRpc has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function runRpc(funcName) {
                            var _arguments = Array.prototype.slice.call(arguments);
                            var args = _arguments.slice(1);
                            return getClient()
                            .then(function(client) {
                    Severity: Minor
                    Found in lib/services/taskgraph-api-service.js - About 1 hr to fix

                      Function accountApiServiceFactory has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          waterline,
                          Errors,
                          Logger,
                          _,
                          Promise,
                      Severity: Major
                      Found in lib/services/account-api-service.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language