appserver-io/webserver

View on GitHub
src/AppserverIo/WebServer/Modules/Rewrite/Entities/Rule.php

Summary

Maintainability
C
1 day
Test Coverage

Function apply has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function apply(RequestContextInterface $requestContext, ResponseInterface $response, array $serverBackreferences)
    {
        // First of all we have to resolve the target string with the backreferences of the matching condition
        // Separate the keys from the values so we can use them in str_replace
        // And also mix in the server's backreferences for good measure
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/Rewrite/Entities/Rule.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 matches has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function matches()
    {
        // We will iterate over all conditions (and the or-combined condition groups) and if there is a non-matching
        // condition or condition group we will fail
        foreach ($this->sortedConditions as $sortedCondition) {
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/Rewrite/Entities/Rule.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 apply has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function apply(RequestContextInterface $requestContext, ResponseInterface $response, array $serverBackreferences)
    {
        // First of all we have to resolve the target string with the backreferences of the matching condition
        // Separate the keys from the values so we can use them in str_replace
        // And also mix in the server's backreferences for good measure
Severity: Major
Found in src/AppserverIo/WebServer/Modules/Rewrite/Entities/Rule.php - About 2 hrs to fix

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

    public function __construct($conditionString, $target, $flagString)
    {
        // Set the raw string properties and append our default operand to the condition string
        $this->conditionString = $conditionString;
        $conditionString .= $this->getDefaultOperand();
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/Rewrite/Entities/Rule.php - About 1 hr to fix

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

    public function __construct($conditionString, $target, $flagString)
    {
        // Set the raw string properties and append our default operand to the condition string
        $this->conditionString = $conditionString;
        $conditionString .= $this->getDefaultOperand();
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/Rewrite/Entities/Rule.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 getBackreferences has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getBackreferences()
    {
        // Iterate over all conditions and collect their backreferences
        $backreferences = array();
        foreach ($this->sortedConditions as $key => $sortedCondition) {
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/Rewrite/Entities/Rule.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 resolveConditions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function resolveConditions(array $backreferences)
    {
        // Iterate over all conditions and resolve them too
        foreach ($this->sortedConditions as $key => $sortedCondition) {
            // If we got an array we have to iterate over it separately, but be aware they are or-combined
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/Rewrite/Entities/Rule.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