biurad/php-http-galaxy

View on GitHub

Showing 46 of 46 total issues

Function getPreflightResponse has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getPreflightResponse(RequestInterface $request, ResponseInterface $response): ResponseInterface
    {
        $response = $response
            ->withHeader('Access-Control-Allow-Origin', true === $this->options['allow_origin'] ? '*' : $request->getHeaderLine('Origin'))
            ->withHeader('Vary', $response->hasHeader('Vary') ? $response->getHeaderLine('Vary') . ', Origin' : 'Origin');
Severity: Minor
Found in src/Middlewares/HttpCorsMiddleware.php - About 5 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 process has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    public function process(Request $request, RequestHandler $handler): ResponseInterface
    {
        $response = $handler->handle($request);

        if (empty($cspHeaders = $this->getCspHeaders($response))) {
Severity: Minor
Found in src/Middlewares/ContentSecurityPolicyMiddleware.php - About 4 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 process has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function process(Request $request, RequestHandler $handler): ResponseInterface
    {
        $response = $handler->handle($request);

        if (!empty($framePolicy = $this->policies['frame_policy'])) {
Severity: Minor
Found in src/Middlewares/HttpPolicyMiddleware.php - About 3 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 hasOrigin has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function hasOrigin(RequestInterface $request): bool
    {
        if (true === $allowedOrigin = $this->options['allow_origin']) {
            return true;
        }
Severity: Minor
Found in src/Middlewares/HttpCorsMiddleware.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

Method process has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process(Request $request, RequestHandler $handler): ResponseInterface
    {
        if ($request instanceof HttpRequest) {
            if (!$request->getRequest()->hasSession(true)) {
                // This variable prevents calling `$this->session` twice in case the Request (and the below factory) is cloned
Severity: Major
Found in src/Middlewares/SessionMiddleware.php - About 2 hrs to fix

    Uri has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Uri implements UriInterface
    {
        private const SCHEMES = ['http' => 80, 'https' => 443];
    
        private const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~';
    Severity: Minor
    Found in src/Uri.php - About 2 hrs to fix

      Function process has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public function process(Request $request, RequestHandler $handler): ResponseInterface
          {
              if ($request instanceof HttpRequest) {
                  if (!$request->getRequest()->hasSession(true)) {
                      // This variable prevents calling `$this->session` twice in case the Request (and the below factory) is cloned
      Severity: Minor
      Found in src/Middlewares/SessionMiddleware.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

      Method getPreflightResponse has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getPreflightResponse(RequestInterface $request, ResponseInterface $response): ResponseInterface
          {
              $response = $response
                  ->withHeader('Access-Control-Allow-Origin', true === $this->options['allow_origin'] ? '*' : $request->getHeaderLine('Origin'))
                  ->withHeader('Vary', $response->hasHeader('Vary') ? $response->getHeaderLine('Vary') . ', Origin' : 'Origin');
      Severity: Minor
      Found in src/Middlewares/HttpCorsMiddleware.php - About 1 hr to fix

        Function createUriString has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function createUriString(string $scheme, string $authority, string $path, string $query, string $fragment): string
            {
                $uri = '';
                if ('' !== $scheme) {
                    $uri .= $scheme . ':';
        Severity: Minor
        Found in src/Uri.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 getLine has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            protected static function getLine(StreamInterface $stream): string
            {
                $line = '';
                $crFound = false;
        
        
        Severity: Minor
        Found in src/Factory/Psr7Bridge.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 splitStream has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            protected static function splitStream(StreamInterface $stream): array
            {
                $headers = [];
                $currentHeader = false;
        
        
        Severity: Minor
        Found in src/Factory/Psr7Bridge.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 encodeResponseSetCookieHeaders has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function encodeResponseSetCookieHeaders(UriInterface $requestUri, ResponseInterface $response): ResponseInterface
            {
                $matchCookie = static function (Cookie $cookie) use ($requestUri): bool {
                    $cookiePath = $cookie->getPath();
                    $cookieDomain = $cookie->getDomain();
        Severity: Minor
        Found in src/Middlewares/CookiesMiddleware.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 process has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function process(Request $request, RequestHandler $handler): ResponseInterface
            {
                $response = $handler->handle($request);
        
                if (empty($cspHeaders = $this->getCspHeaders($response))) {
        Severity: Minor
        Found in src/Middlewares/ContentSecurityPolicyMiddleware.php - About 1 hr to fix

          Method process has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function process(Request $request, RequestHandler $handler): ResponseInterface
              {
                  $response = $handler->handle($request);
          
                  if (!empty($framePolicy = $this->policies['frame_policy'])) {
          Severity: Minor
          Found in src/Middlewares/HttpPolicyMiddleware.php - About 1 hr to fix

            Function buildPolicy has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                private function buildPolicy(array $config, ?array &$nonces = []): array
                {
                    $policies = [];
            
                    foreach ($config as $type => $policy) {
            Severity: Minor
            Found in src/Middlewares/HttpPolicyMiddleware.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 withCacheControl has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function withCacheControl(array $options, ResponseInterface $response): ResponseInterface
                {
                    $cacheControl = [];
                    self::validateOptions($options);
            
            
            Severity: Minor
            Found in src/Cache/CacheControl.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 encodeResponseSetCookieHeaders has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function encodeResponseSetCookieHeaders(UriInterface $requestUri, ResponseInterface $response): ResponseInterface
                {
                    $matchCookie = static function (Cookie $cookie) use ($requestUri): bool {
                        $cookiePath = $cookie->getPath();
                        $cookieDomain = $cookie->getDomain();
            Severity: Minor
            Found in src/Middlewares/CookiesMiddleware.php - About 1 hr to fix

              Method createResponse has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function createResponse(ResponseInterface $response, RequestInterface $request, CacheItemInterface $cacheItem)
                  {
                      if (304 === $response->getStatusCode()) {
                          // The cached response we have is still valid
                          if (!empty($data = $cacheItem->get())) {
              Severity: Minor
              Found in src/Middlewares/CacheControlMiddleware.php - About 1 hr to fix

                Method withCacheControl has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function withCacheControl(array $options, ResponseInterface $response): ResponseInterface
                    {
                        $cacheControl = [];
                        self::validateOptions($options);
                
                
                Severity: Minor
                Found in src/Cache/CacheControl.php - About 1 hr to fix

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

                      public function process(Request $request, RequestHandler $handler): ResponseInterface
                      {
                          $cookieParams = [];
                  
                          // Handle an incoming request cookie.
                  Severity: Minor
                  Found in src/Middlewares/CookiesMiddleware.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

                  Severity
                  Category
                  Status
                  Source
                  Language