APO-Epsilon/apo-website

View on GitHub
family_tree.php

Summary

Maintainability
B
4 hrs
Test Coverage

Method show_public has 100 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function show_public() {
  include('mysql_access.php');
  //generate dot for viz.js
?>
  <script type='text/vnd.graphviz' id='family_tree_script'>
Severity: Major
Found in family_tree.php - About 4 hrs to fix

    Function show_public has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function show_public() {
      include('mysql_access.php');
      //generate dot for viz.js
    ?>
      <script type='text/vnd.graphviz' id='family_tree_script'>
    Severity: Minor
    Found in family_tree.php - About 35 mins to fix

    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

    function show_public() {
      include('mysql_access.php');
      //generate dot for viz.js
    ?>
      <script type='text/vnd.graphviz' id='family_tree_script'>
    Severity: Minor
    Found in family_tree.php by phpmd

    Avoid using undefined variables such as '$db' which will lead to PHP notices.
    Open

      $result = $db->query($sql);
    Severity: Minor
    Found in family_tree.php by phpmd

    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);
    Severity: Minor
    Found in family_tree.php by phpmd

    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

        $result2 = $db->query($sql);
    Severity: Minor
    Found in family_tree.php by phpmd

    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);
    Severity: Minor
    Found in family_tree.php by phpmd

    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

    <?php
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

          $id = $row2['id'];
    Severity: Minor
    Found in family_tree.php by phpmd

    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

    $exec_page = False;
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    TRUE, FALSE and NULL must be lowercase; expected "false" but found "False"
    Open

    $active_page = False;
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    TRUE, FALSE and NULL must be lowercase; expected "true" but found "True"
    Open

    $public_page = True;
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line exceeds 120 characters; contains 320 characters
    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;";
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line exceeds 120 characters; contains 211 characters
    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;";
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line exceeds 120 characters; contains 151 characters
    Open

            scrollTop: elementid.offset().top + elementid.get(0).getBBox().height/2 - container.offset().top + container.scrollTop() - container.height()/2
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line exceeds 120 characters; contains 391 characters
    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;";
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line exceeds 120 characters; contains 154 characters
    Open

            scrollLeft: elementid.offset().left + elementid.get(0).getBBox().width/2 - container.offset().left + container.scrollLeft() - container.width()/2,
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line exceeds 120 characters; contains 144 characters
    Open

      <script>document.getElementById('family_tree').innerHTML = Viz(document.getElementById('family_tree_script').innerHTML, "svg", "dot")</script>
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 6
    Open

          if (empty($colorarrayloop)) {
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

          $id = $row2['id'];
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

          $rank .= " " . $id;
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected 0 spaces, found 2
    Open

      while ($row = mysqli_fetch_array($result)) {
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        while ($row = mysqli_fetch_array($result)) {
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

          $lastname = $row2['lastname'];
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected 0 spaces, found 2
    Open

      }
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

          echo "\"$id\" [label=\"$firstname $lastname\", id=\"$id\", color=$color];\n";
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 6
    Open

          }
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        while ($row = mysqli_fetch_array($result)) {
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected at least 4 spaces, found 2
    Open

      include('mysql_access.php');
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Closing brace indented incorrectly; expected 4 spaces, found 2
    Open

      }
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected at least 8 spaces, found 6
    Open

          $firstname = $row2['firstname'];
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected 0 spaces, found 2
    Open

      }
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        }
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Opening brace should be on a new line
    Open

    function show_public() {
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    Space before opening parenthesis of function call prohibited
    Open

    require_once ('session.php');
    Severity: Minor
    Found in family_tree.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status