elcodedocle/captchalot

View on GitHub
captchaword.php

Summary

Maintainability
D
1 day
Test Coverage

Function generateTrie has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    private function generateTrie(&$validSymbols){

        if (is_string($validSymbols)){
            $validSymbols = array($validSymbols);
        }
Severity: Minor
Found in captchaword.php - About 3 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 __construct has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct(
        $defaultInternalOrExternalSymbols = null, 
        $defaultLength = null, 
        $useExternalSymbolsArray = true,
        $prng = null
Severity: Minor
Found in captchaword.php - About 3 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

Method generateTrie has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function generateTrie(&$validSymbols){

        if (is_string($validSymbols)){
            $validSymbols = array($validSymbols);
        }
Severity: Minor
Found in captchaword.php - About 1 hr to fix

    Method __construct has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __construct(
            $defaultInternalOrExternalSymbols = null, 
            $defaultLength = null, 
            $useExternalSymbolsArray = true,
            $prng = null
    Severity: Minor
    Found in captchaword.php - About 1 hr to fix

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

          public function generateWord($symbols = null, $length = null, $separator = '   '){
              
              if ($symbols===null){
                  $symbols = $this->defaultSymbols;
              }
      Severity: Minor
      Found in captchaword.php - About 1 hr to fix

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

            public function validateWord($word, $symbols = null){
                
                if ($this->defaultTrie === null){
                    $this->defaultTrie = $this->generateTrie($this->defaultSymbols);
                }
        Severity: Minor
        Found in captchaword.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 generateWord has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public function generateWord($symbols = null, $length = null, $separator = '   '){
                
                if ($symbols===null){
                    $symbols = $this->defaultSymbols;
                }
        Severity: Minor
        Found in captchaword.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 isValidWord has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private function isValidWord($word,&$trie){
                $nodes = array($word);
                while (count($nodes)>0){
                    $node = array_shift($nodes);
                    if ($this->inTrie($node,$trie)) { return true; }
        Severity: Minor
        Found in captchaword.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

        There are no issues that match your filters.

        Category
        Status