Kylob/SQLite

View on GitHub
src/Component.php

Summary

Maintainability
F
3 days
Test Coverage

File Component.php has 347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace BootPress\SQLite;

use BootPress\Database\Component as Database;
Severity: Minor
Found in src/Component.php - About 4 hrs to fix

    Function info has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function info($master) // only made public so that $this->fts can call it
        {
            if ($master == 'settings') {
                if (!isset($this->info['settings'])) {
                    if ($this->create('config', array('settings' => 'TEXT NOT NULL DEFAULT ""'))) {
    Severity: Minor
    Found in src/Component.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 recreate has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public function recreate($file)
        {
            if (is_file($file)) {
                return;
            }
    Severity: Minor
    Found in src/Component.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 alter has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        private function alter($table, array $fields, array $changes, $columns)
        {
            $map = array();
            if ($compare = $this->row('SELECT * FROM '.$table.' LIMIT 1', array(), 'assoc')) {
                foreach ($changes as $old => $new) {
    Severity: Minor
    Found in src/Component.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 index has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        private function index($table, $columns)
        {
            $queries = array();
            $outdated = $this->info('indexes', $table);
            if (empty($outdated)) {
    Severity: Minor
    Found in src/Component.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 __construct has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __construct($file = null)
        {
            if (is_null($file)) {
                $file = ':memory:';
                $this->created = true;
    Severity: Minor
    Found in src/Component.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 recreate has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function recreate($file)
        {
            if (is_file($file)) {
                return;
            }
    Severity: Minor
    Found in src/Component.php - About 1 hr to fix

      Method info has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function info($master) // only made public so that $this->fts can call it
          {
              if ($master == 'settings') {
                  if (!isset($this->info['settings'])) {
                      if ($this->create('config', array('settings' => 'TEXT NOT NULL DEFAULT ""'))) {
      Severity: Minor
      Found in src/Component.php - About 1 hr to fix

        Method alter has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function alter($table, array $fields, array $changes, $columns)
            {
                $map = array();
                if ($compare = $this->row('SELECT * FROM '.$table.' LIMIT 1', array(), 'assoc')) {
                    foreach ($changes as $old => $new) {
        Severity: Minor
        Found in src/Component.php - About 1 hr to fix

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

              protected function dbExecute($stmt, array $values, $reference)
              {
                  if (isset($this->prepared[$reference]['result'])) {
                      $this->prepared[$reference]['result']->finalize();
                      unset($this->prepared[$reference]['result']);
          Severity: Minor
          Found in src/Component.php - About 1 hr to fix

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

                public function __construct($file = null)
                {
                    if (is_null($file)) {
                        $file = ':memory:';
                        $this->created = true;
            Severity: Minor
            Found in src/Component.php - About 1 hr to fix

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

                  private function index($table, $columns)
                  {
                      $queries = array();
                      $outdated = $this->info('indexes', $table);
                      if (empty($outdated)) {
              Severity: Minor
              Found in src/Component.php - About 1 hr to fix

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

                    public function settings($name = null, $value = null)
                    {
                        switch (func_num_args()) {
                            case 0: // they want it all
                                return $this->info('settings');
                Severity: Minor
                Found in src/Component.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 dbExecute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function dbExecute($stmt, array $values, $reference)
                    {
                        if (isset($this->prepared[$reference]['result'])) {
                            $this->prepared[$reference]['result']->finalize();
                            unset($this->prepared[$reference]['result']);
                Severity: Minor
                Found in src/Component.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

                Avoid deeply nested control flow statements.
                Open

                                            if (!empty($sql)) {
                                                $this->info['indexes'][$table][$name] = $sql;
                                            }
                Severity: Major
                Found in src/Component.php - About 45 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status