Avoid using undefined variables such as '$seedings' which will lead to PHP notices. Open
$seedings['numeric'] = '0123456789';
- 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 '$seedings' which will lead to PHP notices. Open
if (isset($seedings[$seeds]))
- 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 '$seedings' which will lead to PHP notices. Open
$seeds = $seedings[$seeds];
- 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 '$seedings' which will lead to PHP notices. Open
$seedings['alpha'] = 'abcdefghijklmnopqrstuvwqyz';
- 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 '$seedings' which will lead to PHP notices. Open
$seedings['hexidec'] = '0123456789abcdef';
- 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 '$seedings' which will lead to PHP notices. Open
$seedings['alphanum'] = 'abcdefghijklmnopqrstuvwqyz0123456789';
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
function str_rand($length = 8, $seeds = 'alphanum')
{
include ('mysql_access.php');
// Possible seeds
$seedings['alpha'] = 'abcdefghijklmnopqrstuvwqyz';
- 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 211.
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 6 and the first side effect is on line 2. Open
<?php
- Exclude checks
Line exceeds 120 characters; contains 190 characters Open
"We have received your forgotten password request. If you did not submit this request, please let the webmaster know as soon as possible so security measures can be taken.\n \n" .
- Exclude checks
Line exceeds 120 characters; contains 298 characters Open
"To ensure the privacy of your password, it has been stored in an encrypted form and cannot be decrypted. Therefore, your password has been set to a random value, displayed below. When you login, please update your password. This new password only becomes active if you use it.\n \n" .
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$new_password = str_rand(15, 'alphanum');
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo 'Error: Email does not exist in our database.';
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$subject = "APO Epsilon Password Request";
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$sql = "UPDATE `contact_information` SET `password` = '$hash' WHERE id = '$id'";
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$query = $db->query($sql) or die("If you encounter problems, please contact the webmaster.");
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
} else {
- Exclude checks
A closing tag is not permitted at the end of a PHP file Open
?>
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$mail->Subject = $subject;
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$emailToSend = $firstname . " " . $lastname . ",\n\n" .
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
echo "Mailer Error: " . $mail->ErrorInfo;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
if(!$mail->Send()) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
exit;
- Exclude checks
Expected 1 space after closing parenthesis; found 5 Open
if (isset($seedings[$seeds]))
- Exclude checks
Expected 1 space after closing parenthesis; found 5 Open
for ($i = 0; $length > $i; $i++)
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
echo "Message has been sent.";
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(!$mail->Send()) {
- Exclude checks
Space before opening parenthesis of function call prohibited Open
require_once ('session.php');
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
extract($r);
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$mail->Body = $emailToSend;
- Exclude checks
Space before opening parenthesis of function call prohibited Open
require_once ('PasswordHash.php');
- Exclude checks
Space before opening parenthesis of function call prohibited Open
require_once ('mysql_access.php');
- Exclude checks
Space before opening parenthesis of function call prohibited Open
include ('mysql_access.php');
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo "<p>Name found.</p>";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$mail->AddAddress("$email", "$firstname $lastname");
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
echo "Message could not be sent. <p>";
- Exclude checks
The variable $seeds_count is not named in camelCase. Open
function str_rand($length = 8, $seeds = 'alphanum')
{
include ('mysql_access.php');
// Possible seeds
$seedings['alpha'] = 'abcdefghijklmnopqrstuvwqyz';
- 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 $seeds_count is not named in camelCase. Open
function str_rand($length = 8, $seeds = 'alphanum')
{
include ('mysql_access.php');
// Possible seeds
$seedings['alpha'] = 'abcdefghijklmnopqrstuvwqyz';
- 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();
}
}