yiisoft/yii-web

View on GitHub

Showing 29 of 29 total issues

Method withAddedProtocolHeader has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function withAddedProtocolHeader(string $header, $values = null): self
    {
        $new = clone $this;
        $header = strtolower($header);
        if ($values === null) {
Severity: Minor
Found in src/Middleware/BasicNetworkResolver.php - About 1 hr to fix

    Function withAddedProtocolHeader has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function withAddedProtocolHeader(string $header, $values = null): self
        {
            $new = clone $this;
            $header = strtolower($header);
            if ($values === null) {
    Severity: Minor
    Found in src/Middleware/BasicNetworkResolver.php - About 55 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 createFromParameters has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function createFromParameters(array $server, array $headers = [], array $cookies = [], array $get = [], array $post = [], array $files = [], $body = null): ServerRequestInterface
    Severity: Major
    Found in src/ServerRequestFactory.php - About 50 mins to fix

      Method withAddedTrustedHosts has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              array $hosts,
              // Defining default headers is not secure!
              array $ipHeaders = [],
              array $protocolHeaders = [],
              array $hostHeaders = [],
      Severity: Major
      Found in src/Middleware/TrustedHostsNetworkResolver.php - About 50 mins to fix

        Method populateUploadedFileRecursive has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            private function populateUploadedFileRecursive(array &$files, $names, $tempNames, $types, $sizes, $errors): void
        Severity: Minor
        Found in src/ServerRequestFactory.php - About 45 mins to fix

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

              private function shouldOutputBody(ResponseInterface $response): bool
              {
                  if (in_array($response->getStatusCode(), self::NO_BODY_RESPONSE_CODES, true)) {
                      return false;
                  }
          Severity: Minor
          Found in src/SapiEmitter.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 true;
          Severity: Major
          Found in src/SapiEmitter.php - About 30 mins to fix

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

                private function populateUploadedFileRecursive(array &$files, $names, $tempNames, $types, $sizes, $errors): void
                {
                    if (is_array($names)) {
                        foreach ($names as $i => $name) {
                            $files[$i] = [];
            Severity: Minor
            Found in src/ServerRequestFactory.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 getUrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private function getUrl(RequestInterface $request, array $urlHeaders): ?array
                {
                    foreach ($urlHeaders as $header) {
                        if (!$request->hasHeader($header)) {
                            continue;
            Severity: Minor
            Found in src/Middleware/TrustedHostsNetworkResolver.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

            Severity
            Category
            Status
            Source
            Language