wp-plugins/all-in-one-seo-pack

View on GitHub
OAuth.php

Summary

Maintainability
D
2 days
Test Coverage

File OAuth.php has 542 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/* OAuth PHP Library
 * http://oauth.googlecode.com/svn/code/php/
 *
 * License: The MIT License
Severity: Major
Found in OAuth.php - About 1 day to fix

    Function get_headers has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

          public static function get_headers() {
            if (function_exists('apache_request_headers')) {
              // we need this to get the actual Authorization: header
              // because apache tends to tell us it doesn't exist
              $headers = apache_request_headers();
    Severity: Minor
    Found in OAuth.php - About 2 hrs 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 parse_parameters has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          public static function parse_parameters( $input ) {
            if (!isset($input) || !$input) return array();
    
            $pairs = explode('&', $input);
    
    
    Severity: Minor
    Found in OAuth.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 to_header has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          public function to_header($realm=null) {
            $first = true;
            if($realm) {
              $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
              $first = false;
    Severity: Minor
    Found in OAuth.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 build_http_query has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          public static function build_http_query($params) {
            if (!$params) return '';
    
            // Urlencode both keys and values
            $keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
    Severity: Minor
    Found in OAuth.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

    Method from_request has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
            $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
                      ? 'http'
                      : 'https';
            $http_url = ($http_url) ? $http_url : $scheme .
    Severity: Minor
    Found in OAuth.php - About 1 hr to fix

      Method get_headers has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            public static function get_headers() {
              if (function_exists('apache_request_headers')) {
                // we need this to get the actual Authorization: header
                // because apache tends to tell us it doesn't exist
                $headers = apache_request_headers();
      Severity: Minor
      Found in OAuth.php - About 1 hr to fix

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

              public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
                $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
                          ? 'http'
                          : 'https';
                $http_url = ($http_url) ? $http_url : $scheme .
        Severity: Minor
        Found in OAuth.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 split_header has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              public static function split_header($header, $only_allow_oauth_parameters = true) {
                $params = array();
                if (preg_match_all('/('.($only_allow_oauth_parameters ? 'oauth_' : '').'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches)) {
                  foreach ($matches[1] as $i => $h) {
                    $params[$h] = OAuthUtil::urldecode_rfc3986(empty($matches[3][$i]) ? $matches[4][$i] : $matches[3][$i]);
        Severity: Minor
        Found in OAuth.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

        Method from_consumer_and_token has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
        Severity: Minor
        Found in OAuth.php - About 35 mins to fix

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

                public function set_parameter($name, $value, $allow_duplicates = true) {
                  if ($allow_duplicates && isset($this->parameters[$name])) {
                    // We have already added parameter(s) with this name, so add to the list
                    if (is_scalar($this->parameters[$name])) {
                      // This is the first duplicate, so transform scalar (string)
          Severity: Minor
          Found in OAuth.php - 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

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

                  public static function urlencode_rfc3986($input) {
                    if (is_array($input)) {
                      return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
                    } else if (is_scalar($input)) {
                      return str_replace(
          Severity: Minor
          Found in OAuth.php - 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

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

                public function check_signature($request, $consumer, $token, $signature) {
                  $built = $this->build_signature($request, $consumer, $token);
          
                  // Check for zero length, although unlikely here
                  if (strlen($built) == 0 || strlen($signature) == 0) {
          Severity: Minor
          Found in OAuth.php - 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