owncloud/core

View on GitHub
lib/private/AppFramework/Http/Request.php

Summary

Maintainability
D
2 days
Test Coverage

File Request.php has 442 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Bart Visscher <bartv@thisnet.nl>
 * @author Bernhard Posselt <dev@bernhard-posselt.com>
 * @author Joas Schilling <coding@schilljs.com>
Severity: Minor
Found in lib/private/AppFramework/Http/Request.php - About 6 hrs to fix

    Request has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Request implements ArrayAccess, Countable, IRequest {
        public const USER_AGENT_IE = '/(MSIE)|(Trident)/';
        public const USER_AGENT_IE_8 = '/MSIE 8.0/';
        // Microsoft Edge User Agent from https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
        public const USER_AGENT_MS_EDGE = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Chrome\/[0-9.]+ (Mobile Safari|Safari)\/[0-9.]+ Edge\/[0-9.]+$/';
    Severity: Minor
    Found in lib/private/AppFramework/Http/Request.php - About 4 hrs to fix

      Function getRemoteAddress has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getRemoteAddress() {
              $remoteAddress = $this->server['REMOTE_ADDR'] ?? '';
              $trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
      
              if (\is_array($trustedProxies) && \in_array($remoteAddress, $trustedProxies)) {
      Severity: Minor
      Found in lib/private/AppFramework/Http/Request.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 getRawPathInfo has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getRawPathInfo() {
              $requestUri = $this->server['REQUEST_URI'] ?? '';
              // remove too many leading slashes - can be caused by reverse proxy configuration
              if (\strpos($requestUri, '/') === 0) {
                  $requestUri = '/' . \ltrim($requestUri, '/');
      Severity: Minor
      Found in lib/private/AppFramework/Http/Request.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 decodeContent has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function decodeContent() {
              if ($this->contentDecoded) {
                  return;
              }
              $params = [];
      Severity: Minor
      Found in lib/private/AppFramework/Http/Request.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 getRawPathInfo has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getRawPathInfo() {
              $requestUri = $this->server['REQUEST_URI'] ?? '';
              // remove too many leading slashes - can be caused by reverse proxy configuration
              if (\strpos($requestUri, '/') === 0) {
                  $requestUri = '/' . \ltrim($requestUri, '/');
      Severity: Minor
      Found in lib/private/AppFramework/Http/Request.php - About 1 hr to fix

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

            public function getRequestUri() {
                $uri = $this->server['REQUEST_URI'] ?? '';
                // remove too many leading slashes - can be caused by reverse proxy configuration
                if (\strpos($uri, '/') === 0) {
                    $uri = '/' . \ltrim($uri, '/');
        Severity: Minor
        Found in lib/private/AppFramework/Http/Request.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 getInsecureServerHost has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getInsecureServerHost() {
                $host = 'localhost';
                if (isset($this->server['HTTP_X_FORWARDED_HOST'])) {
                    if (\strpos($this->server['HTTP_X_FORWARDED_HOST'], ',') !== false) {
                        $parts = \explode(',', $this->server['HTTP_X_FORWARDED_HOST']);
        Severity: Minor
        Found in lib/private/AppFramework/Http/Request.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 __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                array $vars= [],
                ISecureRandom $secureRandom = null,
                IConfig $config = null,
                CsrfTokenManager $csrfTokenManager = null,
                $stream = 'php://input'
        Severity: Minor
        Found in lib/private/AppFramework/Http/Request.php - About 35 mins to fix

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

              public function getServerProtocol() {
                  if ($this->config->getSystemValue('overwriteprotocol') !== ''
                      && $this->isOverwriteCondition('protocol')) {
                      return $this->config->getSystemValue('overwriteprotocol');
                  }
          Severity: Minor
          Found in lib/private/AppFramework/Http/Request.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

          Avoid too many return statements within this method.
          Open

                          return $this[$name] ?? null;
          Severity: Major
          Found in lib/private/AppFramework/Http/Request.php - About 30 mins to fix

            Function getId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getId() {
                    // allow clients to provide a request id
                    if (isset($this->server['HTTP_X_REQUEST_ID'])) {
                        $reqId = $this->server['HTTP_X_REQUEST_ID'];
                        if (\strlen($reqId) > 19
            Severity: Minor
            Found in lib/private/AppFramework/Http/Request.php - About 25 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 passesCSRFCheck has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function passesCSRFCheck() {
                    if ($this->csrfTokenManager === null) {
                        return false;
                    }
            
            
            Severity: Minor
            Found in lib/private/AppFramework/Http/Request.php - About 25 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