komissarovea/hexlet-psr-linter

View on GitHub

Showing 5 of 5 total issues

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

    public function enterNode(Node $node)
    {
        //$nodeName = isset($node->name) ? $node->name : 'undefined';
        //echo get_class($node) . " $nodeName " . PHP_EOL;
        foreach ($this->rules as $rule) {
Severity: Minor
Found in src/HplNodeVisitor.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 getFilesByPath has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function getFilesByPath($path)
{
    if (is_readable($path)) {
        if (is_file($path)) {
            return [$path];
Severity: Minor
Found in src/Utils.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 buildReport has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function buildReport($sourcePath, $errors, $format)
{
    $report = "";
    $dict = convertErrorsToDictionary($errors);
    $dict['sourcePath'] = isset($sourcePath) ? realpath($sourcePath) : "";
Severity: Minor
Found in src/Linter.php - About 1 hr to fix

    Function fix has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function fix($result)
    {
        if (isset($result['allStatements'])) {
            $errors = $result['errors'];
            $allStatements = $result['allStatements'];
    Severity: Minor
    Found in src/Linter.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

    Function getParent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function getParent($node, array $acc)
    {
        //eval(\Psy\sh());
        foreach ($acc as $item) {
            if ((isset($item->stmts) && in_array($node, $item->stmts))
    Severity: Minor
    Found in src/Rules/RulesFunctions.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