File mytplsadmin.php
has 379 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
Method copy_templates_db2db
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
Method copy_templates_f2db
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
Function copy_templates_db2db
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
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 copy_templates_f2db
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
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
The method copy_templates_db2db uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
while (list($tpl_id) = $db->fetchRow($drs)) {
// UPDATE mode
$db->query('UPDATE '
. $db->prefix('tplfile')
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method copy_templates_f2db uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
while (list($tpl_id) = $db->fetchRow($drs)) {
// UPDATE mode
$db->query('UPDATE ' . $db->prefix('tplfile') . " SET tpl_lastmodified='" . addslashes($lastmodified) . "' WHERE tpl_id='$tpl_id'");
$db->query('UPDATE ' . $db->prefix('tplsource') . " SET tpl_source='" . addslashes($tpl_source) . "' WHERE tpl_id='$tpl_id'");
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The parameter $tplset_to is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $tplset_from is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $whr_append is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Avoid variables with short names like $db. Configured minimum length is 3. Open
global $db;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The parameter $tplset_to is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $whr_append is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Avoid variables with short names like $db. Configured minimum length is 3. Open
global $db;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 368 and the first side effect is on line 21. Open
<?php
- Exclude checks
Line exceeds 120 characters; contains 153 characters Open
list($is_exist) = $db->fetchRow($db->query('SELECT COUNT(*) FROM ' . $db->prefix('tplfile') . " WHERE tpl_tplset='" . addslashes($tplset_to) . "'"));
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
$sql = 'SELECT DISTINCT tpl_tplset FROM ' . $db->prefix('tplfile') . " ORDER BY tpl_tplset='default' DESC,tpl_tplset";
- Exclude checks
Line exceeds 120 characters; contains 223 characters Open
<th><input type='checkbox' onclick=\"with(document.MainForm){for (i=0;i<length;i++) {if(elements[i].type=='checkbox'&&elements[i].name.indexOf('basecheck')>=0) {elements[i].checked=this.checked;}}}\" />file</th>
- Exclude checks
Line exceeds 120 characters; contains 144 characters Open
<form class='apcalForm' id='MainForm' name='MainForm' action='?dirname=" . htmlspecialchars($target_dirname, ENT_QUOTES) . "' method='post'>
- Exclude checks
Line exceeds 120 characters; contains 178 characters Open
$sql = 'SELECT tpl_file,tpl_desc,tpl_type,COUNT(tpl_id) FROM ' . $db->prefix('tplfile') . " WHERE tpl_module='$target_dirname4sql' GROUP BY tpl_file ORDER BY tpl_type, tpl_file";
- Exclude checks
Line exceeds 120 characters; contains 178 characters Open
$db->query('INSERT INTO ' . $db->prefix('tplset') . " SET tplset_name='" . addslashes($tplset_to) . "', tplset_desc='Created by tplsadmin', tplset_created=UNIX_TIMESTAMP()");
- Exclude checks
Line exceeds 120 characters; contains 153 characters Open
list($is_exist) = $db->fetchRow($db->query('SELECT COUNT(*) FROM ' . $db->prefix('tplset') . " WHERE tplset_name='" . addslashes($tplset_to) . "'"));
- Exclude checks
Line exceeds 120 characters; contains 142 characters Open
. "<br><input type='checkbox' name='{$tplset4disp}_check[{$tpl_file}]' value='1' /> <a href='mytplsform.php?tpl_file="
- Exclude checks
Line exceeds 120 characters; contains 179 characters Open
<select name='clone_tplset_from'>$tplset_options</select>-><input type='text' name='clone_tplset_to' size='8' /><input type='submit' name='clone_tplset_do' value='"
- Exclude checks
Line exceeds 120 characters; contains 187 characters Open
$result = $db->query('SELECT tpl_id FROM ' . $db->prefix('tplfile') . " WHERE tpl_tplset='" . addslashes($tplset_from) . "' AND tpl_file='" . addslashes($tplfile) . "'");
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
$target_mname = $target_module->getVar('name') . ' ' . sprintf('(%2.2f)', $target_module->getVar('version') / 100.0);
- Exclude checks
Line exceeds 120 characters; contains 272 characters Open
$tplsets_th4disp .= "<th $th_style><input type='checkbox' onclick=\"with(document.MainForm){for (i=0;i<length;i++) {if(elements[i].type=='checkbox'&&elements[i].name.indexOf('{$tplset4disp}_check')>=0) {elements[i].checked=this.checked;}}}\" />DB-{$tplset4disp}</th>";
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
$basefilepath = XOOPS_ROOT_PATH . '/modules/' . $target_dirname . '/templates/' . ($type === 'block' ? 'blocks/' : '') . $tpl_file;
- Exclude checks
Line exceeds 120 characters; contains 185 characters Open
" . ($tplset === 'default' ? '' : "<input name='del_do[{$tplset4disp}]' type='submit' value='" . _DELETE . "' onclick='return confirm(\"" . _DELETE . " OK?\");' /><br>") . "
- Exclude checks
Line exceeds 120 characters; contains 142 characters Open
$db->query('UPDATE ' . $db->prefix('tplsource') . " SET tpl_source='" . addslashes($tpl_source) . "' WHERE tpl_id='$tpl_id'");
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
$db->query('UPDATE ' . $db->prefix('tplfile') . " SET tpl_lastmodified='" . addslashes($lastmodified) . "' WHERE tpl_id='$tpl_id'");
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
$db->query('INSERT INTO ' . $db->prefix('tplsource') . " SET tpl_id='$tpl_id', tpl_source='" . addslashes($tpl_source) . "'");
- Exclude checks
Line exceeds 120 characters; contains 168 characters Open
$sql = 'INSERT INTO ' . $db->prefix('tplfile') . ' (tpl_refid,tpl_module,tpl_tplset,tpl_file,tpl_desc,tpl_lastmodified,tpl_lastimported,tpl_type) VALUES (';
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
$db->query('INSERT INTO ' . $db->prefix('tplsource') . " SET tpl_id='$tpl_id', tpl_source='" . addslashes($tpl_source) . "'");
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
$basefilepath = XOOPS_ROOT_PATH . '/modules/' . $row['tpl_module'] . '/templates/' . ($row['tpl_type'] === 'block' ? 'blocks/' : '') . $row['tpl_file'];
- Exclude checks
Line exceeds 120 characters; contains 142 characters Open
$db->query('UPDATE ' . $db->prefix('tplsource') . " SET tpl_source='" . addslashes($tpl_source) . "' WHERE tpl_id='$tpl_id'");
- Exclude checks
The variable $tpl_id is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_id is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tplset_from is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_source is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $whr_append is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_id is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_source is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_id is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_source is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_id is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $whr_append is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_id is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_id is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tplset_to is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $whr_append is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tplset_to is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_source is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_id is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $whr_append is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_id is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_id is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_id is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tplset_to is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_id is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_id is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_source is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tplset_to is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_source is not named in camelCase. Open
function copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1')
{
global $db;
// get tplfile and tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tpl_id is not named in camelCase. Open
function copy_templates_f2db($tplset_to, $whr_append = '1')
{
global $db;
// get tplsource
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}