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
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
- 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
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
- Exclude checks
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
- Read upRead up
- Exclude checks
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'])) {
- Exclude checks
Blank line found at start of control structure Open
}else{
- Exclude checks
Space before opening parenthesis of function call prohibited Open
require_once ('session.php');
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 2 Open
$sql = "SELECT
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$comm_id = $row['comm_id'];
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$position = $row['position'];
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
die("Attendance is not currently recorded for pledges");
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$num_missed = $row['num_missed'];
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$num_missed_total = $row['num_missed'];
- Exclude checks
Expected 1 space after ELSE keyword; 0 found Open
}else{
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
if(mysql_num_rows($result)!=0){
- Exclude checks
Expected 1 space after ELSE keyword; 0 found Open
}else{
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 0 Open
}
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
echo "
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
if($result){
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if($result){
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 10 Open
$sessionStatus = $row['status'];
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 6 Open
}
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
if($result){
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
if(mysql_num_rows($result)!=0){
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 6 Open
if($result){
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Closing brace indented incorrectly; expected 6 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo "</table></div></div><hr>";
- Exclude checks
Closing brace indented incorrectly; expected 6 spaces, found 0 Open
}
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$name = $row['name'];
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
if($attended == 1){
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(mysql_num_rows($result)!=0){
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Closing brace must be on a line by itself Open
echo("</table></div>");}}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 2 Open
$sql = "SELECT COUNT(*) AS num_missed
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if($result){
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 2 Open
echo"
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if($sessionStatus == 'Pledge'){
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
if($sessionStatus == 'Pledge'){
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 2 Open
$result = mysql_query($sql);
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$sql = "SELECT committee_attendance.committee_id AS comm_id,
- Exclude checks
Space before opening parenthesis of function call prohibited Open
require_once ('mysql_access.php');
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$sql = "SELECT status AS status FROM contact_information WHERE id = '".$_SESSION['sessionID']."'";
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 0 Open
function list_attendance_stats($user_id){
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 2 Open
$result = mysql_query($sql);
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 6 Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 10 Open
$attended = "yes";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$result = mysql_query($sql);
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 6 Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Opening brace should be on a new line Open
function list_attendance_stats($user_id){
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 2 Open
$result = mysql_query($sql);
- Exclude checks
Expected 1 space after closing brace; 0 found Open
}else{
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$position_id = $row['position_id'];
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 0 Open
}
- Exclude checks
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";
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if($committee_count > 0){
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
echo "<b>Total Committees: {$committee_count}</b>";
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 10 Open
$attended = "no";
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$date = $row['date'];
- Exclude checks
Closing brace must be on a line by itself Open
echo("</table></div>");}}
- Exclude checks
Expected 1 space after closing brace; 0 found Open
}else{
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 2 Open
$result = mysql_query($sql);
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 0 Open
echo<<<END
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 0 Open
echo("</table></div>");}}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 2 Open
$sql = "SELECT COUNT(*) AS num_missed
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if($committee_count > 0){
- Exclude checks
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,
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if($attended == 1){
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 0 Open
echo "
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
while($row = mysql_fetch_array($result)){
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$committee_count = $row['committee_count'];
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
if($committee_count > 0){
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 0 Open
echo " <div class='row'>
- Exclude checks
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
- 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 $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
- 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 $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
- 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 list_attendance_stats($user_id){
$sql = "SELECT
events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
FROM occurrence
- 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 list_attendance_stats($user_id){
$sql = "SELECT
events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
FROM occurrence
- 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 $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
- 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 list_attendance_stats($user_id){
$sql = "SELECT
events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
FROM occurrence
- 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 $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
- 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 $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
- 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 $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
- 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 list_attendance_stats($user_id){
$sql = "SELECT
events.name AS name, SUM(events.worth) AS sum_worth, events.worth AS worth
FROM occurrence
- 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();
}
}