XoopsModules25x/adminer

View on GitHub

Showing 193 of 307 total issues

Method foreignKeys has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function foreignKeys($table) {
        if (DRIVER == 'server' && DB == 'mysql') {
            switch ($table) {
                case 'columns_priv': return array(array('table' => 'user', 'source' => array('Host', 'User'), 'target' => array('Host', 'User')));
                case 'db': return array(array('table' => 'user', 'source' => array('Host', 'User'), 'target' => array('Host', 'User')));
Severity: Major
Found in include/plugins/foreign-system.php - About 2 hrs to fix

    Method create_ajax_script has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function create_ajax_script() 
    {
      global $linenumber, $foffset, $totalqueries, $delaypersession, $curfilename, $delimiter;
    ?>
    
    Severity: Major
    Found in include/bigdump.php - About 2 hrs to fix

      Function dumpTable has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      dumpDatabase($i){}function
      dumpTable($Q,$If,$Yc=0){if($_POST["format"]!="sql"){echo"\xef\xbb\xbf";if($If)dump_csv(array_keys(fields($Q)));}else{if($Yc==2){$m=array();foreach(fields($Q)as$F=>$l)$m[]=idf_escape($F)." $l[full_type]";$g="CREATE TABLE ".table($Q)." (".implode(", ",$m).")";}else$g=create_sql($Q,$_POST["auto_increment"]);set_utf8mb4($g);if($If&&$g){if($If=="DROP+CREATE"||$Yc==1)echo"DROP ".($Yc==2?"VIEW":"TABLE")." IF EXISTS ".table($Q).";\n";if($Yc==1)$g=remove_definer($g);echo"$g;\n\n";}}}function
      Severity: Minor
      Found in include/adminer.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 select_value has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      md5(uniqid(mt_rand(),true));}function
      select_value($V,$z,$l,$he){global$b,$aa;if(is_array($V)){$K="";foreach($V
      as$w=>$U)$K.="<tr>".($V!=array_values($V)?"<th>".h($w):"")."<td>".select_value($U,$z,$l,$he);return"<table cellspacing='0'>$K</table>";}if(!$z)$z=$b->selectLink($V,$l);if($z===null){if(is_mail($V))$z="mailto:$V";if($qd=is_url($V))$z=(($qd=="http"&&$aa)||preg_match('~WebKit~i',$_SERVER["HTTP_USER_AGENT"])?$V:"https://www.adminer.org/redirect/?url=".urlencode($V));}$K=$b->editVal($V,$l);if($K!==null){if($K==="")$K="&nbsp;";elseif(!is_utf8($K))$K="\0";elseif($he!=""&&is_shortable($l))$K=shorten_utf8($K,max(0,+$he));else$K=h($K);}return$b->selectVal($K,$z,$l,$V);}function
      Severity: Minor
      Found in include/editor.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 select_value has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      md5(uniqid(mt_rand(),true));}function
      select_value($X,$A,$l,$ag){global$b,$ba;if(is_array($X)){$K="";foreach($X
      as$Zc=>$W)$K.="<tr>".($X!=array_values($X)?"<th>".h($Zc):"")."<td>".select_value($W,$A,$l,$ag);return"<table cellspacing='0'>$K</table>";}if(!$A)$A=$b->selectLink($X,$l);if($A===null){if(is_mail($X))$A="mailto:$X";if($Oe=is_url($X))$A=(($Oe=="http"&&$ba)||preg_match('~WebKit~i',$_SERVER["HTTP_USER_AGENT"])?$X:"https://www.adminer.org/redirect/?url=".urlencode($X));}$K=$b->editVal($X,$l);if($K!==null){if($K==="")$K="&nbsp;";elseif(!is_utf8($K))$K="\0";elseif($ag!=""&&is_shortable($l))$K=shorten_utf8($K,max(0,+$ag));else$K=h($K);}return$b->selectVal($K,$A,$l,$X);}function
      Severity: Minor
      Found in include/adminer.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

      File plugin.php has 269 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      /** Adminer customization allowing usage of plugins
      * @link https://www.adminer.org/plugins/#use
      * @author Jakub Vrana, http://www.vrana.cz/
      Severity: Minor
      Found in include/plugins/plugin.php - About 2 hrs to fix

        Function editFunctions has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        messageQuery($I,$bg){global$y;restart_session();$Ec=&get_session("queries");$u="sql-".count($Ec[$_GET["db"]]);if(strlen($I)>1e6)$I=preg_replace('~[\x80-\xFF]+$~','',substr($I,0,1e6))."\n...";$Ec[$_GET["db"]][]=array($I,time(),$bg);return" <span class='time'>".@date("H:i:s")."</span> <a href='#$u' onclick=\"return !toggle('$u');\">".'SQL command'."</a>"."<div id='$u' class='hidden'><pre><code class='jush-$y'>".shorten_utf8($I,1000).'</code></pre>'.($bg?" <span class='time'>($bg)</span>":'').(support("sql")?'<p><a href="'.h(str_replace("db=".urlencode(DB),"db=".urlencode($_GET["db"]),ME).'sql=&history='.(count($Ec[$_GET["db"]])-1)).'">'.'Edit'.'</a>':'').'</div>';}function
        editFunctions($l){global$Lb;$K=($l["null"]?"NULL/":"");foreach($Lb
        as$z=>$xc){if(!$z||(!isset($_GET["call"])&&(isset($_GET["select"])||where($_GET)))){foreach($xc
        as$ye=>$X){if(!$ye||preg_match("~$ye~",$l["type"]))$K.="/$X";}if($z&&!preg_match('~set|blob|bytea|raw|file~',$l["type"]))$K.="/SQL";}}if($l["auto_increment"]&&!isset($_GET["select"])&&!where($_GET))$K='Auto Increment';return
        explode("/",$K);}function
        Severity: Minor
        Found in include/adminer.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 tablesPrint has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function tablesPrint($tables) { ?>
        
          <p class="jsonly"><input id="filter-field">
          <style>
            .select-text {
        Severity: Major
        Found in include/plugins/FasterTablesFilter.php - About 2 hrs to fix

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

          selectSearchProcess($m,$t){$K=array();foreach((array)$_GET["where"]as$x=>$Y){$La=$Y["col"];$Uc=$Y["op"];$V=$Y["val"];if(($x<0?"":$La).$V!=""){$Ra=array();foreach(($La!=""?array($La=>$m[$La]):$m)as$D=>$l){if($La!=""||is_numeric($V)||!preg_match('~int|float|double|decimal~',$l["type"])){$D=idf_escape($D);if($La!=""&&$l["type"]=="enum")$Ra[]=(in_array(0,$V)?"$D IS NULL OR ":"")."$D IN (".implode(", ",array_map('intval',$V)).")";else{$ie=preg_match('~char|text|enum|set~',$l["type"]);$W=$this->processInput($l,(!$Uc&&$ie&&preg_match('~^[^%]+$~',$V)?"%$V%":$V));$Ra[]=$D.($W=="NULL"?" IS".($Uc==">="?" NOT":"")." $W":(in_array($Uc,$this->operators)||$Uc=="="?" $Uc $W":($ie?" LIKE $W":" IN (".str_replace(",","', '",$W).")")));if($x<0&&$V=="0")$Ra[]="$D IS NULL";}}}$K[]=($Ra?"(".implode(" OR ",$Ra).")":"0");}}return$K;}function
          selectOrderProcess($m,$t){$jc=$_GET["index_order"];if($jc!="")unset($_GET["order"][1]);if($_GET["order"])return
          array(idf_escape(reset($_GET["order"])).($_GET["desc"]?" DESC":""));foreach(($jc!=""?array($t[$jc]):$t)as$s){if($jc!=""||$s["type"]=="INDEX"){$Xb=array_filter($s["descs"]);$db=false;foreach($s["columns"]as$V){if(preg_match('~date|timestamp~',$m[$V]["type"])){$db=true;break;}}$K=array();foreach($s["columns"]as$x=>$V)$K[]=idf_escape($V).(($Xb?$s["descs"][$x]:$db)?" DESC":"");return$K;}}return
          array();}function
          Severity: Minor
          Found in include/editor.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 selectEmailProcess has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          selectLengthProcess(){return"100";}function
          selectEmailProcess($Y,$Mb){if($_POST["email_append"])return
          true;if($_POST["email"]){$Jd=0;if($_POST["all"]||$_POST["check"]){$l=idf_escape($_POST["email_field"]);$Yd=$_POST["email_subject"];$B=$_POST["email_message"];preg_match_all('~\\{\\$([a-z0-9_]+)\\}~i',"$Yd.$B",$Bc);$M=get_rows("SELECT DISTINCT $l".($Bc[1]?", ".implode(", ",array_map('idf_escape',array_unique($Bc[1]))):"")." FROM ".table($_GET["select"])." WHERE $l IS NOT NULL AND $l != ''".($Y?" AND ".implode(" AND ",$Y):"").($_POST["all"]?"":" AND ((".implode(") OR (",array_map('where_check',(array)$_POST["check"]))."))"));$m=fields($_GET["select"]);foreach($this->rowDescriptions($M,$Mb)as$L){$_d=array('{\\'=>'{');foreach($Bc[1]as$V)$_d['{$'."$V}"]=$this->editVal($L[$V],$m[$V]);$pb=$L[$_POST["email_field"]];if(is_mail($pb)&&send_mail($pb,strtr($Yd,$_d),strtr($B,$_d),$_POST["email_from"],$_FILES["email_files"]))$Jd++;}}cookie("adminer_email",$_POST["email_from"]);redirect(remove_from_uri(),lang(array('%d e-mail has been sent.','%d e-mails have been sent.'),$Jd));}return
          false;}function
          Severity: Minor
          Found in include/editor.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 referencable_primary has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          as$z=>$X){if($X===null)$X="<i>NULL</i>";elseif($Fa[$z]&&!is_utf8($X))$X="<i>".lang(array('%d byte','%d bytes'),strlen($X))."</i>";elseif(!strlen($X))$X="&nbsp;";else{$X=h($X);if($tg[$z]==254)$X="<code>$X</code>";}if(isset($od[$z])&&!$d[$od[$z]]){if($ge&&$y=="sql"){$Q=$L[array_search("table=",$od)];$A=$od[$z].urlencode($ge[$Q]!=""?$ge[$Q]:$Q);}else{$A="edit=".urlencode($od[$z]);foreach($w[$od[$z]]as$Ua=>$x)$A.="&where".urlencode("[".bracket_escape($Ua)."]")."=".urlencode($L[$x]);}$X="<a href='".h(ME.$A)."'>$X</a>";}echo"<td>$X";}}echo($t?"</table>":"<p class='message'>".'No rows.')."\n";return$K;}function
          referencable_primary($rf){$K=array();foreach(table_status('',true)as$Pf=>$Q){if($Pf!=$rf&&fk_support($Q)){foreach(fields($Pf)as$l){if($l["primary"]){if($K[$Pf]){unset($K[$Pf]);break;}$K[$Pf]=$l;}}}}return$K;}function
          Severity: Minor
          Found in include/adminer.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 rowDescriptions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          idf_escape($l["field"]);}return"";}function
          rowDescriptions($M,$Mb){$K=$M;foreach($M[0]as$x=>$V){if(list($R,$r,$D)=$this->_foreignColumn($Mb,$x)){$hc=array();foreach($M
          as$L)$hc[$L[$x]]=q($L[$x]);$eb=$this->_values[$R];if(!$eb)$eb=get_key_vals("SELECT $r, $D FROM ".table($R)." WHERE $r IN (".implode(", ",$hc).")");foreach($M
          as$C=>$L){if(isset($L[$x]))$K[$C][$x]=(string)$eb[$L[$x]];}}}return$K;}function
          Severity: Minor
          Found in include/editor.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 process_input has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          as$x=>$V){if($x===""||!$V)break;$Ib++;}$Sc=($Ib?" onchange=\"var f = this.form['function[".h(js_escape(bracket_escape($l["field"])))."]']; if ($Ib > f.selectedIndex) f.selectedIndex = $Ib;\" onkeyup='keyupChange.call(this);'":"");$c.=$Sc;$Yb=(in_array($o,$Tb)||isset($Tb[$o]));echo(count($Tb)>1?"<select name='function[$D]' onchange='functionChange(this);'".on_help("getTarget(event).value.replace(/^SQL\$/, '')",1).">".optionlist($Tb,$o===null||$Yb?$o:"")."</select>":nbsp(reset($Tb))).'<td>';$mc=$b->editInput($_GET["edit"],$l,$c,$W);if($mc!="")echo$mc;elseif($l["type"]=="set"){preg_match_all("~'((?:[^']|'')*)'~",$l["length"],$Bc);foreach($Bc[1]as$q=>$V){$V=stripcslashes(str_replace("''","'",$V));$Fa=(is_int($W)?($W>>$q)&1:in_array($V,explode(",",$W),true));echo" <label><input type='checkbox' name='fields[$D][$q]' value='".(1<<$q)."'".($Fa?' checked':'')."$Sc>".h($b->editVal($V,$l)).'</label>';}}elseif(preg_match('~blob|bytea|raw|file~',$l["type"])&&ini_bool("file_uploads"))echo"<input type='file' name='fields-$D'$Sc>";elseif(($ge=preg_match('~text|lob~',$l["type"]))||preg_match("~\n~",$W)){if($ge&&$v!="sqlite")$c.=" cols='50' rows='12'";else{$M=min(12,substr_count($W,"\n")+1);$c.=" cols='30' rows='$M'".($M==1?" style='height: 1.2em;'":"");}echo"<textarea$c>".h($W).'</textarea>';}elseif($o=="json")echo"<textarea$c cols='50' rows='12' class='jush-js'>".h($W).'</textarea>';else{$Gc=(!preg_match('~int~',$l["type"])&&preg_match('~^(\\d+)(,(\\d+))?$~',$l["length"],$A)?((preg_match("~binary~",$l["type"])?2:1)*$A[1]+($A[3]?1:0)+($A[2]&&!$l["unsigned"]?1:0)):($we[$l["type"]]?$we[$l["type"]]+($l["unsigned"]?0:1):0));if($v=='sql'&&$f->server_info>=5.6&&preg_match('~time~',$l["type"]))$Gc+=7;echo"<input".((!$Yb||$o==="")&&preg_match('~(?<!o)int~',$l["type"])?" type='number'":"")." value='".h($W)."'".($Gc?" maxlength='$Gc'":"").(preg_match('~char|binary~',$l["type"])&&$Gc>20?" size='40'":"")."$c>";}}}function
          process_input($l){global$b;$gc=bracket_escape($l["field"]);$o=$_POST["function"][$gc];$W=$_POST["fields"][$gc];if($l["type"]=="enum"){if($W==-1)return
          false;if($W=="")return"NULL";return+$W;}if($l["auto_increment"]&&$W=="")return
          null;if($o=="orig")return($l["on_update"]=="CURRENT_TIMESTAMP"?idf_escape($l["field"]):false);if($o=="NULL")return"NULL";if($l["type"]=="set")return
          array_sum((array)$W);if($o=="json"){$o="";$W=json_decode($W,true);if(!is_array($W))return
          Severity: Minor
          Found in include/editor.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 process_input has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          as$z=>$X){if($z===""||!$X)break;$pc++;}$Wd=($pc?" onchange=\"var f = this.form['function[".h(js_escape(bracket_escape($l["field"])))."]']; if ($pc > f.selectedIndex) f.selectedIndex = $pc;\" onkeyup='keyupChange.call(this);'":"");$wa.=$Wd;$Cc=(in_array($q,$xc)||isset($xc[$q]));echo(count($xc)>1?"<select name='function[$F]' onchange='functionChange(this);'".on_help("getTarget(event).value.replace(/^SQL\$/, '')",1).">".optionlist($xc,$q===null||$Cc?$q:"")."</select>":nbsp(reset($xc))).'<td>';$Pc=$b->editInput($_GET["edit"],$l,$wa,$Y);if($Pc!="")echo$Pc;elseif($l["type"]=="set"){preg_match_all("~'((?:[^']|'')*)'~",$l["length"],$rd);foreach($rd[1]as$t=>$X){$X=stripcslashes(str_replace("''","'",$X));$Na=(is_int($Y)?($Y>>$t)&1:in_array($X,explode(",",$Y),true));echo" <label><input type='checkbox' name='fields[$F][$t]' value='".(1<<$t)."'".($Na?' checked':'')."$Wd>".h($b->editVal($X,$l)).'</label>';}}elseif(preg_match('~blob|bytea|raw|file~',$l["type"])&&ini_bool("file_uploads"))echo"<input type='file' name='fields-$F'$Wd>";elseif(($Zf=preg_match('~text|lob~',$l["type"]))||preg_match("~\n~",$Y)){if($Zf&&$y!="sqlite")$wa.=" cols='50' rows='12'";else{$M=min(12,substr_count($Y,"\n")+1);$wa.=" cols='30' rows='$M'".($M==1?" style='height: 1.2em;'":"");}echo"<textarea$wa>".h($Y).'</textarea>';}elseif($q=="json")echo"<textarea$wa cols='50' rows='12' class='jush-js'>".h($Y).'</textarea>';else{$yd=(!preg_match('~int~',$l["type"])&&preg_match('~^(\\d+)(,(\\d+))?$~',$l["length"],$C)?((preg_match("~binary~",$l["type"])?2:1)*$C[1]+($C[3]?1:0)+($C[2]&&!$l["unsigned"]?1:0)):($tg[$l["type"]]?$tg[$l["type"]]+($l["unsigned"]?0:1):0));if($y=='sql'&&$e->server_info>=5.6&&preg_match('~time~',$l["type"]))$yd+=7;echo"<input".((!$Cc||$q==="")&&preg_match('~(?<!o)int~',$l["type"])?" type='number'":"")." value='".h($Y)."'".($yd?" maxlength='$yd'":"").(preg_match('~char|binary~',$l["type"])&&$yd>20?" size='40'":"")."$wa>";}}}function
          process_input($l){global$b;$Jc=bracket_escape($l["field"]);$q=$_POST["function"][$Jc];$Y=$_POST["fields"][$Jc];if($l["type"]=="enum"){if($Y==-1)return
          false;if($Y=="")return"NULL";return+$Y;}if($l["auto_increment"]&&$Y=="")return
          null;if($q=="orig")return($l["on_update"]=="CURRENT_TIMESTAMP"?idf_escape($l["field"]):false);if($q=="NULL")return"NULL";if($l["type"]=="set")return
          array_sum((array)$Y);if($q=="json"){$q="";$Y=json_decode($Y,true);if(!is_array($Y))return
          Severity: Minor
          Found in include/adminer.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

          Consider simplifying this complex logical expression.
          Open

          queries("ROLLBACK");}}$jb=array("server"=>"MySQL")+$jb;if(!defined("DRIVER")){$kd=array("MySQLi","MySQL","PDO_MySQL");define("DRIVER","server");if(extension_loaded("mysqli")){class
          Min_DB
          extends
          MySQLi{var$extension="MySQLi";function
          __construct(){parent::init();}function
          Severity: Critical
          Found in include/editor.php - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

            queries("ROLLBACK");}}$Eb=array("server"=>"MySQL")+$Eb;if(!defined("DRIVER")){$Ee=array("MySQLi","MySQL","PDO_MySQL");define("DRIVER","server");if(extension_loaded("mysqli")){class
            Min_DB
            extends
            MySQLi{var$extension="MySQLi";function
            __construct(){parent::init();}function
            Severity: Critical
            Found in include/adminer.php - About 2 hrs to fix

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

              rename_database($D,$Ma){$K=false;if(create_database($D,$Ma)){$zd=array();foreach(tables_list()as$R=>$ue)$zd[]=table($R)." TO ".idf_escape($D).".".table($R);$K=(!$zd||queries("RENAME TABLE ".implode(", ",$zd)));if($K)queries("DROP DATABASE ".idf_escape(DB));restart_session();set_session("dbs",null);}return$K;}function
              auto_increment(){$ta=" PRIMARY KEY";if($_GET["create"]!=""&&$_POST["auto_increment_col"]){foreach(indexes($_GET["create"])as$s){if(in_array($_POST["fields"][$_POST["auto_increment_col"]]["orig"],$s["columns"],true)){$ta="";break;}if($s["type"]=="PRIMARY")$ta=" UNIQUE";}}return" AUTO_INCREMENT$ta";}function
              Severity: Minor
              Found in include/editor.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 auto_increment has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              rename_database($F,$Wa){$K=false;if(create_database($F,$Wa)){$bf=array();foreach(tables_list()as$Q=>$U)$bf[]=table($Q)." TO ".idf_escape($F).".".table($Q);$K=(!$bf||queries("RENAME TABLE ".implode(", ",$bf)));if($K)queries("DROP DATABASE ".idf_escape(DB));restart_session();set_session("dbs",null);}return$K;}function
              auto_increment(){$za=" PRIMARY KEY";if($_GET["create"]!=""&&$_POST["auto_increment_col"]){foreach(indexes($_GET["create"])as$v){if(in_array($_POST["fields"][$_POST["auto_increment_col"]]["orig"],$v["columns"],true)){$za="";break;}if($v["type"]=="PRIMARY")$za=" UNIQUE";}}return" AUTO_INCREMENT$za";}function
              Severity: Minor
              Found in include/adminer.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 connect_error has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              set_utf8mb4($g){global$e;static$P=false;if(!$P&&preg_match('~\butf8mb4~i',$g)){$P=true;echo"SET NAMES ".charset($e).";\n\n";}}function
              connect_error(){global$b,$e,$T,$k,$Eb;if(DB!=""){header("HTTP/1.1 404 Not Found");page_header('Database'.": ".h(DB),'Invalid database.',true);}else{if($_POST["db"]&&!$k)queries_redirect(substr(ME,0,-1),'Databases have been dropped.',drop_databases($_POST["db"]));page_header('Select database',$k,false);echo"<p class='links'>\n";foreach(array('database'=>'Create new database','privileges'=>'Privileges','processlist'=>'Process list','variables'=>'Variables','status'=>'Status',)as$z=>$X){if(support($z))echo"<a href='".h(ME)."$z='>$X</a>\n";}echo"<p>".sprintf('%s version: %s through PHP extension %s',$Eb[DRIVER],"<b>".h($e->server_info)."</b>","<b>$e->extension</b>")."\n","<p>".sprintf('Logged as: %s',"<b>".h(logged_user())."</b>")."\n";$h=$b->databases();if($h){$of=support("scheme");$Xa=collations();echo"<form action='' method='post'>\n","<table cellspacing='0' class='checkable' onclick='tableClick(event);' ondblclick='tableClick(event, true);'>\n","<thead><tr>".(support("database")?"<td>&nbsp;":"")."<th>".'Database'." - <a href='".h(ME)."refresh=1'>".'Refresh'."</a>"."<td>".'Collation'."<td>".'Tables'."<td>".'Size'." - <a href='".h(ME)."dbsize=1' onclick=\"return !ajaxSetHtml('".h(js_escape(ME))."script=connect');\">".'Compute'."</a>"."</thead>\n";$h=($_GET["dbsize"]?count_tables($h):array_flip($h));foreach($h
              as$i=>$S){$hf=h(ME)."db=".urlencode($i);echo"<tr".odd().">".(support("database")?"<td>".checkbox("db[]",$i,in_array($i,(array)$_POST["db"])):""),"<th><a href='$hf'>".h($i)."</a>";$Wa=nbsp(db_collation($i,$Xa));echo"<td>".(support("database")?"<a href='$hf".($of?"&amp;ns=":"")."&amp;database=' title='".'Alter database'."'>$Wa</a>":$Wa),"<td align='right'><a href='$hf&amp;schema=' id='tables-".h($i)."' title='".'Database schema'."'>".($_GET["dbsize"]?$S:"?")."</a>","<td align='right' id='size-".h($i)."'>".($_GET["dbsize"]?db_size($i):"?"),"\n";}echo"</table>\n",(support("database")?"<fieldset><legend>".'Selected'." <span id='selected'></span></legend><div>\n"."<input type='hidden' name='all' value='' onclick=\"selectCount('selected', formChecked(this, /^db/));\">\n"."<input type='submit' name='drop' value='".'Drop'."'".confirm().">\n"."</div></fieldset>\n":""),"<script type='text/javascript'>tableCheck();</script>\n","<input type='hidden' name='token' value='$T'>\n","</form>\n";}}page_footer("db");}if(isset($_GET["status"]))$_GET["variables"]=$_GET["status"];if(isset($_GET["import"]))$_GET["sql"]=$_GET["import"];if(!(DB!=""?$e->select_db(DB):isset($_GET["sql"])||isset($_GET["dump"])||isset($_GET["database"])||isset($_GET["processlist"])||isset($_GET["privileges"])||isset($_GET["user"])||isset($_GET["variables"])||$_GET["script"]=="connect"||$_GET["script"]=="kill")){if(DB!=""||$_GET["refresh"]){restart_session();set_session("dbs",null);}connect_error();exit;}$Vd="RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT";class
              Severity: Minor
              Found in include/adminer.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 editInput has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  function editInput($table, $field, $attrs, $value) {
                      static $slugify;
                      if (!$_GET['select'] && !$_GET['where']) {
                          if ($slugify === null) {
                              $slugify = array();
              Severity: Minor
              Found in include/plugins/slugify.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