mariuz/firebirdwebadmin

View on GitHub
inc/functions.inc.php

Summary

Maintainability
F
1 wk
Test Coverage

File functions.inc.php has 913 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
// Purpose        collection of little helpers etc.
// Author         Lutz Brueckner <irie@gmx.de>
// Copyright      (c) 2000-2006 by Lutz Brueckner,
//                published under the terms of the GNU General Public Licence v.2,
Severity: Major
Found in inc/functions.inc.php - About 2 days to fix

    Function build_coldef has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    function build_coldef($idx, $mode = 'create')
    {
        global $s_coldefs;
    
        if (!isset($s_coldefs[$idx]['name']))
    Severity: Minor
    Found in inc/functions.inc.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 set_customize_cookie has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    function set_customize_cookie($customize)
    {
    
        // don't save rubbish if the session is gone
        if (empty($customize['color'])) {
    Severity: Minor
    Found in inc/functions.inc.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 build_coldef has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function build_coldef($idx, $mode = 'create')
    {
        global $s_coldefs;
    
        if (!isset($s_coldefs[$idx]['name']))
    Severity: Minor
    Found in inc/functions.inc.php - About 1 hr to fix

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

      function build_datatype($defs, $type = 'column', $mode = 'create')
      {
      
          $datatype = $defs['type'];
          $sql = '';
      Severity: Minor
      Found in inc/functions.inc.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 set_customize_cookie has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function set_customize_cookie($customize)
      {
      
          // don't save rubbish if the session is gone
          if (empty($customize['color'])) {
      Severity: Minor
      Found in inc/functions.inc.php - About 1 hr to fix

        Function is_allowed_db has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        function is_allowed_db($filename)
        {
            global $ALLOWED_FILES, $ALLOWED_DIRS;
        
            $cmp_func = (stristr(php_uname(), 'wind') !== false) ? 'strcasecmp' : 'strcmp';
        Severity: Minor
        Found in inc/functions.inc.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 build_datatype has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function build_datatype($defs, $type = 'column', $mode = 'create')
        {
        
            $datatype = $defs['type'];
            $sql = '';
        Severity: Minor
        Found in inc/functions.inc.php - About 1 hr to fix

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

          function have_panel_permissions($user, $pname, $connected = false)
          {
          
              if ($connected && !$GLOBALS['s_connected']) {
                  return false;
          Severity: Minor
          Found in inc/functions.inc.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 set_customize_settings has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function set_customize_settings($cookie_string)
          {
          
              $settings = explode("\n", $cookie_string);
          
          
          Severity: Minor
          Found in inc/functions.inc.php - About 1 hr to fix

            Method get_dependencies has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function get_dependencies($type, $name, $fname = null)
            {
                global $dbhandle;
            
                switch ($type) {
            Severity: Minor
            Found in inc/functions.inc.php - About 1 hr to fix

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

              function get_request_data($name, $source = 'POST')
              {
              
                  if (isset($GLOBALS['_' . $source][$name])) {
                      if (is_array($GLOBALS['_' . $source][$name])) {
              Severity: Minor
              Found in inc/functions.inc.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 set_customize_settings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function set_customize_settings($cookie_string)
              {
              
                  $settings = explode("\n", $cookie_string);
              
              
              Severity: Minor
              Found in inc/functions.inc.php - About 45 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 get_type_string has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function get_type_string($field)
              {
              
                  if (in_array($field['type'], array_keys($GLOBALS['s_domains']))) {
                      $field = $GLOBALS['s_domains'][$field['type']];
              Severity: Minor
              Found in inc/functions.inc.php - About 45 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 column_fk_is_modified has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function column_fk_is_modified($olddef, $coldef)
              {
              
                  $varnames = array('fk_name', 'on_update', 'on_delete', 'fk_table', 'fk_column');
                  foreach ($varnames as $name) {
              Severity: Minor
              Found in inc/functions.inc.php - About 45 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 datatype_is_modified has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function datatype_is_modified($olddef, $coldef)
              {
              
                  $varnames = array('type', 'size', 'charset', 'prec', 'scale', 'stype', 'segsize');
              
              
              Severity: Minor
              Found in inc/functions.inc.php - About 45 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

              Consider simplifying this complex logical expression.
              Open

                      if ((isset($olddef[$name]) && $olddef[$name] != $coldef[$name])
                          || (!isset($coldef[$name]) && !empty($olddef[$name]))
                          || (!isset($olddef[$name]) && !empty($coldef[$name]))
                      ) {
              
              
              Severity: Major
              Found in inc/functions.inc.php - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                        if ((isset($olddef[$name]) && $olddef[$name] != $coldef[$name])
                            || (!isset($coldef[$name]) && !empty($olddef[$name]))
                            || (!isset($olddef[$name]) && !empty($coldef[$name]))
                        ) {
                
                
                Severity: Major
                Found in inc/functions.inc.php - About 40 mins to fix

                  Method isql_execute has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function isql_execute($sql, $user = null, $pw = null, $db = null, $host = null)
                  Severity: Minor
                  Found in inc/functions.inc.php - About 35 mins to fix

                    Method error_handler has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    function error_handler($errno, $errmsg, $file, $line, $errstack)
                    Severity: Minor
                    Found in inc/functions.inc.php - About 35 mins to fix

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

                      function get_language_file($path) {
                          if ($path == null) {
                              $path = '.' . DIRECTORY_SEPARATOR . 'lang';
                          }    
                          $fileLang = $path. DIRECTORY_SEPARATOR . (isset($_SESSION['s_cust']['language']) && !empty($_SESSION['s_cust']['language']) && ($_SESSION['s_cust']['language'] != 1) ? $_SESSION['s_cust']['language'] : LANGUAGE).'.inc.php';
                      Severity: Minor
                      Found in inc/functions.inc.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

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

                      function fix_language()
                      {
                          global $ptitle_strings;
                      
                          foreach (panel_array_names() as $key => $parray) {
                      Severity: Minor
                      Found in inc/functions.inc.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

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

                      function exec_command($cmd, $parameters, $stderr = false)
                      {
                          $is_windows = (stristr(php_uname(), 'wind') == true) ? true : false;
                      
                          if (($is_windows && !is_file(BINPATH . $cmd . '.exe')) && !is_file(BINPATH . $cmd)) {
                      Severity: Minor
                      Found in inc/functions.inc.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 'unknown';
                      Severity: Major
                      Found in inc/functions.inc.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                            return true;
                        Severity: Major
                        Found in inc/functions.inc.php - About 30 mins to fix

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

                          function get_datatype($type, $subtype)
                          {
                          
                              $datatypes = get_datatypes(SERVER_FAMILY, SERVER_VERSION);
                          
                          
                          Severity: Minor
                          Found in inc/functions.inc.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_panel_title has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function set_panel_title($name, $title)
                          {
                          
                              foreach (panel_array_names() as $key => $parray) {
                                  global $$parray;
                          Severity: Minor
                          Found in inc/functions.inc.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

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

                          function get_tabmenu_top_fixed($page)
                          {
                          
                              $menuentries = array('Database' => url_session('database.php'),
                                  'Tables' => url_session('tables.php'),
                          Severity: Major
                          Found in inc/functions.inc.php and 1 other location - About 7 hrs to fix
                          inc/functions.inc.php on lines 960..987

                          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 225.

                          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

                          function get_tabmenu($page)
                          {
                          
                              $menuentries = array('Database' => url_session('database.php'),
                                  'Tables' => url_session('tables.php'),
                          Severity: Major
                          Found in inc/functions.inc.php and 1 other location - About 7 hrs to fix
                          inc/functions.inc.php on lines 992..1019

                          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 225.

                          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

                          There are no issues that match your filters.

                          Category
                          Status