PHP 7 fixes and jenkins/sonarqube configs

This commit is contained in:
Timothy Warren 2015-11-12 13:51:31 -05:00
parent 50ee98efa5
commit 7ef0482dec
22 changed files with 437 additions and 149 deletions

View File

@ -1,9 +1,12 @@
language: php language: php
sudo: false
php: php:
- 5.4 - 5.4
- 5.5 - 5.5
- 5.6 - 5.6
- 7.0
- hhvm - hhvm
install: install:

View File

@ -1,4 +1,4 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); <?php //if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View File

@ -1,5 +1,7 @@
<?php <?php
$config = [];
include "config.php"; include "config.php";
$config['base_url'] = (isset($config['base_url'])) ? $config['base_url'] : 'https://todo.timshomepage.net/';
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Content Domain | Content Domain

View File

@ -13,7 +13,7 @@ class Calendar extends MY_Controller {
parent::__construct(); parent::__construct();
$this->load->library('calendar'); $this->load->library('calendar');
$this->load->model('task_model'); $this->load->model('task_model');
} }
/** /**
@ -40,17 +40,12 @@ class Calendar extends MY_Controller {
} }
$_months = array( $_months = array(
01 => 'January', 02 => 'February',
03 => 'March', 04 => 'April',
05 => 'May', 06 => 'June',
07 => 'July', 08 => 'August',
09 => 'September', 10 => 'October',
11 => 'November', 12 => 'December',
1 => 'January', 2 => 'February', 1 => 'January', 2 => 'February',
3 => 'March', 4 => 'April', 3 => 'March', 4 => 'April',
5 => 'May', 6 => 'June', 5 => 'May', 6 => 'June',
7 => 'July', 8 => 'August', 7 => 'July', 8 => 'August',
9 => 'September', 9 => 'September', 10 => 'October',
11 => 'November', 12 => 'December'
); );
$year = (isset($year)) ? $year : date('Y'); $year = (isset($year)) ? $year : date('Y');

View File

@ -179,6 +179,7 @@ class Task extends MY_Controller {
{ {
$task_id = (int) $task_id; $task_id = (int) $task_id;
$data = $this->task_model->get_task_by_id($task_id); $data = $this->task_model->get_task_by_id($task_id);
$data['cat_list'] = $this->task_model->get_category_select($task_id); $data['cat_list'] = $this->task_model->get_category_select($task_id);
$data['pri_list'] = $this->task_model->get_priority_select($task_id); $data['pri_list'] = $this->task_model->get_priority_select($task_id);
$data['stat_list'] = $this->task_model->get_status_select($task_id); $data['stat_list'] = $this->task_model->get_status_select($task_id);

View File

@ -7,8 +7,8 @@
* build_header(), build_footer(), and _headers() methods. * build_header(), build_footer(), and _headers() methods.
*/ */
class Page { class Page {
private static $meta, $head_js, $foot_js, $css, $title, private $meta, $head_js, $foot_js, $css, $title,
$head_tags, $body_id; $head_tags, $body_id;
/** /**
@ -32,7 +32,7 @@ class Page {
$this->body_id = ""; $this->body_id = "";
$this->CI =& get_instance(); $this->CI =& get_instance();
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -48,7 +48,7 @@ class Page {
{ {
$this->CI->output->set_header("Cache-Control: must-revalidate, public"); $this->CI->output->set_header("Cache-Control: must-revalidate, public");
$this->CI->output->set_header("Vary: Accept"); $this->CI->output->set_header("Vary: Accept");
//Predefine charset and mime //Predefine charset and mime
$charset = "UTF-8"; $charset = "UTF-8";
$mime = "text/html"; $mime = "text/html";
@ -59,17 +59,17 @@ class Page {
$this->CI->output->set_header("Content-Type: $mime;charset=$charset"); $this->CI->output->set_header("Content-Type: $mime;charset=$charset");
$this->CI->output->set_header("X-UA-Compatible: chrome=1"); $this->CI->output->set_header("X-UA-Compatible: chrome=1");
$this->CI->output->set_output($doctype_string); $this->CI->output->set_output($doctype_string);
return $this; return $this;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Set Meta * Set Meta
* *
* Sets meta tags, with codeigniter native meta tag helper * Sets meta tags, with codeigniter native meta tag helper
* *
* @param array $meta * @param array $meta
* @return Page * @return Page
*/ */
@ -78,7 +78,7 @@ class Page {
$this->meta .= T1.meta($meta).NL; $this->meta .= T1.meta($meta).NL;
return $this; return $this;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -94,7 +94,7 @@ class Page {
$this->head_js .= $this->script_tag($file, FALSE); $this->head_js .= $this->script_tag($file, FALSE);
return $this; return $this;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -128,7 +128,7 @@ class Page {
$this->foot_js .= $this->script_tag($file, FALSE); $this->foot_js .= $this->script_tag($file, FALSE);
return $this; return $this;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -140,12 +140,12 @@ class Page {
{ {
$title = ($title == "") ? $title = ($title == "") ?
$this->CI->config->item('default_title') : $title; $this->CI->config->item('default_title') : $title;
$this->title = $title; $this->title = $title;
return $this; return $this;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -160,7 +160,7 @@ class Page {
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Sets custom page header * Sets custom page header
* @return $this * @return $this
@ -199,10 +199,10 @@ class Page {
//Output Header //Output Header
$this->CI->load->view('header', $data); $this->CI->load->view('header', $data);
return $this; return $this;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -233,9 +233,9 @@ class Page {
$this->CI->load->view('footer', $data); $this->CI->load->view('footer', $data);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Script Tag * Script Tag
* *
@ -261,21 +261,21 @@ class Page {
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Num Queries * Num Queries
* *
* Returns number of queries run on a page * Returns number of queries run on a page
* *
* @return int * @return int
*/ */
public function num_queries() public function num_queries()
{ {
return (isset($this->CI->db)) ? count($this->CI->db->queries) : 0; return (isset($this->CI->db)) ? count($this->CI->db->queries) : 0;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Set Message * Set Message
* *

View File

@ -1,10 +0,0 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@ -5,16 +5,6 @@
*/ */
class Friend_model extends CI_Model { class Friend_model extends CI_Model {
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
}
// --------------------------------------------------------------------------
/** /**
* Get Friends * Get Friends
* *

View File

@ -186,14 +186,9 @@ class Task_model extends CI_Model {
->where('user_id', $uid) ->where('user_id', $uid)
->delete('item_comments'); ->delete('item_comments');
if($this->db->affected_rows() > 0) return ($this->db->affected_rows() > 0)
{ ? $this->db->affected_rows()
return $this->db->affected_rows(); : -1;
}
else
{
return -1;
}
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -317,7 +312,7 @@ class Task_model extends CI_Model {
$result_array[$i] = $row; $result_array[$i] = $row;
// Overdue is set as false to cut down on visual noise. // Overdue is set as false to cut down on visual noise.
// Since every task in the list is overdue, using the // Since every task in the list is overdue, using the
// visual style is redundant // visual style is redundant
$result_array[$i]['overdue'] = FALSE; $result_array[$i]['overdue'] = FALSE;
$i++; $i++;
@ -616,12 +611,12 @@ class Task_model extends CI_Model {
*/ */
public function update_task() public function update_task()
{ {
$title = $this->title; $title = $this->input->post('title');;
$desc = str_replace('<br>', '<br />', $this->description); $desc = str_replace('<br>', '<br />', $this->input->post('desc'));
$category = $this->category; $category = $this->input->post('category');
$priority = $this->priority; $priority = $this->input->post('priority');
$status = $this->status; $status = $this->input->post('status');
$due = $this->due; $due = $this->input->post('due');
$uid = $this->user_id; $uid = $this->user_id;
$task_id = $this->task_id; $task_id = $this->task_id;
@ -1161,17 +1156,7 @@ class Task_model extends CI_Model {
//Check if the user has permission //Check if the user has permission
if($admin === TRUE) if($admin === TRUE || $user_admin === TRUE || $group_admin === TRUE)
{
$this->_remove_task($task_id);
return;
}
else if($user_admin === TRUE)
{
$this->_remove_task($task_id);
return;
}
else if($group_admin === TRUE)
{ {
$this->_remove_task($task_id); $this->_remove_task($task_id);
return; return;

View File

@ -3,7 +3,7 @@
<?php $group_id = $this->uri->segment('3'); ?> <?php $group_id = $this->uri->segment('3'); ?>
<section class="right"> <section class="right">
<h1>Manage Group</h1> <h1>Manage Group</h1>
<form action="<?= site_url("group/manage") .'/'. $group_id ?>" method="post"> <?= form_open("group/manage/" . (int)$group_id) ?>
<fieldset> <fieldset>
<legend>Group Members</legend> <legend>Group Members</legend>
<dl> <dl>

View File

@ -35,16 +35,16 @@
<input type="text" name="due" id="due" value="<?= date('Y-m-d', $due) ?>" placeholder="YYYY-MM-DD" size="10" /> <input type="text" name="due" id="due" value="<?= date('Y-m-d', $due) ?>" placeholder="YYYY-MM-DD" size="10" />
<label>Hour: <label>Hour:
<select name="due_hour"> <select name="due_hour">
<option value="00"<?= (date('H', $due) == 00) ? ' selected="selected"' : "" ?>>Midnight</option> <option value="00"<?= (date('H', $due) == 0) ? ' selected="selected"' : "" ?>>Midnight</option>
<option value="01"<?= (date('H', $due) == 01) ? ' selected="selected"' : "" ?>>1 AM</option> <option value="01"<?= (date('H', $due) == 1) ? ' selected="selected"' : "" ?>>1 AM</option>
<option value="02"<?= (date('H', $due) == 02) ? ' selected="selected"' : "" ?>>2 AM</option> <option value="02"<?= (date('H', $due) == 2) ? ' selected="selected"' : "" ?>>2 AM</option>
<option value="03"<?= (date('H', $due) == 03) ? ' selected="selected"' : "" ?>>3 AM</option> <option value="03"<?= (date('H', $due) == 3) ? ' selected="selected"' : "" ?>>3 AM</option>
<option value="04"<?= (date('H', $due) == 04) ? ' selected="selected"' : "" ?>>4 AM</option> <option value="04"<?= (date('H', $due) == 4) ? ' selected="selected"' : "" ?>>4 AM</option>
<option value="05"<?= (date('H', $due) == 05) ? ' selected="selected"' : "" ?>>5 AM</option> <option value="05"<?= (date('H', $due) == 5) ? ' selected="selected"' : "" ?>>5 AM</option>
<option value="06"<?= (date('H', $due) == 06) ? ' selected="selected"' : "" ?>>6 AM</option> <option value="06"<?= (date('H', $due) == 6) ? ' selected="selected"' : "" ?>>6 AM</option>
<option value="07"<?= (date('H', $due) == 07) ? ' selected="selected"' : "" ?>>7 AM</option> <option value="07"<?= (date('H', $due) == 7) ? ' selected="selected"' : "" ?>>7 AM</option>
<option value="08"<?= (date('H', $due) == 08) ? ' selected="selected"' : "" ?>>8 AM</option> <option value="08"<?= (date('H', $due) == 8) ? ' selected="selected"' : "" ?>>8 AM</option>
<option value="09"<?= (date('H', $due) == 09) ? ' selected="selected"' : "" ?>>9 AM</option> <option value="09"<?= (date('H', $due) == 9) ? ' selected="selected"' : "" ?>>9 AM</option>
<option value="10"<?= (date('H', $due) == 10) ? ' selected="selected"' : "" ?>>10 AM</option> <option value="10"<?= (date('H', $due) == 10) ? ' selected="selected"' : "" ?>>10 AM</option>
<option value="11"<?= (date('H', $due) == 11) ? ' selected="selected"' : "" ?>>11 AM</option> <option value="11"<?= (date('H', $due) == 11) ? ' selected="selected"' : "" ?>>11 AM</option>
<option value="12"<?= (date('H', $due) == 12) ? ' selected="selected"' : "" ?>>12 Noon</option> <option value="12"<?= (date('H', $due) == 12) ? ' selected="selected"' : "" ?>>12 Noon</option>

View File

@ -4,19 +4,19 @@
<?php if($user_perms == PERM_ADMIN_ACCESS): ?> <?php if($user_perms == PERM_ADMIN_ACCESS): ?>
<p id="delTask"><a href="#" onclick="if(confirm('Are you sure you want to delete this task')){window.location='<?= site_url('task/delete').'/'.$this->security->xss_clean($this->uri->segment('3')) ?>'}">Delete Task</a></p> <p id="delTask"><a href="#" onclick="if(confirm('Are you sure you want to delete this task')){window.location='<?= site_url('task/delete').'/'.$this->security->xss_clean($this->uri->segment('3')) ?>'}">Delete Task</a></p>
<?php endif ?> <?php endif ?>
<?= form_open('task/edit' . '/' . $this->uri->segment(3)); ?> <?= form_open('task/edit' . '/' . (int)$this->uri->segment(3)); ?>
<fieldset> <fieldset>
<legend>Task</legend> <legend>Task</legend>
<dl> <dl>
<dt><label for="title">Title</label></dt> <dt><label for="title">Title</label></dt>
<dd> <dd>
<input type="text" name="title" id="title" value="<?= set_value('title') ?>" placeholder="Task Heading" /> <input type="text" name="title" id="title" value="<?= $title ?>" placeholder="Task Heading" />
</dd> </dd>
<dt><label for="desc">Description</label></dt> <dt><label for="desc">Description</label></dt>
<dd> <dd>
<textarea rows="10" cols="80" name="desc" id="desc" placeholder="Task details"><?= set_value('description') ?></textarea> <textarea rows="10" cols="80" name="desc" id="desc" placeholder="Task details"><?= $description ?></textarea>
</dd> </dd>
<dt><label for="category">Category</label></dt> <dt><label for="category">Category</label></dt>
@ -32,7 +32,7 @@
<?= $pri_list ?> <?= $pri_list ?>
</select> </select>
</dd> </dd>
<dt><label for="status">Status</label></dt> <dt><label for="status">Status</label></dt>
<dd> <dd>
<select name="status" id="status"> <select name="status" id="status">
@ -45,16 +45,16 @@
<input type="text" name="due" id="due" value="<?= ($due != 0) ? date('Y-m-d', $due) : 0 ?>" placeholder="YYYY-MM-DD" size="10" /> <input type="text" name="due" id="due" value="<?= ($due != 0) ? date('Y-m-d', $due) : 0 ?>" placeholder="YYYY-MM-DD" size="10" />
<label>Hour: <label>Hour:
<select name="due_hour"> <select name="due_hour">
<option value="00"<?= (date('H', $due) == 00) ? ' selected="selected"' : "" ?>>Midnight</option> <option value="00"<?= (date('H', $due) == 0) ? ' selected="selected"' : "" ?>>Midnight</option>
<option value="01"<?= (date('H', $due) == 01) ? ' selected="selected"' : "" ?>>1 AM</option> <option value="01"<?= (date('H', $due) == 1) ? ' selected="selected"' : "" ?>>1 AM</option>
<option value="02"<?= (date('H', $due) == 02) ? ' selected="selected"' : "" ?>>2 AM</option> <option value="02"<?= (date('H', $due) == 2) ? ' selected="selected"' : "" ?>>2 AM</option>
<option value="03"<?= (date('H', $due) == 03) ? ' selected="selected"' : "" ?>>3 AM</option> <option value="03"<?= (date('H', $due) == 3) ? ' selected="selected"' : "" ?>>3 AM</option>
<option value="04"<?= (date('H', $due) == 04) ? ' selected="selected"' : "" ?>>4 AM</option> <option value="04"<?= (date('H', $due) == 4) ? ' selected="selected"' : "" ?>>4 AM</option>
<option value="05"<?= (date('H', $due) == 05) ? ' selected="selected"' : "" ?>>5 AM</option> <option value="05"<?= (date('H', $due) == 5) ? ' selected="selected"' : "" ?>>5 AM</option>
<option value="06"<?= (date('H', $due) == 06) ? ' selected="selected"' : "" ?>>6 AM</option> <option value="06"<?= (date('H', $due) == 6) ? ' selected="selected"' : "" ?>>6 AM</option>
<option value="07"<?= (date('H', $due) == 07) ? ' selected="selected"' : "" ?>>7 AM</option> <option value="07"<?= (date('H', $due) == 7) ? ' selected="selected"' : "" ?>>7 AM</option>
<option value="08"<?= (date('H', $due) == 08) ? ' selected="selected"' : "" ?>>8 AM</option> <option value="08"<?= (date('H', $due) == 8) ? ' selected="selected"' : "" ?>>8 AM</option>
<option value="09"<?= (date('H', $due) == 09) ? ' selected="selected"' : "" ?>>9 AM</option> <option value="09"<?= (date('H', $due) == 9) ? ' selected="selected"' : "" ?>>9 AM</option>
<option value="10"<?= (date('H', $due) == 10) ? ' selected="selected"' : "" ?>>10 AM</option> <option value="10"<?= (date('H', $due) == 10) ? ' selected="selected"' : "" ?>>10 AM</option>
<option value="11"<?= (date('H', $due) == 11) ? ' selected="selected"' : "" ?>>11 AM</option> <option value="11"<?= (date('H', $due) == 11) ? ' selected="selected"' : "" ?>>11 AM</option>
<option value="12"<?= (date('H', $due) == 12) ? ' selected="selected"' : "" ?>>12 Noon</option> <option value="12"<?= (date('H', $due) == 12) ? ' selected="selected"' : "" ?>>12 Noon</option>
@ -188,7 +188,8 @@
<dt><label for="check_desc">Checklist item:</label></dt> <dt><label for="check_desc">Checklist item:</label></dt>
<dd> <dd>
<input type="text" size="10" name="check_desc" id="check_desc" />&nbsp;&nbsp; <input type="text" size="10" name="check_desc" id="check_desc" />&nbsp;&nbsp;
<input type="button" name="add_checklist_item" id="add_checklist_item" value="Add Checklist Item" /> <button name="add_checklist_item" id="add_checklist_item">Add Checklist Item</button>
<?php /*<input type="button" name="add_checklist_item" id="add_checklist_item" value="Add Checklist Item" /> */ ?>
</dd> </dd>
</dl> </dl>
<?php $this->load->view('task/checklist_view'); ?> <?php $this->load->view('task/checklist_view'); ?>
@ -202,7 +203,8 @@
<dd> <dd>
<textarea rows="10" cols="80" name="comment" id="comment"></textarea> <textarea rows="10" cols="80" name="comment" id="comment"></textarea>
<br /> <br />
<input type="button" name="add_task_comment" id="add_task_comment" value="Submit comment" /> <button name="add_task_comment" id="add_task_comment">Submit Comment</button>
<?php /*<input type="button" name="add_task_comment" id="add_task_comment" value="Submit comment" />*/ ?>
</dd> </dd>
</dl> </dl>
<?php $this->load->view('task/comments_view'); ?> <?php $this->load->view('task/comments_view'); ?>

268
build.xml Normal file
View File

@ -0,0 +1,268 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="animeclient" default="full-build">
<!-- By default, we assume all tools to be on the $PATH -->
<property name="pdepend" value="pdepend"/>
<property name="phpcpd" value="phpcpd"/>
<property name="phpcs" value="phpcs"/>
<property name="phploc" value="phploc"/>
<property name="phpmd" value="phpmd"/>
<property name="phpunit" value="phpunit"/>
<property name="sonar" value="sonar-runner"/>
<!-- Use this when the tools are located as PHARs in build/tools
<property name="pdepend" value="build/tools/pdepend.phar"/>
<property name="phpcpd" value="build/tools/phpcpd.phar"/>
<property name="phpcs" value="build/tools/phpcs.phar"/>
<property name="phpdox" value="build/tools/phpdox.phar"/>
<property name="phploc" value="build/tools/phploc.phar"/>
<property name="phpmd" value="build/tools/phpmd.phar"/>
<property name="phpunit" value="build/tools/phpunit.phar"/> -->
<!-- Use this when the tools are managed by Composer in vendor/bin
<property name="pdepend" value="vendor/bin/pdepend"/>
<property name="phpcpd" value="vendor/bin/phpcpd"/>
<property name="phpcs" value="vendor/bin/phpcs"/>
<property name="phpdox" value="vendor/bin/phpdox"/>
<property name="phploc" value="vendor/bin/phploc"/>
<property name="phpmd" value="vendor/bin/phpmd"/>
<property name="phpunit" value="vendor/bin/phpunit"/> -->
<target name="full-build"
depends="prepare,static-analysis,phpunit,sonar,-check-failure"
description="Performs static analysis, runs the tests, and generates project documentation"/>
<target name="full-build-parallel"
depends="prepare,static-analysis-parallel,phpunit, -check-failure"
description="Performs static analysis (executing the tools in parallel), runs the tests, and generates project documentation"/>
<target name="quick-build"
depends="prepare,lint,phpunit-no-coverage"
description="Performs a lint check and runs the tests (without generating code coverage reports)"/>
<target name="static-analysis"
depends="lint,phploc-ci,pdepend,phpcs-ci,phpcpd-ci"
description="Performs static analysis" />
<!-- Adjust the threadCount attribute's value to the number of CPUs -->
<target name="static-analysis-parallel"
description="Performs static analysis (executing the tools in parallel)">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend"/>
</sequential>
<antcall target="lint"/>
<antcall target="phpcpd-ci"/>
<antcall target="phpcs-ci"/>
<antcall target="phploc-ci"/>
</parallel>
</target>
<target name="clean"
unless="clean.done"
description="Cleanup build artifacts">
<delete dir="build/api"/>
<delete dir="build/coverage"/>
<delete dir="build/logs"/>
<delete dir="build/pdepend"/>
<property name="clean.done" value="true"/>
</target>
<target name="prepare"
unless="prepare.done"
depends="clean"
description="Prepare for build">
<mkdir dir="build/api"/>
<mkdir dir="build/coverage"/>
<mkdir dir="build/logs"/>
<mkdir dir="build/pdepend"/>
<property name="prepare.done" value="true"/>
</target>
<target name="lint"
unless="lint.done"
description="Perform syntax check of sourcecode files">
<apply executable="php" taskname="lint">
<arg value="-l" />
<fileset dir="application">
<include name="**/*.php" />
<exclude name="logs/*.php" />
<exclude name="config/**/*.php" />
<exclude name="errors/*.php" />
<exclude name="third_party/**/*.php" />
<exclude name="views/**/*.php" />
<modified />
</fileset>
<fileset dir="tests">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
<property name="lint.done" value="true"/>
</target>
<target name="phploc"
unless="phploc.done"
description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
<exec executable="${phploc}" taskname="phploc">
<arg value="--count-tests" />
<arg path="application/controllers" />
<arg path="application/models" />
<arg path="application/libraries" />
<arg path="application/core" />
<arg path="application/hooks" />
<arg path="tests" />
</exec>
<property name="phploc.done" value="true"/>
</target>
<target name="phploc-ci"
unless="phploc.done"
depends="prepare"
description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment.">
<exec executable="${phploc}" taskname="phploc">
<arg value="--count-tests" />
<arg value="--log-csv" />
<arg path="build/logs/phploc.csv" />
<arg value="--log-xml" />
<arg path="build/logs/phploc.xml" />
<arg path="application/controllers" />
<arg path="application/models" />
<arg path="application/libraries" />
<arg path="application/core" />
<arg path="application/hooks" />
<arg path="tests" />
</exec>
<property name="phploc.done" value="true"/>
</target>
<target name="pdepend"
unless="pdepend.done"
depends="prepare"
description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${pdepend}" taskname="pdepend">
<arg value="--jdepend-xml=build/logs/jdepend.xml" />
<arg value="--jdepend-chart=build/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=build/pdepend/overview-pyramid.svg" />
<arg path="application" />
</exec>
<property name="pdepend.done" value="true"/>
</target>
<target name="phpcs"
unless="phpcs.done"
description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${phpcs}" taskname="phpcs">
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg value="--ignore=autoload.php" />
<arg path="application/controllers" />
<arg path="application/models" />
<arg path="application/libraries" />
<arg path="application/core" />
<arg path="application/hooks" />
<arg path="tests" />
</exec>
<property name="phpcs.done" value="true"/>
</target>
<target name="phpcs-ci"
unless="phpcs.done"
depends="prepare"
description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${phpcs}" output="/dev/null" taskname="phpcs">
<arg value="--report=checkstyle" />
<arg value="--report-file=build/logs/checkstyle.xml" />
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg value="--ignore=autoload.php" />
<arg path="application/controllers" />
<arg path="application/models" />
<arg path="application/libraries" />
<arg path="application/core" />
<arg path="application/hooks" />
<arg path="tests" />
</exec>
<property name="phpcs.done" value="true"/>
</target>
<target name="phpcpd"
unless="phpcpd.done"
description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${phpcpd}" taskname="phpcpd">
<arg path="application/controllers" />
<arg path="application/models" />
<arg path="application/libraries" />
<arg path="application/core" />
<arg path="application/hooks" />
</exec>
<property name="phpcpd.done" value="true"/>
</target>
<target name="phpcpd-ci"
unless="phpcpd.done"
depends="prepare"
description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${phpcpd}" taskname="phpcpd">
<arg value="--log-pmd" />
<arg path="build/logs/pmd-cpd.xml" />
<arg path="application/controllers" />
<arg path="application/models" />
<arg path="application/libraries" />
<arg path="application/core" />
<arg path="application/hooks" />
</exec>
<property name="phpcpd.done" value="true"/>
</target>
<target name="phpunit"
unless="phpunit.done"
depends="prepare"
description="Run unit tests with PHPUnit">
<exec executable="${phpunit}" resultproperty="result.phpunit" taskname="phpunit">
<arg value="--configuration"/>
<arg path="build/phpunit.xml"/>
</exec>
<property name="phpunit.done" value="true"/>
</target>
<target name="phpunit-no-coverage"
unless="phpunit.done"
depends="prepare"
description="Run unit tests with PHPUnit (without generating code coverage reports)">
<exec executable="${phpunit}" failonerror="true" taskname="phpunit">
<arg value="--configuration"/>
<arg path="build/phpunit.xml"/>
<arg value="--no-coverage"/>
</exec>
<property name="phpunit.done" value="true"/>
</target>
<target name="sonar"
depends="phpunit">
<exec executable="${sonar}" taskname="sonar"/>
<property name="sonar.done" value="true"/>
</target>
<target name="-check-failure">
<fail message="PHPUnit did not finish successfully">
<condition>
<not>
<equals arg1="${result.phpunit}" arg2="0"/>
</not>
</condition>
</fail>
</target>
</project>

48
build/phpunit.xml Normal file
View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
stopOnFailure="false"
bootstrap="../tests/bootstrap.php">
<php>
<server name="SERVER_NAME" value="http://example.com" />
<server name="REMOTE_ADDR" value="127.0.0.1" />
<server name="HTTP_USER_AGENT" value="PHPUnit" />
</php>
<filter>
<whitelist>
<directory suffix=".php">../application/controllers</directory>
<directory suffix=".php">../application/core</directory>
<directory suffix=".php">../application/libraries</directory>
<directory suffix=".php">../application/models</directory>
<directory suffix=".php">../application/helpers</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="ControllerTests">
<directory suffix=".php">../tests/controllers</directory>
</testsuite>
<testsuite name="ExtensionTests">
<directory suffix=".php">../tests/core</directory>
</testsuite>
<testsuite name="HelperTests">
<directory suffix=".php">../tests/helpers</directory>
</testsuite>
<testsuite name="LibTests">
<directory suffix=".php">../tests/libs</directory>
</testsuite>
<testsuite name="ModelTests">
<directory suffix=".php">../tests/models</directory>
</testsuite>
<testsuite name="SystemTests">
<directory suffix=".php">../tests/system</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-html" target="coverage"/>
<log type="coverage-clover" target="logs/clover.xml"/>
<log type="coverage-crap4j" target="logs/crap4j.xml"/>
<log type="coverage-xml" target="logs/coverage" />
<log type="junit" target="logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit>

6
sonar-project.properties Normal file
View File

@ -0,0 +1,6 @@
sonar.projectKey=todo
sonar.projectName=Tim's Todo
sonar.projectVersion=1.0
sonar.sources=application/controllers,application/models,application/libraries,application/core,application/hooks
sonar.php.coverage.reportPath=build/logs/clover.xml
sonar.php.tests.reportPath=build/logs/junit.xml

View File

@ -274,7 +274,7 @@ if ( ! function_exists('config_item'))
if ( ! isset($_config_item[$item])) if ( ! isset($_config_item[$item]))
{ {
$config =& get_config(); $config = get_config();
if ( ! isset($config[$item])) if ( ! isset($config[$item]))
{ {
@ -514,16 +514,16 @@ if ( ! function_exists('remove_invisible_characters'))
function remove_invisible_characters($str, $url_encoded = TRUE) function remove_invisible_characters($str, $url_encoded = TRUE)
{ {
$non_displayables = array(); $non_displayables = array();
// every control character except newline (dec 10) // every control character except newline (dec 10)
// carriage return (dec 13), and horizontal tab (dec 09) // carriage return (dec 13), and horizontal tab (dec 09)
if ($url_encoded) if ($url_encoded)
{ {
$non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15 $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15
$non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31 $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31
} }
$non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127 $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
do do

View File

@ -60,7 +60,7 @@ class CI_Config {
*/ */
function __construct() function __construct()
{ {
$this->config =& get_config(); $this->config = get_config();
log_message('debug', "Config Class Initialized"); log_message('debug', "Config Class Initialized");
// Set the base_url automatically if none was provided // Set the base_url automatically if none was provided

View File

@ -78,7 +78,7 @@ class CI_Lang {
return; return;
} }
$config =& get_config(); $config = get_config();
if ($idiom == '') if ($idiom == '')
{ {

View File

@ -37,7 +37,7 @@ class CI_Log {
*/ */
public function __construct() public function __construct()
{ {
$config =& get_config(); $config = get_config();
$this->_log_path = ($config['log_path'] != '') ? $config['log_path'] : APPPATH.'logs/'; $this->_log_path = ($config['log_path'] != '') ? $config['log_path'] : APPPATH.'logs/';

View File

@ -20,15 +20,13 @@ spl_autoload_register(function($class) {
$exact_file = "{$path}{$class}.php"; $exact_file = "{$path}{$class}.php";
$lower_file = $path . mb_strtolower($class) . ".php"; $lower_file = $path . mb_strtolower($class) . ".php";
if (file_exists($lower_file)) foreach([$lower_file, $exact_file] as $file)
{ {
require_once($lower_file); if (file_exists($file))
return; {
} require_once($file);
else if (file_exists($exact_file)) return;
{ }
require_once($exact_file);
return;
} }
} }
}); });

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
colors="true" colors="true"
stopOnFailure="false" stopOnFailure="false"
bootstrap="bootstrap.php"> bootstrap="bootstrap.php">
<php> <php>
<server name="SERVER_NAME" value="http://example.com" /> <server name="SERVER_NAME" value="http://example.com" />
@ -10,13 +10,13 @@
<server name="HTTP_USER_AGENT" value="PHPUnit" /> <server name="HTTP_USER_AGENT" value="PHPUnit" />
</php> </php>
<filter> <filter>
<blacklist> <whitelist>
<directory suffix=".php">../application/third_party</directory> <directory suffix=".php">../application/controllers</directory>
<directory suffix=".php">../application/config</directory> <directory suffix=".php">../application/core</directory>
<directory suffix=".php">../application/views</directory> <directory suffix=".php">../application/libraries</directory>
<directory suffix=".php">../system</directory> <directory suffix=".php">../application/models</directory>
<directory suffix=".php">.</directory> <directory suffix=".php">../application/helpers</directory>
</blacklist> </whitelist>
</filter> </filter>
<testsuites> <testsuites>
<testsuite name="ControllerTests"> <testsuite name="ControllerTests">

View File

@ -175,7 +175,7 @@ section{
input[type="submit"], input[type="button"]{ input[type="submit"], input[type="button"], button{
background:url('/images/bgs/Title.png'); background:url('/images/bgs/Title.png');
color:#fff; color:#fff;
padding:0.5em; padding:0.5em;
@ -601,7 +601,7 @@ select#friends option{
vertical-align:top; vertical-align:top;
display:inline-block; display:inline-block;
} }
header nav{ header nav{
width:80%; width:80%;
} }
@ -609,7 +609,7 @@ select#friends option{
section, footer, nav{ section, footer, nav{
border:0; border:0;
} }
dt{ dt{
text-align:right; text-align:right;
padding-right:0.5em; padding-right:0.5em;
@ -633,7 +633,7 @@ select#friends option{
border-radius:5px; border-radius:5px;
margin-left:0.35%; margin-left:0.35%;
} }
#pagination strong{ #pagination strong{
letter-spacing:.5em; letter-spacing:.5em;
margin-left:.5em; margin-left:.5em;
@ -658,34 +658,34 @@ select#friends option{
vertical-align:top; vertical-align:top;
background:transparent; background:transparent;
} }
.left{ .left{
border-radius:0; border-radius:0;
text-align:left; text-align:left;
width:15%; width:15%;
} }
#home .left{ #home .left{
width:74%; width:74%;
} }
.left form{ .left form{
width:100%; width:100%;
margin:0 auto; margin:0 auto;
} }
.right{ .right{
border-bottom-left-radius:5px; border-bottom-left-radius:5px;
padding-top:0; padding-top:0;
margin-left:.25%; margin-left:.25%;
width:83%; width:83%;
} }
#home .right{ #home .right{
width:22%; width:22%;
} }
dt{ dt{
width:13%; width:13%;
} }
@ -693,25 +693,25 @@ select#friends option{
#left_nav li{ #left_nav li{
display:block; display:block;
} }
fieldset dt, fieldset dd{ fieldset dt, fieldset dd{
display:inline-block; display:inline-block;
vertical-align:top; vertical-align:top;
margin:.5% 0; margin:.5% 0;
} }
strong { strong {
font-weight:bold; font-weight:bold;
} }
#task_view dt, th a{ #task_view dt, th a{
font-weight:bold; font-weight:bold;
} }
.error{ .error{
font-weight:300; font-weight:300;
} }
#task_comment_list dt{ #task_comment_list dt{
width:25%; width:25%;
padding:.5em; padding:.5em;
@ -721,12 +721,12 @@ select#friends option{
width:70%; width:70%;
padding:.5em; padding:.5em;
} }
.immediate, td.immediate, .overdue td{ .immediate, td.immediate, .overdue td{
font-weight:bold; font-weight:bold;
font-style:italic; font-style:italic;
} }
.overdue td{ .overdue td{
font-weight:bold; font-weight:bold;
} }
@ -736,7 +736,7 @@ select#friends option{
vertical-align:top; vertical-align:top;
margin:.5em auto; margin:.5em auto;
} }
#home .right dt, #home .right dd{ #home .right dt, #home .right dd{
width:45%; width:45%;
display:inline-block; display:inline-block;