RackHD/on-http

View on GitHub
lib/services/swagger-api-service.js

Summary

Maintainability
F
4 days
Test Coverage

Function swaggerFactory has 328 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function swaggerFactory(
    Promise,
    Errors,
    _,
    injector,
Severity: Major
Found in lib/services/swagger-api-service.js - About 1 day to fix

    Function swaggerFactory has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
    Open

    function swaggerFactory(
        Promise,
        Errors,
        _,
        injector,
    Severity: Minor
    Found in lib/services/swagger-api-service.js - About 1 day 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

    File swagger-api-service.js has 372 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Copyright 2016, EMC, Inc.
    
    'use strict';
    
    var di = require('di');
    Severity: Minor
    Found in lib/services/swagger-api-service.js - About 4 hrs to fix

      Function _render has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function _render(viewName, req, res) {
              var options;
      
              return Promise.try(function() {
                  assert.optionalString(viewName);
      Severity: Major
      Found in lib/services/swagger-api-service.js - About 2 hrs to fix

        Function makeRenderableOptions has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function makeRenderableOptions(req, res, context, ignoreLookup) {
                var scope = res.locals.scope;
                var apiServer = util.format('http://%s:%d',
                    config.get('apiServerAddress'),
                    config.get('apiServerPort')
        Severity: Major
        Found in lib/services/swagger-api-service.js - About 2 hrs to fix

          Function _addLinksHeader has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function _addLinksHeader(req, res, count) {
                  var skip = req.swagger.query.$skip;
                  var top = req.swagger.query.$top;
                  var uriBase = req.url.split('?')[0];
          
          
          Severity: Major
          Found in lib/services/swagger-api-service.js - About 2 hrs to fix

            Function swaggerFactory has 15 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                Promise,
                Errors,
                _,
                injector,
                views,
            Severity: Major
            Found in lib/services/swagger-api-service.js - About 1 hr to fix

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

                  function swaggerController(options, callback) {
                      if (typeof options === 'function') {
                          callback = options;
                          options = {};
                      }
              Severity: Minor
              Found in lib/services/swagger-api-service.js - About 1 hr to fix

                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

                  There are no issues that match your filters.

                  Category
                  Status