kiler129/CherryHttp

View on GitHub

Showing 42 of 42 total issues

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

    public function setBody($body)
    {
        if ($body === '' || $body === null) {
            $this->setHeader('Content-Length', '0');
            $this->body = $body;
Severity: Minor
Found in src/Http/Response/Response.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 getResponse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function getResponse($code = ResponseCode::NO_CONTENT, $content = null, $headers = [])
    {
        $response = clone $this->baseResponse;

        if ($code !== false) {
Severity: Minor
Found in src/Http/Response/ResponseFactory.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

Missing class import via use statement (line '104', column '23').
Open

            throw new \InvalidArgumentException(
Severity: Minor
Found in src/Http/Request/Request.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '100', column '23').
Open

            throw new \InvalidArgumentException('Malformed path! It should NOT contain spaces or #');
Severity: Minor
Found in src/Http/Request/Request.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '69', column '23').
Open

            throw new \InvalidArgumentException('Request-target cannot be empty.');
Severity: Minor
Found in src/Http/Request/Request.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '130', column '19').
Open

        throw new \LogicException('You cannot perform write on listener node');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '46', column '19').
Open

        throw new \LogicException('Listeners do not provide stream objects');
Severity: Minor
Found in src/Server/Node/HttpListenerNode.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '160', column '23').
Open

            throw new \InvalidArgumentException('Body need to be a string or object implementing StreamInterface');
Severity: Minor
Found in src/Http/Message/Message.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '74', column '23').
Open

            throw new \LogicException(__CLASS__ . ' accepts error codes only (4xx & 5xx).');
Severity: Minor
Found in src/Http/Response/ErrorResponse.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '63', column '23').
Open

            throw new \InvalidArgumentException('Invalid code specified. Consult RFC.');
Severity: Minor
Found in src/Http/Response/Response.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '45', column '23').
Open

            throw new \LogicException('Overflow magnitude cannot be negative.');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Remove error control operator '@' on line 43.
Open

    public function onStreamError()
    {
        /** @noinspection PhpUsageOfSilenceOperatorInspection There's no way to overcome that */
        @fclose($this->stream); //Well... I don't think it's gonna work really
        $this->stream = null;
Severity: Minor
Found in src/IO/Stream/AbstractStreamNode.php by phpmd

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

Missing class import via use statement (line '59', column '23').
Open

            throw new \LogicException(__CLASS__ . ' accepts only redirect codes only.');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '49', column '23').
Open

            throw new \InvalidArgumentException('Overflow magnitude should be a number.');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '67', column '23').
Open

            throw new \InvalidArgumentException('Invalid port');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '70', column '23').
Open

            throw new \InvalidArgumentException(
Severity: Minor
Found in src/Http/Message/Message.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '47', column '23').
Open

            throw new \InvalidArgumentException('Invalid ip address');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '85', column '23').
Open

            throw new \LogicException(

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Remove error control operator '@' on line 78.
Open

    public function doWrite()
    {
        //PHP, despite returning number of bytes written, throws warning if buffer overflown 
        /** @noinspection PhpUsageOfSilenceOperatorInspection */
        $bytesWritten = @fwrite($this->stream, $this->writeBuffer);

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

Missing class import via use statement (line '96', column '23').
Open

            throw new \InvalidArgumentException('Path cannot be empty.');
Severity: Minor
Found in src/Http/Request/Request.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Severity
Category
Status
Source
Language