shawnrice/alphred

View on GitHub

Showing 55 of 55 total issues

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

    public function __construct( $args ) {

        // Create the data storage variable
        $this->data = [];

Severity: Minor
Found in classes/ScriptFilter.php - About 35 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

Avoid too many return statements within this method.
Open

        return file_get_contents( $this->get_cache_file() );
Severity: Major
Found in classes/Request.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                    return [ 'code' => 0, 'data' => false ];
    Severity: Major
    Found in classes/Request.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return [ $score, MATCH_INITIALS_STARTSWITH ];
      Severity: Major
      Found in classes/Filter.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return [0, 'None'];
        Severity: Major
        Found in classes/Filter.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return [$score, MATCH_ALLCHARS ];
          Severity: Major
          Found in classes/Filter.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return $this->results;
            Severity: Major
            Found in classes/Request.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return [ $score, MATCH_SUBSTRING ];
              Severity: Major
              Found in classes/Filter.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return false;
                Severity: Major
                Found in classes/Request.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return [$score, MATCH_INITIALS_CONTAIN];
                  Severity: Major
                  Found in classes/Filter.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return [ 'code' => $this->code, 'data' => $this->results ];
                    Severity: Major
                    Found in classes/Request.php - About 30 mins to fix

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

                          public static function get( $name ) {
                              // Check if the variable is in the appropriate array
                              if ( in_array( $name, self::$variables ) ) {
                                  // If the variable is set, then return it
                                  if ( isset( $_SERVER[ $name ] ) ) {
                      Severity: Minor
                      Found in classes/Globals.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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function __construct( $values = [] ) {
                              // Has this been initialized with values in the array?
                              if ( count( $values ) > 0 ) {
                                  // Cycle through the array and set the appropriate variables
                                  foreach ( $values as $k => $v ) :
                      Severity: Minor
                      Found in classes/Dialog.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 set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function set( $options ) {
                              // Options must be an array of 'key' => 'value', like: 'title' => 'This is a title'
                              if ( ! is_array( $options ) ) {
                                  return false;
                              }
                      Severity: Minor
                      Found in classes/ScriptFilter.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 clear_directory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function clear_directory( $dir ) {
                              if ( ! file_exists( $dir ) || ! is_dir( $dir ) || '.' === $dir ) {
                                  // Throw an exception because this is a bad request to clear the cache
                                  throw new Exception( "Cannot clear directory: `{$dir}`", 3 );
                              }
                      Severity: Minor
                      Found in classes/Request.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