appserver-io/webserver

View on GitHub

Showing 68 of 68 total issues

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

    public function shutdown()
    {
        // get refs to local vars
        $requestContext = $this->getRequestContext();
        $connection = $this->getConnection();

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

    public function process(RequestInterface $request, ResponseInterface $response, RequestContextInterface $requestContext, $hook)
    {

        // if false hook is coming do nothing
        if (ModuleHooks::REQUEST_POST !== $hook) {
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/AuthenticationModule.php - About 1 hr to fix

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

    public function lookup($requestUri)
    {
        // set targetUrl to null by default
        $targetUrl = null;
        // set base to local ref

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

    public function logAccess()
    {
        // get object refs to local var
        $request = $this->getParser()->getRequest();
        $response = $this->getParser()->getResponse();

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

    public function process(RequestInterface $request, ResponseInterface $response, RequestContextInterface $requestContext, $hook)
    {
        // In php an interface is, by definition, a fixed contract. It is immutable.
        // So we have to declair the right ones afterwards...
        /**
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/RewriteMapModule.php - About 1 hr to fix

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

    public function shutdown()
    {
        // get refs to local vars
        $requestContext = $this->getRequestContext();
        $connection = $this->getConnection();

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 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process(RequestInterface $request, ResponseInterface $response, RequestContextInterface $requestContext, $hook)
    {
        // In php an interface is, by definition, a fixed contract. It is immutable.
        // So we have to declare the right ones afterwards...

Severity: Minor
Found in src/AppserverIo/WebServer/Modules/CoreModule.php - About 1 hr to fix

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

    public function process(RequestInterface $request, ResponseInterface $response, RequestContextInterface $requestContext, $hook)
    {
        // In php an interface is, by definition, a fixed contract. It is immutable.
        // So we have to declare the right ones afterwards...
        /**
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/DeflateModule.php - About 1 hr to fix

Method matches has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function matches()
    {
        // Switching between different actions we have to take.
        // Using an if cascade as it seems to be faster than switch...case
        $result = false;
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/Rewrite/Entities/Condition.php - About 1 hr to fix

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

    protected function initCerts()
    {
        // get stream context to enhance it
        $streamContext = $this->getServerContext()->getStreamContext();
        // get logger
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/VirtualHostModule.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

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

    public function process(RequestInterface $request, ResponseInterface $response, RequestContextInterface $requestContext, $hook)
    {
        // In php an interface is, by definition, a fixed contract. It is immutable.
        // So we have to declare the right ones afterwards...

Severity: Minor
Found in src/AppserverIo/WebServer/Modules/CoreModule.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

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

    public function process(RequestInterface $request, ResponseInterface $response, RequestContextInterface $requestContext, $hook)
    {
        // In php an interface is, by definition, a fixed contract. It is immutable.
        // So we have to declare the right ones afterwards...
        /**
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/DeflateModule.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

Avoid deeply nested control flow statements.
Open

                                if (substr($paramValue, 0, 1) !== "/") {
                                    $paramValue = getcwd() . DIRECTORY_SEPARATOR . $paramValue;
                                }
Severity: Major
Found in src/AppserverIo/WebServer/Modules/LocationModule.php - About 45 mins to fix

Function prepareOperandAdditions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function prepareOperandAdditions()
    {
        foreach ($this->htaccessAdditions as $addition) {
            // The string has to start with an addition (any negating ! was cut of before)
            if (strpos($this->action, $addition) === 0) {
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/Rewrite/Entities/Condition.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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

                    foreach ($location['params'] as $paramName => $paramValue) {
                        // check if server var mapping exists
                        if (isset($this->paramServerVarsMap[$paramName])) {
                            // check if documentRoot is changed
                            if ($this->paramServerVarsMap[$paramName] === ServerVars::DOCUMENT_ROOT) {
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/LocationModule.php and 1 other location - About 40 mins to fix
src/AppserverIo/WebServer/Modules/VirtualHostModule.php on lines 192..205

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 94.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            foreach ($params as $paramName => $paramValue) {
                // check if server var mapping exists
                if (isset($this->paramServerVarsMap[$paramName])) {
                    // check if documentRoot is changed
                    if ($this->paramServerVarsMap[$paramName] === ServerVars::DOCUMENT_ROOT) {
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/VirtualHostModule.php and 1 other location - About 40 mins to fix
src/AppserverIo/WebServer/Modules/LocationModule.php on lines 161..174

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 94.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    public function process(RequestInterface $request, ResponseInterface $response, RequestContextInterface $requestContext, $hook)
    {
        // In php an interface is, by definition, a fixed contract. It is immutable.
        // So we have to declair the right ones afterwards...
        /**
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/RewriteMapModule.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 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

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

    protected function prepareEnvironment(RequestInterface $request, RequestContextInterface $requestContext)
    {

        // prepare the Fast-CGI environment variables
        $environment = array(
Severity: Minor
Found in src/AppserverIo/WebServer/Modules/FcgiModule.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

Severity
Category
Status
Source
Language