show_exec accesses the super-global variable $_SESSION. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $_SERVER. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $_SERVER. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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_public accesses the super-global variable $_SERVER. Open
function show_public() {
include('mysql_access.php');
$sql = "SELECT page_text FROM editable_pages WHERE page_name=\"$_SERVER[PHP_SELF]\";";
$result = $db->query($sql);
$page_array = mysqli_fetch_array($result);
- 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 $_SERVER. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $_POST. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $_POST. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 show_exec
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$page_text = $db->real_escape_string($page_text);
- 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
echo $db->error;
- 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 "Update Failed";
echo $db->error;
}
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
$exec_page = True;
$active_page = False;
$public_page = True;
- 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 317.
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 8 and the first side effect is on line 3. Open
<?php
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "False" Open
$active_page = False;
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "True" Open
$exec_page = True;
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "True" Open
$public_page = True;
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
$sql = "UPDATE editable_pages SET page_text=\"$page_text\", edit_date=\"$today\", edit_id=\"$user_id\" WHERE page_name=\"$_SERVER[PHP_SELF]\";";
- Exclude checks
Line exceeds 120 characters; contains 165 characters Open
plugins : ["charmap", "fullscreen", "link", "paste", "textcolor", "anchor", "code", "lists", "preview", "searchreplace", "table", "autolink", "contextmenu"],
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
include('mysql_access.php');
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
include('mysql_access.php');
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(isset($_POST['page_text'])) {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$result = $db->query($sql);
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$page_array = mysqli_fetch_array($result);
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$page_text = $page_array['page_text'];
- Exclude checks
A closing tag is not permitted at the end of a PHP file Open
?>
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if($result) {
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$result = $db->query($sql);
- Exclude checks
Opening brace should be on a new line Open
function show_public() {
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$result = $db->query($sql);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$page_text = trim($page_text);
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
if(isset($_POST['page_text'])) {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$user_id = $_SESSION['sessionID'];
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$sql = "SELECT page_text FROM editable_pages WHERE page_name=\"$_SERVER[PHP_SELF]\";";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$page_array = mysqli_fetch_array($result);
- Exclude checks
Opening brace should be on a new line Open
function show_exec() {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$sql = "UPDATE editable_pages SET page_text=\"$page_text\", edit_date=\"$today\", edit_id=\"$user_id\" WHERE page_name=\"$_SERVER[PHP_SELF]\";";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo $page_text;
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if($result) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$page_text = $_POST['page_text'];
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo <<<END
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$page_text = stripslashes($page_text);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$today = date("Y-m-d");
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$page_text = $page_array['page_text'];
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$page_text = $db->real_escape_string($page_text);
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
echo "Update Successful";
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
echo "Update Failed";
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
echo $db->error;
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
} else {
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$sql = "SELECT page_text FROM editable_pages WHERE page_name=\"$_SERVER[PHP_SELF]\";";
- Exclude checks
The variable $page_text is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $page_text is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $page_text is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $user_id is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $page_array is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $page_array is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $page_text is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $page_array is not named in camelCase. Open
function show_public() {
include('mysql_access.php');
$sql = "SELECT page_text FROM editable_pages WHERE page_name=\"$_SERVER[PHP_SELF]\";";
$result = $db->query($sql);
$page_array = mysqli_fetch_array($result);
- 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 $page_text is not named in camelCase. Open
function show_public() {
include('mysql_access.php');
$sql = "SELECT page_text FROM editable_pages WHERE page_name=\"$_SERVER[PHP_SELF]\";";
$result = $db->query($sql);
$page_array = mysqli_fetch_array($result);
- 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 $page_text is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $page_text is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $page_text is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $page_array is not named in camelCase. Open
function show_public() {
include('mysql_access.php');
$sql = "SELECT page_text FROM editable_pages WHERE page_name=\"$_SERVER[PHP_SELF]\";";
$result = $db->query($sql);
$page_array = mysqli_fetch_array($result);
- 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 $page_text is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $page_text is not named in camelCase. Open
function show_public() {
include('mysql_access.php');
$sql = "SELECT page_text FROM editable_pages WHERE page_name=\"$_SERVER[PHP_SELF]\";";
$result = $db->query($sql);
$page_array = mysqli_fetch_array($result);
- 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 $page_text is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $user_id is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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 $page_text is not named in camelCase. Open
function show_exec() {
include('mysql_access.php');
if(isset($_POST['page_text'])) {
$page_text = $_POST['page_text'];
$page_text = trim($page_text);
- 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();
}
}