attogram/attogram-database

View on GitHub

Showing 104 of 7,594 total issues

File db-admin.php has 4793 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
// Attogram Framework - Database Module - phpLiteAdmin mod v0.0.5

//
//    Project: phpLiteAdmin (https://bitbucket.org/phpliteadmin/public)
Severity: Major
Found in admin_actions/db-admin.php - About 1 wk to fix

    Function alterTable has a Cognitive Complexity of 273 (exceeds 5 allowed). Consider refactoring.
    Open

        public function alterTable($table, $alterdefs)
        {
            global $debug, $lang;
            $this->alterError="";
            $errormsg = sprintf($lang['alter_failed'],htmlencode($table)).' - ';
    Severity: Minor
    Found in admin_actions/db-admin.php - About 5 days 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 alterTable has 332 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function alterTable($table, $alterdefs)
        {
            global $debug, $lang;
            $this->alterError="";
            $errormsg = sprintf($lang['alter_failed'],htmlencode($table)).' - ';
    Severity: Major
    Found in admin_actions/db-admin.php - About 1 day to fix

      Function export_sql has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
      Open

          public function export_sql($tables, $drop, $structure, $data, $transaction, $comments)
          {
              global $lang;
              if($comments)
              {
      Severity: Minor
      Found in admin_actions/db-admin.php - About 1 day 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 export_csv has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
      Open

          public function export_csv($tables, $field_terminate, $field_enclosed, $field_escaped, $null, $crlf, $fields_in_first_row)
          {
              $field_enclosed = $field_enclosed;
              $query = "SELECT * FROM sqlite_master WHERE type='table' or type='view' ORDER BY type DESC";
              $result = $this->selectArray($query);
      Severity: Minor
      Found in admin_actions/db-admin.php - About 1 day 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 selectArray has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

          public function selectArray($query, $mode="both")
          {
              $result = $this->query($query);
              //make sure the result is valid
              if($result=== false || $result===NULL)
      Severity: Minor
      Found in admin_actions/db-admin.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

      Function select has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          public function select($query, $mode="both")
          {
              $result = $this->query($query);
              if(!$result) //make sure the result is valid
                  return NULL;
      Severity: Minor
      Found in admin_actions/db-admin.php - About 5 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 import_csv has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          public function import_csv($filename, $table, $field_terminate, $field_enclosed, $field_escaped, $null, $fields_in_first_row)
          {
              // CSV import implemented by Christopher Kramer - http://www.christosoft.de
              $csv_handle = fopen($filename,'r');
              $csv_insert = "BEGIN;\n";
      Severity: Minor
      Found in admin_actions/db-admin.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

      Database has 37 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Database
      {
          protected $db; //reference to the DB object
          protected $type; //the extension for PHP that handles SQLite
          protected $data;
      Severity: Minor
      Found in admin_actions/db-admin.php - About 4 hrs to fix

        Function explode_sql has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
        Open

        function explode_sql($delimiter, $sql)
        {
            $ign = array('"' => '"', "'" => "'", "/*" => "*/", "--" => "\n"); // Ignore sequences.
            $out = array();
            $last = 0;
        Severity: Minor
        Found in admin_actions/db-admin.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

        File SqliteDatabase.php has 323 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php  // Attogram Framework - Database Module - SqliteDatabase class v0.3.20
        
        namespace Attogram;
        
        /**
        Severity: Minor
        Found in includes/SqliteDatabase.php - About 3 hrs to fix

          Method export_sql has 86 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function export_sql($tables, $drop, $structure, $data, $transaction, $comments)
              {
                  global $lang;
                  if($comments)
                  {
          Severity: Major
          Found in admin_actions/db-admin.php - About 3 hrs to fix

            Method tabler has 69 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function tabler(
                    $table,
                    $tableId,
                    $nameSingular,
                    $namePlural, // TODO - remove unused
            Severity: Major
            Found in includes/SqliteDatabase.php - About 2 hrs to fix

              Consider simplifying this complex logical expression.
              Open

              if(!isset($_GET['confirm']) && $target_table && isset($_GET['action']) && ($_GET['action']=="table_export" || $_GET['action']=="table_import" || $_GET['action']=="table_sql" || $_GET['action']=="row_view" || $_GET['action']=="row_create" || $_GET['action']=="column_view" || $_GET['action']=="table_rename" || $_GET['action']=="table_search" || $_GET['action']=="table_triggers"))
              {
                  //- HTML: tabs for tables
                  if($target_table_type == 'table')
                  {
              Severity: Critical
              Found in admin_actions/db-admin.php - About 2 hrs to fix

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

                    public function __construct($data)
                    {
                        global $lang;
                        $this->data = $data;
                        try
                Severity: Minor
                Found in admin_actions/db-admin.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 dir_tree has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                function dir_tree($dir)
                {
                    $path = '';
                    $stack[] = $dir;
                    while($stack)
                Severity: Minor
                Found in admin_actions/db-admin.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 export_csv has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function export_csv($tables, $field_terminate, $field_enclosed, $field_escaped, $null, $crlf, $fields_in_first_row)
                    {
                        $field_enclosed = $field_enclosed;
                        $query = "SELECT * FROM sqlite_master WHERE type='table' or type='view' ORDER BY type DESC";
                        $result = $this->selectArray($query);
                Severity: Major
                Found in admin_actions/db-admin.php - About 2 hrs to fix

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

                      public function __construct($data)
                      {
                          global $lang;
                          $this->data = $data;
                          try
                  Severity: Minor
                  Found in admin_actions/db-admin.php - About 1 hr to fix

                    Function get_type_affinity has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function get_type_affinity($type)
                    {
                        if (preg_match("/INT/i", $type))
                            return "INTEGER";
                        else if (preg_match("/(?:CHAR|CLOB|TEXT)/i", $type))
                    Severity: Minor
                    Found in admin_actions/db-admin.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 tabler has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function tabler(
                            $table,
                            $tableId,
                            $nameSingular,
                            $namePlural, // TODO - remove unused
                    Severity: Minor
                    Found in includes/SqliteDatabase.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