APO-Epsilon/apo-website

View on GitHub
attendance.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method list_attendance_stats has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function list_attendance_stats($user_id){

  $sql = "SELECT
      events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
      FROM occurrence
Severity: Minor
Found in attendance.php - About 1 hr to fix

    Function list_attendance_stats has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    function list_attendance_stats($user_id){
    
      $sql = "SELECT
          events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
          FROM occurrence
    Severity: Minor
    Found in attendance.php - About 1 hr 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

    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 41 and the first side effect is on line 29.
    Open

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

    The parameter $user_id is not named in camelCase.
    Open

    function list_attendance_stats($user_id){
    
      $sql = "SELECT
          events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
          FROM occurrence
    Severity: Minor
    Found in attendance.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    Blank line found at start of control structure
    Open

    if (!isset($_SESSION['sessionID'])) {
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Blank line found at start of control structure
    Open

    }else{
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Space before opening parenthesis of function call prohibited
    Open

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

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

      $sql = "SELECT
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after WHILE keyword; 0 found
    Open

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

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

          $comm_id = $row['comm_id'];
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

          $position = $row['position'];
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

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

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

          die("Attendance is not currently recorded for pledges");
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

          $num_missed = $row['num_missed'];
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

          $num_missed_total = $row['num_missed'];
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after ELSE keyword; 0 found
    Open

            }else{
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      if(mysql_num_rows($result)!=0){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after ELSE keyword; 0 found
    Open

    }else{
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 4
    Open

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

    Expected 1 space after closing parenthesis; found 0
    Open

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

    Line indented incorrectly; expected 4 spaces, found 0
    Open

    }
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 4
    Open

        }
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

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

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

        echo "
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

        if($result){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after IF keyword; 0 found
    Open

          if($result){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected at least 12 spaces, found 10
    Open

              $sessionStatus = $row['status'];
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 6
    Open

          }
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 4
    Open

        }
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

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

    Expected 1 space after closing parenthesis; found 0
    Open

          if($result){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

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

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

      if(mysql_num_rows($result)!=0){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 6
    Open

          if($result){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after WHILE keyword; 0 found
    Open

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

    Line indented incorrectly; expected 8 spaces, found 4
    Open

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

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

      }
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

      echo "</table></div></div><hr>";
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Closing brace indented incorrectly; expected 6 spaces, found 0
    Open

    }
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

          $name = $row['name'];
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 4
    Open

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

    Expected 1 space after closing parenthesis; found 0
    Open

            if($attended == 1){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after IF keyword; 0 found
    Open

      if(mysql_num_rows($result)!=0){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after WHILE keyword; 0 found
    Open

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

    Closing brace must be on a line by itself
    Open

    echo("</table></div>");}}
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

      $sql = "SELECT COUNT(*) AS num_missed
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after IF keyword; 0 found
    Open

        if($result){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

      echo"
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after IF keyword; 0 found
    Open

        if($sessionStatus == 'Pledge'){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

        if($sessionStatus == 'Pledge'){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 4
    Open

        }
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

      $result = mysql_query($sql);
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after WHILE keyword; 0 found
    Open

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

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

      $sql = "SELECT committee_attendance.committee_id AS comm_id,
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Space before opening parenthesis of function call prohibited
    Open

    require_once ('mysql_access.php');
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

      $sql = "SELECT status AS status FROM contact_information WHERE id = '".$_SESSION['sessionID']."'";
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after WHILE keyword; 0 found
    Open

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

    Line indented incorrectly; expected 4 spaces, found 0
    Open

    function list_attendance_stats($user_id){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after WHILE keyword; 0 found
    Open

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

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

      $result = mysql_query($sql);
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 6
    Open

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

    Expected 1 space after WHILE keyword; 0 found
    Open

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

    Expected 1 space after closing parenthesis; found 0
    Open

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

    Line indented incorrectly; expected at least 12 spaces, found 10
    Open

              $attended = "yes";
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

      $result = mysql_query($sql);
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 6
    Open

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

    Opening brace should be on a new line
    Open

    function list_attendance_stats($user_id){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

      $result = mysql_query($sql);
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after closing brace; 0 found
    Open

            }else{
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

          $position_id = $row['position_id'];
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 0
    Open

    }
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

      $sql = "SELECT COUNT(id) AS committee_count FROM committee_attendance WHERE id = ".$user_id." AND attended = 1";
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after IF keyword; 0 found
    Open

        if($committee_count > 0){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

          echo "<b>Total Committees: {$committee_count}</b>";
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected at least 12 spaces, found 10
    Open

              $attended = "no";
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

          $date = $row['date'];
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Closing brace must be on a line by itself
    Open

    echo("</table></div>");}}
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after closing brace; 0 found
    Open

    }else{
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

      $result = mysql_query($sql);
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 4
    Open

        }
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 4
    Open

        }
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

    echo<<<END
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

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

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

    echo("</table></div>");}}
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

      $sql = "SELECT COUNT(*) AS num_missed
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 4
    Open

        if($committee_count > 0){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

      $sql = "SELECT occurrence.e_id AS e_id, occurrence.id AS id, occurrence.date AS date,
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after IF keyword; 0 found
    Open

            if($attended == 1){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected at least 12 spaces, found 0
    Open

    echo "
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 4
    Open

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

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

          $committee_count = $row['committee_count'];
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    Expected 1 space after closing parenthesis; found 0
    Open

        if($committee_count > 0){
    Severity: Minor
    Found in attendance.php by phpcodesniffer

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

    echo "    <div class='row'>
    Severity: Minor
    Found in attendance.php by phpcodesniffer

    The variable $num_missed_total is not named in camelCase.
    Open

    function list_attendance_stats($user_id){
    
      $sql = "SELECT
          events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
          FROM occurrence
    Severity: Minor
    Found in attendance.php by phpmd

    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 $committee_count is not named in camelCase.
    Open

    function list_attendance_stats($user_id){
    
      $sql = "SELECT
          events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
          FROM occurrence
    Severity: Minor
    Found in attendance.php by phpmd

    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 $committee_count is not named in camelCase.
    Open

    function list_attendance_stats($user_id){
    
      $sql = "SELECT
          events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
          FROM occurrence
    Severity: Minor
    Found in attendance.php by phpmd

    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 list_attendance_stats($user_id){
    
      $sql = "SELECT
          events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
          FROM occurrence
    Severity: Minor
    Found in attendance.php by phpmd

    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 list_attendance_stats($user_id){
    
      $sql = "SELECT
          events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
          FROM occurrence
    Severity: Minor
    Found in attendance.php by phpmd

    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 $num_missed_total is not named in camelCase.
    Open

    function list_attendance_stats($user_id){
    
      $sql = "SELECT
          events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
          FROM occurrence
    Severity: Minor
    Found in attendance.php by phpmd

    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 list_attendance_stats($user_id){
    
      $sql = "SELECT
          events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
          FROM occurrence
    Severity: Minor
    Found in attendance.php by phpmd

    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 $num_missed is not named in camelCase.
    Open

    function list_attendance_stats($user_id){
    
      $sql = "SELECT
          events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
          FROM occurrence
    Severity: Minor
    Found in attendance.php by phpmd

    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 $committee_count is not named in camelCase.
    Open

    function list_attendance_stats($user_id){
    
      $sql = "SELECT
          events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
          FROM occurrence
    Severity: Minor
    Found in attendance.php by phpmd

    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 $num_missed is not named in camelCase.
    Open

    function list_attendance_stats($user_id){
    
      $sql = "SELECT
          events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
          FROM occurrence
    Severity: Minor
    Found in attendance.php by phpmd

    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 list_attendance_stats($user_id){
    
      $sql = "SELECT
          events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
          FROM occurrence
    Severity: Minor
    Found in attendance.php by phpmd

    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

    There are no issues that match your filters.

    Category
    Status