nathanmac/Responder

View on GitHub

Showing 5 of 7 total issues

Function write has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function write(XMLWriter $xml, $payload, $last_key = 'entity')
    {
        foreach ($payload as $key => $value) {
            if (is_numeric($key)) {
                if (substr($last_key, -3) == 'ies') {
Severity: Minor
Found in src/Formats/XML.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 generate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function generate($payload, $container = 'data')
    {
        $function      = null;
        $function_list = [
            'bson_encode',
Severity: Minor
Found in src/Formats/BSON.php - About 1 hr to fix

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

    public function generate($payload, $container = 'data')
    {
        $function      = null;
        $function_list = [
            'bson_encode',
Severity: Minor
Found in src/Formats/BSON.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 getContentType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getContentType($format = '')
    {
        if (empty($format) && isset($_SERVER['ACCEPT'])) {
            $format = $_SERVER['ACCEPT'];
        }
Severity: Minor
Found in src/Responder.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 generate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function generate($payload, $container = 'data')
    {
        if (function_exists('msgpack_pack')) {
            if ($payload) {
                $prevHandler = set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) {
Severity: Minor
Found in src/Formats/MSGPack.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