melphi/algobox

View on GitHub
java/algobox/algobox-microservice/src/main/resources/static/swagger/lib/swagger-oauth.js

Summary

Maintainability
D
2 days
Test Coverage

Function handleLogin has 147 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function handleLogin() {
  var scopes = [];

  var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions;
  if(auths) {

    Function handleLogin has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    function handleLogin() {
      var scopes = [];
    
      var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions;
      if(auths) {

    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-oauth.js has 301 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var appName;
    var popupMask;
    var popupDialog;
    var clientId;
    var realm;

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

      window.onOAuthComplete = function onOAuthComplete(token,OAuthSchemeKey) {
        if(token) {
          if(token.error) {
            var checkbox = $('input[type=checkbox],.secured')
            checkbox.each(function(pos){

        Function processOAuthCode has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        window.processOAuthCode = function processOAuthCode(data) {
          var OAuthSchemeKey = data.state;
        
          // redirect_uri is required in auth code flow 
          // see https://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.1.3

          Function onOAuthComplete has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          window.onOAuthComplete = function onOAuthComplete(token,OAuthSchemeKey) {
            if(token) {
              if(token.error) {
                var checkbox = $('input[type=checkbox],.secured')
                checkbox.each(function(pos){

          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

          Avoid deeply nested control flow statements.
          Open

                      if(diff.length > 0){
                        o = v.parentNode.parentNode;
                        $(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
                        $(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
          
          

            Avoid deeply nested control flow statements.
            Open

                        for(var i=0; i < requiredScopes.length; i++) {
                          var s = requiredScopes[i];
                          if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) {
                            diff.push(s);
                          }

              Avoid deeply nested control flow statements.
              Open

                            if(inner)
                              requiredScopes.push(inner);

                Avoid deeply nested control flow statements.
                Open

                            if(o.hasOwnProperty(t) && t === 'implicit') {
                              var dets = o[t];
                              var ep = dets.loginEndpoint.url;
                              url = dets.loginEndpoint.url + '?response_type=token';
                              window.swaggerUi.tokenName = dets.tokenName;

                  Avoid deeply nested control flow statements.
                  Open

                            for(i = 0; i < auth.scopes.length; i++) {
                              scopes.push(auth.scopes[i]);
                            }

                    Avoid deeply nested control flow statements.
                    Open

                              for(scope in auth.scopes) {
                                scopes.push({scope: scope, description: auth.scopes[scope], OAuthSchemeKey: key});
                              }

                      TODO found
                      Open

                          //TODO: merge not replace if scheme is different from any existing 

                      TODO found
                      Open

                        //TODO: only display applicable scopes (will need to pass them into handleLogin)

                      There are no issues that match your filters.

                      Category
                      Status