sadovnik/hexlet-psr-linter

View on GitHub

Showing 7 of 7 total issues

Function leaveNode has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function leaveNode(Node $node)
    {
        foreach ($this->rules->getAssociatedRules($node) as $rule) {
            $result = $rule->verify($node);

Severity: Minor
Found in src/LinterVisitor.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 verify has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function verify(Node $node)
    {
        if ($node instanceof Node\Stmt\Class_
            || $node instanceof Node\Stmt\Function_
            || $node instanceof Node\Stmt\Trait_
Severity: Minor
Found in src/Rules/EitherDeclarationsOrSideEffectsRule.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 printResult has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function printResult($result)
    {
        $lineCount = $result->getNode() ? $result->getNode()->getLine() : '';
        $line = sprintf('%6s', $lineCount);

Severity: Minor
Found in src/CliApp.php - About 1 hr to fix

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

    function isCamelCase(string $functionName) : bool
    {
        $legalFirstChar = '[a-z]';
    
        if (preg_match("/^$legalFirstChar/", $functionName) === 0) {
    Severity: Minor
    Found in src/Rules/CamelCaseHelpers.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 getNodeTypeMap has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function getNodeTypeMap()
        {
            if ($this->map === null) {
                $this->map = [];
                foreach ($this->rules as $rule) {
    Severity: Minor
    Found in src/Rules/RuleCollection.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 __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function __construct($afterFix, $beforeFix, $fixedNode, $rule, Node $node = null)
    Severity: Minor
    Found in src/RuleResults/FixedRuleResult.php - About 35 mins to fix

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

          private function printResult($result)
          {
              $lineCount = $result->getNode() ? $result->getNode()->getLine() : '';
              $line = sprintf('%6s', $lineCount);
      
      
      Severity: Minor
      Found in src/CliApp.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