Aigeruth/docker-private-registry

View on GitHub
public/js/lib/swagger-oauth.js

Summary

Maintainability
C
1 day
Test Coverage

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

function handleLogin() {
  var scopes = [];

  if(window.swaggerUi.api.authSchemes 
    && window.swaggerUi.api.authSchemes.oauth2
Severity: Major
Found in public/js/lib/swagger-oauth.js - About 3 hrs to fix

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

    function onOAuthComplete(token) {
      if(token) {
        if(token.error) {
          var checkbox = $('input[type=checkbox],.secured')
          checkbox.each(function(pos){
    Severity: Minor
    Found in public/js/lib/swagger-oauth.js - About 1 hr to fix

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

      function handleLogin() {
        var scopes = [];
      
        if(window.swaggerUi.api.authSchemes 
          && window.swaggerUi.api.authSchemes.oauth2
      Severity: Minor
      Found in public/js/lib/swagger-oauth.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

      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);
                    }
      Severity: Major
      Found in public/js/lib/swagger-oauth.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if(diff.length > 0){
                      o = v.parentNode;
                      $(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
                      $(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
        
        
        Severity: Major
        Found in public/js/lib/swagger-oauth.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                        if(inner)
                          requiredScopes.push(inner);
          Severity: Major
          Found in public/js/lib/swagger-oauth.js - About 45 mins to fix

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

            function onOAuthComplete(token) {
              if(token) {
                if(token.error) {
                  var checkbox = $('input[type=checkbox],.secured')
                  checkbox.each(function(pos){
            Severity: Minor
            Found in public/js/lib/swagger-oauth.js - About 35 mins 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

            There are no issues that match your filters.

            Category
            Status