wikimedia/mediawiki-core

View on GitHub
includes/api/ApiAuthManagerHelper.php

Summary

Maintainability
C
1 day
Test Coverage

File ApiAuthManagerHelper.php has 259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Copyright © 2016 Wikimedia Foundation and contributors
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Minor
Found in includes/api/ApiAuthManagerHelper.php - About 2 hrs to fix

    Method getStandardParams has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function getStandardParams( $action, ...$wantedParams ) {
            $params = [
                'requests' => [
                    ParamValidator::PARAM_TYPE => 'string',
                    ParamValidator::PARAM_ISMULTI => true,
    Severity: Minor
    Found in includes/api/ApiAuthManagerHelper.php - About 1 hr to fix

      Method formatAuthenticationResponse has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function formatAuthenticationResponse( AuthenticationResponse $res ) {
              $ret = [
                  'status' => $res->status,
              ];
      
      
      Severity: Minor
      Found in includes/api/ApiAuthManagerHelper.php - About 1 hr to fix

        Method formatRequests has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function formatRequests( array $reqs ) {
                $params = $this->module->extractRequestParams();
                $mergeFields = !empty( $params['mergerequestfields'] );
        
                $ret = [ 'requests' => [] ];
        Severity: Minor
        Found in includes/api/ApiAuthManagerHelper.php - About 1 hr to fix

          Method loadAuthenticationRequests has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function loadAuthenticationRequests( $action ) {
                  $params = $this->module->extractRequestParams();
          
                  $reqs = $this->authManager->getAuthenticationRequests( $action, $this->module->getUser() );
          
          
          Severity: Minor
          Found in includes/api/ApiAuthManagerHelper.php - About 1 hr to fix

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

                public function formatAuthenticationResponse( AuthenticationResponse $res ) {
                    $ret = [
                        'status' => $res->status,
                    ];
            
            
            Severity: Minor
            Found in includes/api/ApiAuthManagerHelper.php - 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 formatRequests has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function formatRequests( array $reqs ) {
                    $params = $this->module->extractRequestParams();
                    $mergeFields = !empty( $params['mergerequestfields'] );
            
                    $ret = [ 'requests' => [] ];
            Severity: Minor
            Found in includes/api/ApiAuthManagerHelper.php - About 45 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