attogram/attogram-database

View on GitHub

Showing 7,594 of 7,594 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                    for($i=0; $i<sizeof($result); $i++)
                    {
                        if(isset($_SESSION[COOKIENAME.$target_table.'chartlabels']) && $_SESSION[COOKIENAME.$target_table.'chartlabels']==$i)
                            echo "<option value='".$i."' selected='selected'>".htmlencode($result[$i]['name'])."</option>";
                        else
Severity: Major
Found in admin_actions/db-admin.php and 1 other location - About 2 hrs to fix
admin_actions/db-admin.php on lines 2787..2793

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 141.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        case "index_delete":
            $query = "DROP INDEX ".$db->quote_id($_GET['pk']);
            $result = $db->query($query);
            if($result===false)
                $error = true;
Severity: Major
Found in admin_actions/db-admin.php and 1 other location - About 2 hrs to fix
admin_actions/db-admin.php on lines 1531..1538

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 140.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        case "trigger_delete":
            $query = "DROP TRIGGER ".$db->quote_id($_GET['pk']);
            $result = $db->query($query);
            if($result===false)
                $error = true;
Severity: Major
Found in admin_actions/db-admin.php and 1 other location - About 2 hrs to fix
admin_actions/db-admin.php on lines 1541..1548

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 140.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              case "index_delete":
                  echo "<form action='?table=".urlencode($target_table)."&amp;action=index_delete&amp;pk=".urlencode($_GET['pk'])."&amp;confirm=1' method='post'>";
                  echo "<div class='confirm'>";
                  echo sprintf($lang['ques_del_index'], htmlencode($_GET['pk']))."<br/><br/>";
                  echo "<input type='submit' value='".$lang['confirm']."' class='btn'/> ";
      Severity: Major
      Found in admin_actions/db-admin.php and 1 other location - About 2 hrs to fix
      admin_actions/db-admin.php on lines 3463..3471

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 128.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              case "trigger_delete":
                  echo "<form action='?table=".urlencode($target_table)."&amp;action=trigger_delete&amp;pk=".urlencode($_GET['pk'])."&amp;confirm=1' method='post'>";
                  echo "<div class='confirm'>";
                  echo sprintf($lang['ques_del_trigger'], htmlencode($_GET['pk']))."<br/><br/>";
                  echo "<input type='submit' value='".$lang['confirm']."' class='btn'/> ";
      Severity: Major
      Found in admin_actions/db-admin.php and 1 other location - About 2 hrs to fix
      admin_actions/db-admin.php on lines 3452..3460

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 128.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

      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

      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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                for($i=0; $i<sizeof($result); $i++)
                {
                    if(substr($result[$i]['name'], 0, 7)!="sqlite_" && $result[$i]['name']!="")
                        echo "<option value='".htmlencode($result[$i]['name'])."' selected='selected'>".htmlencode($result[$i]['name'])."</option>";
                }
        Severity: Major
        Found in admin_actions/db-admin.php and 1 other location - About 1 hr to fix
        admin_actions/db-admin.php on lines 4057..4061

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 120.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                for($i=0; $i<sizeof($result); $i++)
                {
                    if(substr($result[$i]['name'], 0, 7)!="sqlite_" && $result[$i]['name']!="")
                        echo "<option value='".htmlencode($result[$i]['name'])."'>".htmlencode($result[$i]['name'])."</option>";
                }
        Severity: Major
        Found in admin_actions/db-admin.php and 1 other location - About 1 hr to fix
        admin_actions/db-admin.php on lines 3983..3987

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 120.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          Method explode_sql has 46 lines of code (exceeds 25 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 1 hr to fix

            Method import_csv has 46 lines of code (exceeds 25 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 1 hr to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                                      for($col = $pkFirstCol; array_key_exists($col, $arr[$i]); $col=$col+2)
                                      {
                                          // in $col we have the type and in $col-1 the value
                                          if($arr[$i][$col]=='integer' || $arr[$i][$col]=='real')
                                              // json encode as int or float, not string
              Severity: Major
              Found in admin_actions/db-admin.php and 1 other location - About 1 hr to fix
              admin_actions/db-admin.php on lines 2277..2286

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 116.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                                      for($col = $pkFirstCol; array_key_exists($col, $arr[$j]); $col=$col+2)
                                      {
                                          // in $col we have the type and in $col-1 the value
                                          if($arr[$j][$col]=='integer' || $arr[$j][$col]=='real')
                                              // json encode as int or float, not string
              Severity: Major
              Found in admin_actions/db-admin.php and 1 other location - About 1 hr to fix
              admin_actions/db-admin.php on lines 2586..2595

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 116.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Function query has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function query($query, $ignoreAlterCase=false)
                  {
                      global $debug;
                      if(strtolower(substr(ltrim($query),0,5))=='alter' && $ignoreAlterCase==false) //this query is an ALTER query - call the necessary function
                      {
              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

              Severity
              Category
              Status
              Source
              Language