family_tree.php
Method show_public
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function show_public() {
include('mysql_access.php');
//generate dot for viz.js
?>
<script type='text/vnd.graphviz' id='family_tree_script'>
Function show_public
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
function show_public() {
include('mysql_access.php');
//generate dot for viz.js
?>
<script type='text/vnd.graphviz' id='family_tree_script'>
- 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 function show_public() has 112 lines of code. Current threshold is set to 100. Avoid really long methods. Open
Open
function show_public() {
include('mysql_access.php');
//generate dot for viz.js
?>
<script type='text/vnd.graphviz' id='family_tree_script'>
- Exclude checks
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
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
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
Open
$result2 = $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
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
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 27 and the first side effect is on line 2. Open
Open
<?php
- Exclude checks
Avoid variables with short names like $id. Configured minimum length is 3. Open
Open
$id = $row2['id'];
- 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
TRUE, FALSE and NULL must be lowercase; expected "false" but found "False" Open
Open
$exec_page = False;
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "False" Open
Open
$active_page = False;
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "True" Open
Open
$public_page = True;
- Exclude checks
Line exceeds 120 characters; contains 320 characters Open
Open
$sql = "SELECT DISTINCT pledgeyear, pledgesem FROM (SELECT pledgeyear, pledgesem FROM contact_information UNION DISTINCT SELECT pledgeyear, pledgesem FROM alumni UNION DISTINCT SELECT pledgeyear, pledgesem FROM alumni_info)all_users WHERE pledgeyear<>\"\" AND pledgesem<>\"\" ORDER BY pledgeyear ASC, pledgesem DESC;";
- Exclude checks
Line exceeds 120 characters; contains 211 characters Open
Open
$sql = "SELECT id, firstname, lastname FROM contact_information UNION DISTINCT SELECT id, firstname, lastname FROM alumni UNION DISTINCT SELECT id, firstname, lastname FROM alumni_info ORDER BY lastname ASC;";
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
Open
scrollTop: elementid.offset().top + elementid.get(0).getBBox().height/2 - container.offset().top + container.scrollTop() - container.height()/2
- Exclude checks
Line exceeds 120 characters; contains 391 characters Open
Open
$sql = "SELECT id, firstname, lastname FROM (SELECT id, firstname, lastname, pledgeyear, pledgesem FROM contact_information UNION DISTINCT SELECT id, firstname, lastname, pledgeyear, pledgesem FROM alumni UNION DISTINCT SELECT id, firstname, lastname, pledgeyear, pledgesem FROM alumni_info)all_users WHERE pledgesem=\"$pledgesem\" AND pledgeyear=\"$pledgeyear\" ORDER BY lastname ASC;";
- Exclude checks
Line exceeds 120 characters; contains 154 characters Open
Open
scrollLeft: elementid.offset().left + elementid.get(0).getBBox().width/2 - container.offset().left + container.scrollLeft() - container.width()/2,
- Exclude checks
Line exceeds 120 characters; contains 144 characters Open
Open
<script>document.getElementById('family_tree').innerHTML = Viz(document.getElementById('family_tree_script').innerHTML, "svg", "dot")</script>
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 6 Open
Open
if (empty($colorarrayloop)) {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
$id = $row2['id'];
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
$rank .= " " . $id;
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 2 Open
Open
while ($row = mysqli_fetch_array($result)) {
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
while ($row = mysqli_fetch_array($result)) {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
$lastname = $row2['lastname'];
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 2 Open
Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
echo "\"$id\" [label=\"$firstname $lastname\", id=\"$id\", color=$color];\n";
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 6 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
while ($row = mysqli_fetch_array($result)) {
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
Open
include('mysql_access.php');
- Exclude checks
Closing brace indented incorrectly; expected 4 spaces, found 2 Open
Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
$firstname = $row2['firstname'];
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 2 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
}
- Exclude checks
Opening brace should be on a new line Open
Open
function show_public() {
- Exclude checks
Space before opening parenthesis of function call prohibited Open
Open
require_once ('session.php');
- Exclude checks