list_exec_by_page accesses the super-global variable $_SERVER. Open
function list_exec_by_page() {
include('mysql_access.php');
if(isset($_GET['remove'])) {
$sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
$result = $db->query($sql);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
show_exec accesses the super-global variable $_GET. Open
function show_exec() {
if(isset($_GET['page_id'])) {
list_exec_by_page();
} else if(isset($_GET['position_id'])) {
list_page_by_exec();
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_exec_by_page accesses the super-global variable $_GET. Open
function list_exec_by_page() {
include('mysql_access.php');
if(isset($_GET['remove'])) {
$sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
$result = $db->query($sql);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_page_by_exec accesses the super-global variable $_GET. Open
function list_page_by_exec() {
if(isset($_GET['remove'])) {
remove_permission($_GET['remove'], $_GET['position_id']);
} elseif(isset($_GET['add'])) {
add_permission($_GET['add'], $_GET['position_id']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_page_by_exec accesses the super-global variable $_SERVER. Open
function list_page_by_exec() {
if(isset($_GET['remove'])) {
remove_permission($_GET['remove'], $_GET['position_id']);
} elseif(isset($_GET['add'])) {
add_permission($_GET['add'], $_GET['position_id']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_page_by_exec accesses the super-global variable $_GET. Open
function list_page_by_exec() {
if(isset($_GET['remove'])) {
remove_permission($_GET['remove'], $_GET['position_id']);
} elseif(isset($_GET['add'])) {
add_permission($_GET['add'], $_GET['position_id']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_page_by_exec accesses the super-global variable $_SERVER. Open
function list_page_by_exec() {
if(isset($_GET['remove'])) {
remove_permission($_GET['remove'], $_GET['position_id']);
} elseif(isset($_GET['add'])) {
add_permission($_GET['add'], $_GET['position_id']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_page_by_exec accesses the super-global variable $_GET. Open
function list_page_by_exec() {
if(isset($_GET['remove'])) {
remove_permission($_GET['remove'], $_GET['position_id']);
} elseif(isset($_GET['add'])) {
add_permission($_GET['add'], $_GET['position_id']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_page_by_exec accesses the super-global variable $_GET. Open
function list_page_by_exec() {
if(isset($_GET['remove'])) {
remove_permission($_GET['remove'], $_GET['position_id']);
} elseif(isset($_GET['add'])) {
add_permission($_GET['add'], $_GET['position_id']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_exec_by_page accesses the super-global variable $_GET. Open
function list_exec_by_page() {
include('mysql_access.php');
if(isset($_GET['remove'])) {
$sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
$result = $db->query($sql);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_page_by_exec accesses the super-global variable $_GET. Open
function list_page_by_exec() {
if(isset($_GET['remove'])) {
remove_permission($_GET['remove'], $_GET['position_id']);
} elseif(isset($_GET['add'])) {
add_permission($_GET['add'], $_GET['position_id']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_page_by_exec accesses the super-global variable $_GET. Open
function list_page_by_exec() {
if(isset($_GET['remove'])) {
remove_permission($_GET['remove'], $_GET['position_id']);
} elseif(isset($_GET['add'])) {
add_permission($_GET['add'], $_GET['position_id']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_exec_by_page accesses the super-global variable $_GET. Open
function list_exec_by_page() {
include('mysql_access.php');
if(isset($_GET['remove'])) {
$sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
$result = $db->query($sql);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_exec_by_page accesses the super-global variable $_GET. Open
function list_exec_by_page() {
include('mysql_access.php');
if(isset($_GET['remove'])) {
$sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
$result = $db->query($sql);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_exec_by_page accesses the super-global variable $_SERVER. Open
function list_exec_by_page() {
include('mysql_access.php');
if(isset($_GET['remove'])) {
$sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
$result = $db->query($sql);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_exec_by_page accesses the super-global variable $_SERVER. Open
function list_exec_by_page() {
include('mysql_access.php');
if(isset($_GET['remove'])) {
$sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
$result = $db->query($sql);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_page_by_exec accesses the super-global variable $_GET. Open
function list_page_by_exec() {
if(isset($_GET['remove'])) {
remove_permission($_GET['remove'], $_GET['position_id']);
} elseif(isset($_GET['add'])) {
add_permission($_GET['add'], $_GET['position_id']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_page_by_exec accesses the super-global variable $_SERVER. Open
function list_page_by_exec() {
if(isset($_GET['remove'])) {
remove_permission($_GET['remove'], $_GET['position_id']);
} elseif(isset($_GET['add'])) {
add_permission($_GET['add'], $_GET['position_id']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_exec_by_page accesses the super-global variable $_GET. Open
function list_exec_by_page() {
include('mysql_access.php');
if(isset($_GET['remove'])) {
$sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
$result = $db->query($sql);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
show_exec accesses the super-global variable $_GET. Open
function show_exec() {
if(isset($_GET['page_id'])) {
list_exec_by_page();
} else if(isset($_GET['position_id'])) {
list_page_by_exec();
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_exec_by_page accesses the super-global variable $_GET. Open
function list_exec_by_page() {
include('mysql_access.php');
if(isset($_GET['remove'])) {
$sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
$result = $db->query($sql);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_page_by_exec accesses the super-global variable $_GET. Open
function list_page_by_exec() {
if(isset($_GET['remove'])) {
remove_permission($_GET['remove'], $_GET['position_id']);
} elseif(isset($_GET['add'])) {
add_permission($_GET['add'], $_GET['position_id']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_positions accesses the super-global variable $_SERVER. Open
function list_positions() {
include('mysql_access.php');
$sql = "SELECT position, position_id FROM positions ORDER BY position_order ASC;";
$result = $db->query($sql);
echo "<div class=\"medium-6 small-12 columns\">";
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_pages accesses the super-global variable $_SERVER. Open
function list_pages() {
include('mysql_access.php');
$sql = "SELECT page, entry_id FROM exec_permissions_pages ORDER BY page ASC;";
$result = $db->query($sql);
echo "<div class=\"medium-6 small-12 columns\">";
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_exec_by_page accesses the super-global variable $_GET. Open
function list_exec_by_page() {
include('mysql_access.php');
if(isset($_GET['remove'])) {
$sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
$result = $db->query($sql);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
list_page_by_exec accesses the super-global variable $_GET. Open
function list_page_by_exec() {
if(isset($_GET['remove'])) {
remove_permission($_GET['remove'], $_GET['position_id']);
} elseif(isset($_GET['add'])) {
add_permission($_GET['add'], $_GET['position_id']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Method list_exec_by_page
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function list_exec_by_page() {
include('mysql_access.php');
if(isset($_GET['remove'])) {
$sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
$result = $db->query($sql);
Method list_page_by_exec
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function list_page_by_exec() {
if(isset($_GET['remove'])) {
remove_permission($_GET['remove'], $_GET['position_id']);
} elseif(isset($_GET['add'])) {
add_permission($_GET['add'], $_GET['position_id']);
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
The method show_exec uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
echo "<div class='small-12 columns text-center'><h2>Permissions Manager</h2></div>";
list_pages();
list_positions();
}
- 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 add_permission uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
echo "$position permission added for $page";
}
- 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 remove_permission uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
echo "$position permission removed for $page";
}
- 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
Avoid unused local variables such as '$db'. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused local variables such as '$db'. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Similar blocks of code found in 2 locations. Consider refactoring. Open
function remove_permission($pageId, $execId) {
include('mysql_access.php');
$sql = "SELECT page FROM exec_permissions_pages WHERE entry_id=$pageId;";
$result = $db->query($sql);
$row = mysqli_fetch_array($result);
- Read upRead up
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 166.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
function add_permission($pageId, $execId) {
include('mysql_access.php');
$sql = "SELECT page FROM exec_permissions_pages WHERE entry_id=$pageId;";
$result = $db->query($sql);
$row = mysqli_fetch_array($result);
- Read upRead up
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 166.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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 23 and the first side effect is on line 2. Open
<?php
- Exclude checks
Line exceeds 120 characters; contains 285 characters Open
$sql = "SELECT exec_permissions.page AS page, exec_permissions_pages.entry_id AS page_id FROM exec_permissions_pages INNER JOIN exec_permissions ON exec_permissions.page=exec_permissions_pages.page WHERE exec_permissions.position=\"$position\" ORDER BY exec_permissions.page ASC;";
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
echo "<tr><td>{$row['page']}</td><td><a href=\"{$_SERVER['PHP_SELF']}?page_id={$row['entry_id']}\" class=\"button expand\">Edit</a></td></tr>";
- Exclude checks
Line exceeds 120 characters; contains 162 characters Open
echo "<tr><td>{$row['position']}</td><td><a href=\"{$_SERVER['PHP_SELF']}?position_id={$row['position_id']}\" class=\"button expand\">Edit</a></td></tr>";
- Exclude checks
Line exceeds 120 characters; contains 214 characters Open
$sql = "SELECT exec_permissions.position AS position FROM exec_permissions_pages INNER JOIN exec_permissions ON exec_permissions.page=exec_permissions_pages.page WHERE exec_permissions_pages.entry_id=$pageId;";
- Exclude checks
Line exceeds 120 characters; contains 172 characters Open
echo "<tr><td>{$row['position']}</td><td><a href=\"{$_SERVER['PHP_SELF']}?page_id=$pageId&remove={$row['position']}\" class=\"button expand\">Remove</a></td></tr>";
- Exclude checks
Line exceeds 120 characters; contains 186 characters Open
echo "<tr><td>{$row['page']}</td><td><a href=\"{$_SERVER['PHP_SELF']}?position_id={$_GET['position_id']}&remove={$row['page_id']}\" class=\"button expand\">Remove</a></td></tr>";
- Exclude checks
Usage of ELSE IF is discouraged; use ELSEIF instead Open
} else if(isset($_GET['position_id'])) {
- Exclude checks
Opening brace should be on a new line Open
function list_pages() {
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($row = mysqli_fetch_array($result)) {
- Exclude checks
Space before opening parenthesis of function call prohibited Open
require_once ('session.php');
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(!$result) {
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($row = mysqli_fetch_array($result)) {
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($row = mysqli_fetch_array($result)) {
- Exclude checks
Opening brace should be on a new line Open
function list_page_by_exec() {
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(!$result) {
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($row = mysqli_fetch_array($result)) {
- Exclude checks
Expected 1 space after ELSEIF keyword; 0 found Open
} elseif(isset($_GET['add'])) {
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(isset($_GET['remove'])) {
- Exclude checks
Opening brace should be on a new line Open
function remove_permission($pageId, $execId) {
- Exclude checks
Expected 1 space after ELSEIF keyword; 0 found Open
} elseif(isset($_GET['add'])) {
- Exclude checks
Opening brace should be on a new line Open
function add_permission($pageId, $execId) {
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(isset($_GET['page_id'])) {
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($row = mysqli_fetch_array($result)) {
- Exclude checks
Opening brace should be on a new line Open
function list_positions() {
- Exclude checks
Opening brace should be on a new line Open
function show_exec() {
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(isset($_GET['remove'])) {
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
} else if(isset($_GET['position_id'])) {
- Exclude checks
Opening brace should be on a new line Open
function list_exec_by_page() {
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($row = mysqli_fetch_array($result)) {
- Exclude checks