elcodedocle/chbspassgen

View on GitHub

Showing 37 of 37 total issues

Function filterVariations has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    public function filterVariations($variations){
        if ( !isset($variations) || $variations === null) {

            $variations = array();
            $variations['capitalize'] = $this->capitalize;
Severity: Minor
Found in PasswordGenerator.php - About 6 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

File PasswordGenerator.php has 390 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace synapp\info\tools\passwordgenerator;
use Exception;
use synapp\info\tools\passwordgenerator\cryptosecureprng\CryptoSecurePRNG;
use synapp\info\tools\passwordgenerator\dictionary\Dictionary;
Severity: Minor
Found in PasswordGenerator.php - About 5 hrs to fix

    PasswordGenerator has 38 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class PasswordGenerator extends PasswordGeneratorAbstract {
    
        private $defaultMinEntropies = array (64, 80, 112, 128); //min entropy (in bits) per level as an array of integers in ascending order
        private $defaultLevel = 2;
        private $defaultDictionaryFilename = null; // 2^13 (aprox)
    Severity: Minor
    Found in PasswordGenerator.php - About 5 hrs to fix

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

          public function __construct($dictionary = null, $level = null, $separators = ' ', $minEntropies = null, $useVariations = true, $variations = null, $minWordSize = null, $minReadWordsWordSize = null, $prng = null){
      
              if ($minWordSize === null) {
                  $this->minWordSize = $this->defaultMinWordSize;
              } else if (is_int($minWordSize)){
      Severity: Minor
      Found in PasswordGenerator.php - About 4 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 generatePassword has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          public function generatePassword($dictionary = null, $minEntropy = null, $level = null, $separators = null, $useVariations = null, $variations = null){
              
              if ($dictionary === null){
                  $dictionary = $this->getDictionary();
              } else if (!is_object($dictionary) || !in_array('DictionaryInterface', class_implements($dictionary))){
      Severity: Minor
      Found in PasswordGenerator.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 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 applyVariation has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function applyVariation($word,$index,$variations,$last,&$appliedVariation){
              $count = 0;
              if(isset($variations['capitalize'])&&$variations['capitalize']===true){
                  if ($count<$index){
                      $count++;
      Severity: Minor
      Found in PasswordGenerator.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 getMinSymbolCount has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getMinSymbolCount($minEntropy = null, $dictionary = null, $variationsCount = null){
              if ($variationsCount === null) { $variationsCount = $this->getVariationsCount(); }
              else if (!is_int($variationsCount)) { throw new Exception ('$variationsCount must be an int'); }
              if ($minEntropy === null) { $minEntropy = $this->getMinEntropy(); }
              else if (!is_numeric($minEntropy)) { throw new Exception ('$minEntropy must be numeric'); }
      Severity: Minor
      Found in PasswordGeneratorAbstract.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 applyVariation has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function applyVariation($word,$index,$variations,$last,&$appliedVariation){
              $count = 0;
              if(isset($variations['capitalize'])&&$variations['capitalize']===true){
                  if ($count<$index){
                      $count++;
      Severity: Minor
      Found in PasswordGenerator.php - About 1 hr to fix

        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

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

                public function __construct($dictionary = null, $level = null, $separators = ' ', $minEntropies = null, $useVariations = true, $variations = null, $minWordSize = null, $minReadWordsWordSize = null, $prng = null){
            
                    if ($minWordSize === null) {
                        $this->minWordSize = $this->defaultMinWordSize;
                    } else if (is_int($minWordSize)){
            Severity: Minor
            Found in PasswordGenerator.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

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

              function requestAndSetPasswordAndEntropy(){
                  'use strict';
                  //TODO: client input validation
                  var xmlhttp, AJAXresponse, parameters,
                      allcaps = document.getElementById('allcaps').checked?'true':'false',
              Severity: Minor
              Found in webapp/passgenClientController.js - 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 requestAndSetPasswordAndEntropy has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function requestAndSetPasswordAndEntropy(){
                  'use strict';
                  //TODO: client input validation
                  var xmlhttp, AJAXresponse, parameters,
                      allcaps = document.getElementById('allcaps').checked?'true':'false',
              Severity: Minor
              Found in webapp/passgenClientController.js - About 1 hr to fix

                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

                  Severity
                  Category
                  Status
                  Source
                  Language