Showing 1,397 of 1,397 total issues
Method process
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process()
{
// Set headers to allow Cross-origin scripting
$rh = getallheaders();
header('Allow: GET,HEAD,POST,PUT,DELETE,OPTIONS');
- Create a ticketCreate a ticket
Method get_all_free_beds
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function get_all_free_beds($term, $gender, $randomize = FALSE, $banner = FALSE)
{
// Only get free beds
// Join other tables so we can do the other 'assignable' checks
// Make sure everything is online and nothing is reserved
- Create a ticketCreate a ticket
Method execute
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute()
{
$this->data = array();
$query = "SELECT hms_assignment.id, hms_assignment.banner_id, hms_assignment.asu_username, hms_new_application.cell_phone, hms_room.room_number, hms_floor.floor_number, hms_residence_hall.hall_name FROM hms_assignment LEFT JOIN (SELECT username, MAX(term) AS mterm FROM hms_new_application GROUP BY username) AS a ON hms_assignment.asu_username = a.username LEFT JOIN hms_new_application ON a.username = hms_new_application.username AND a.mterm = hms_new_application.term LEFT JOIN hms_bed ON hms_assignment.bed_id = hms_bed.id LEFT JOIN hms_room ON hms_bed.room_id = hms_room.id LEFT JOIN hms_floor ON hms_room.floor_id = hms_floor.id LEFT JOIN hms_residence_hall ON hms_floor.residence_hall_id = hms_residence_hall.id WHERE ( hms_assignment.term = $this->term) ORDER BY hms_residence_hall.id ASC";
- Create a ticketCreate a ticket
Similar blocks of code found in 2 locations. Consider refactoring. Open
if($reg->requiresEndDate()) {
$form->addText('end_date');
if(!is_null($f->getEndDate())) {
$form->setValue('end_date', strftime('%m/%d/%Y', $f->getEndDate()));
}
- Read upRead up
- Create a ticketCreate a ticket
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 105.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if($reg->requiresEditDate()) {
$form->addText('edit_date');
if(!is_null($f->getEditDate())) {
$form->setValue('edit_date', strftime('%m/%d/%Y', $f->getEditDate()));
}
- Read upRead up
- Create a ticketCreate a ticket
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 105.
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
Function parseSwitchStatement
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseSwitchStatement() {
var discriminant, cases, clause, oldInSwitch, defaultFound, marker = markerCreate();
expectKeyword('switch');
- Create a ticketCreate a ticket
Function uint8ToBase64
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function uint8ToBase64 (uint8) {
var i,
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
output = "",
temp, length
- Create a ticketCreate a ticket
Function relative
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.relative = function(from, to) {
from = exports.resolve(from).substr(1);
to = exports.resolve(to).substr(1);
function trim(arr) {
- Create a ticketCreate a ticket
Function scanJSXText
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function scanJSXText(stopChars) {
var ch, str = '', start;
start = index;
while (index < length) {
ch = source[index];
- Create a ticketCreate a ticket
Method execute
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute(CommandContext $context)
{
$requestId = $context->get('requestId');
$errorCmd = CommandFactory::getCommand('LotteryShowDenyRoommateRequest');
- Create a ticketCreate a ticket
Method execute
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !\Current_User::allow('hms', 'assignment_maintenance')) {
throw new PermissionException('You do not have permission to assign students.');
}
- Create a ticketCreate a ticket
Method execute
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute(CommandContext $context)
{
if(!UserStatus::isAdmin() || !\Current_User::allow('hms', 'bed_attributes') ){
throw new PermissionException('You do not have permission to edit beds.');
}
- Create a ticketCreate a ticket
Method setRoommateVar
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function setRoommateVar($roomie, $status, $status_extra=null)
{
$roomLink = $this->getRoommateRoomLink($roomie->getUsername());
if(is_null($roomLink)){
$roomLink = "";
- Create a ticketCreate a ticket
Method execute
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute(CommandContext $context)
{
if(!UserStatus::isAdmin() || !\Current_User::allow('hms', 'view_activity_log')){
throw new PermissionException('You do not have permission to view the activity log.');
}
- Create a ticketCreate a ticket
Method countRemainingApplicationsByClassGender
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function countRemainingApplicationsByClassGender($term, $class, $gender = null)
{
$query = "SELECT count(*) FROM hms_new_application JOIN hms_lottery_application ON hms_new_application.id = hms_lottery_application.id
LEFT OUTER JOIN (SELECT asu_username FROM hms_assignment WHERE hms_assignment.term=$term) as foo ON hms_new_application.username = foo.asu_username
WHERE foo.asu_username IS NULL AND hms_lottery_application.invited_on IS NULL
- Create a ticketCreate a ticket
Method getRoomChangesNeedsApproval
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getRoomChangesNeedsApproval($term, Array $floorList)
{
$db = PdoFactory::getPdoInstance();
$floorPlaceholders = array();
- Create a ticketCreate a ticket
Method getApplicationById
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getApplicationById($id)
{
$application = new HousingApplication();
$db = new \PHPWS_DB('hms_new_application');
$db->addWhere('id', $id);
- Create a ticketCreate a ticket
Method show
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function show()
{
$tpl = array();
$submitCmd = CommandFactory::getCommand('SendLotteryInvites');
- Create a ticketCreate a ticket
Method show
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function show()
{
$tpl = array();
if($this->halls == NULL){
- Create a ticketCreate a ticket
Method getCheckinsOrderedByRoom
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getCheckinsOrderedByRoom($term)
{
$db = PdoFactory::getPdoInstance();
// NB: Must be specific about the columns we want (can't select *) because
- Create a ticketCreate a ticket