elcodedocle/chbspassgen

View on GitHub
dictionary/Dictionary.php

Summary

Maintainability
D
2 days
Test Coverage

Function __construct has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct($input = null, $minWordSize = null, $format = null, $params = array(), $prng = null){

        $this->defaultFilename = realpath(dirname(__FILE__)).'/top10000.txt';

        if ($minWordSize===null) { $minWordSize = $this->defaultMinWordSize; } else { $this->defaultMinWordSize = $minWordSize; }
Severity: Minor
Found in dictionary/Dictionary.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 getRandomWordsArray has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function getRandomWordsArray($count = null, $unique = null){
        if ($unique === null) { $unique = $this->defaultUnique; }
        // be aware unique = true invalidates 
        // countWordsOn(password) * log2(countWordsOn(Dictionary)) 
        // as a valid measure of the entropy in bits!
Severity: Minor
Found in dictionary/Dictionary.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 readWordsFromFile has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function readWordsFromFile($filename = null, $splitPattern = null, $add = null, $minWordSize = null){
        if ($filename === null) { $filename = $this->defaultFilename; }
        if ($splitPattern === null) { $splitPattern = $this->defaultSplitPattern; }
        if ($add === null) { $add = $this->defaultAdd; }
        if ($minWordSize === null) { $minWordSize = $this->defaultMinWordSize; }
Severity: Minor
Found in dictionary/Dictionary.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 readWords has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function readWords($input = null, $format = null, $params = array(), $minWordSize = null){
        
        if ($format === null) { $format = $this->defaultFormat; }        
        if (!is_array($params)) { throw new Exception ('$params must be array'); }
        if (isset($params['add'])){
Severity: Minor
Found in dictionary/Dictionary.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

Method readWordsFromFile has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function readWordsFromFile($filename = null, $splitPattern = null, $add = null, $minWordSize = null){
        if ($filename === null) { $filename = $this->defaultFilename; }
        if ($splitPattern === null) { $splitPattern = $this->defaultSplitPattern; }
        if ($add === null) { $add = $this->defaultAdd; }
        if ($minWordSize === null) { $minWordSize = $this->defaultMinWordSize; }
Severity: Minor
Found in dictionary/Dictionary.php - About 1 hr to fix

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

        public function __construct($input = null, $minWordSize = null, $format = null, $params = array(), $prng = null){
    
            $this->defaultFilename = realpath(dirname(__FILE__)).'/top10000.txt';
    
            if ($minWordSize===null) { $minWordSize = $this->defaultMinWordSize; } else { $this->defaultMinWordSize = $minWordSize; }
    Severity: Minor
    Found in dictionary/Dictionary.php - About 1 hr to fix

      Function readWordsFromPDO has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function readWordsFromPDO($dbh = null, $table = null, $column = null, $add = null, $minWordSize = null){
              if ($dbh === null) { $dbh = $this->defaultDbh; }
              if ($table === null) { $table = $this->defaultTable; } 
              if ($column === null) { $column = $this->defaultColumn; }
              if ($add === null) { $add = $this->defaultAdd; }
      Severity: Minor
      Found in dictionary/Dictionary.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 readWords has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function readWords($input = null, $format = null, $params = array(), $minWordSize = null){
              
              if ($format === null) { $format = $this->defaultFormat; }        
              if (!is_array($params)) { throw new Exception ('$params must be array'); }
              if (isset($params['add'])){
      Severity: Minor
      Found in dictionary/Dictionary.php - About 1 hr to fix

        Function readWordsFromArray has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function readWordsFromArray($newWords, $add = null, $minWordSize = null){
                if ($add === null) { $add = $this->defaultAdd; }
                if ($minWordSize === null) { $minWordSize = $this->defaultMinWordSize; }
                if (
                    !is_bool($add)
        Severity: Minor
        Found in dictionary/Dictionary.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 readWordsFromPDO has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function readWordsFromPDO($dbh = null, $table = null, $column = null, $add = null, $minWordSize = null){
                if ($dbh === null) { $dbh = $this->defaultDbh; }
                if ($table === null) { $table = $this->defaultTable; } 
                if ($column === null) { $column = $this->defaultColumn; }
                if ($add === null) { $add = $this->defaultAdd; }
        Severity: Minor
        Found in dictionary/Dictionary.php - About 1 hr to fix

          Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function __construct($input = null, $minWordSize = null, $format = null, $params = array(), $prng = null){
          Severity: Minor
          Found in dictionary/Dictionary.php - About 35 mins to fix

            Method readWordsFromPDO has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function readWordsFromPDO($dbh = null, $table = null, $column = null, $add = null, $minWordSize = null){
            Severity: Minor
            Found in dictionary/Dictionary.php - About 35 mins to fix

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

                  public function countWords($words = null, $minWordSize = null, $minReadWordsWordSize = null){
                      if ($words === null) { $words = $this->words; }
                      if ($minWordSize === null) { $minWordSize = $this->minWordSize; }
                      if ($minReadWordsWordSize === null) { $minReadWordsWordSize = $this->minReadWordsWordSize; }
                      if (!array($words)) { throw new Exception('$words must be an array'); }
              Severity: Minor
              Found in dictionary/Dictionary.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

              There are no issues that match your filters.

              Category
              Status