Browse Source

PHP 7 fixes and jenkins/sonarqube configs

Timothy J. Warren 3 years ago
parent
commit
7ef0482dec

+ 3
- 0
.travis.yml View File

@@ -1,9 +1,12 @@
1 1
 language: php
2 2
 
3
+sudo: false
4
+
3 5
 php:
4 6
   - 5.4
5 7
   - 5.5
6 8
   - 5.6
9
+  - 7.0
7 10
   - hhvm
8 11
 
9 12
 install:

+ 1
- 1
application/config/config.php View File

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

+ 2
- 0
application/config/sites.php View File

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

+ 3
- 8
application/controllers/calendar.php View File

@@ -13,7 +13,7 @@ class Calendar extends MY_Controller {
13 13
 		parent::__construct();
14 14
 		$this->load->library('calendar');
15 15
 		$this->load->model('task_model');
16
-		
16
+
17 17
 	}
18 18
 
19 19
 	/**
@@ -40,17 +40,12 @@ class Calendar extends MY_Controller {
40 40
 		}
41 41
 
42 42
 		$_months = array(
43
-			01 => 'January', 02 => 'February',
44
-			03 => 'March', 04 => 'April',
45
-			05 => 'May', 06 => 'June',
46
-			07 => 'July', 08 => 'August',
47
-			09 => 'September', 10 => 'October',
48
-			11 => 'November', 12 => 'December',
49 43
 			1 => 'January', 2 => 'February',
50 44
 			3 => 'March', 4 => 'April',
51 45
 			5 => 'May', 6 => 'June',
52 46
 			7 => 'July', 8 => 'August',
53
-			9 => 'September',
47
+			9 => 'September', 10 => 'October',
48
+			11 => 'November', 12 => 'December'
54 49
 		);
55 50
 
56 51
 		$year = (isset($year)) ? $year : date('Y');

+ 1
- 0
application/controllers/task.php View File

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

+ 23
- 23
application/libraries/Page.php View File

@@ -7,8 +7,8 @@
7 7
  * build_header(), build_footer(), and _headers() methods.
8 8
  */
9 9
 class Page {
10
-	
11
-	private static $meta, $head_js, $foot_js, $css, $title,
10
+
11
+	private $meta, $head_js, $foot_js, $css, $title,
12 12
 			$head_tags, $body_id;
13 13
 
14 14
 	/**
@@ -32,7 +32,7 @@ class Page {
32 32
 		$this->body_id = "";
33 33
 		$this->CI =& get_instance();
34 34
 	}
35
-	
35
+
36 36
 	// --------------------------------------------------------------------------
37 37
 
38 38
 	/**
@@ -48,7 +48,7 @@ class Page {
48 48
 	{
49 49
 		$this->CI->output->set_header("Cache-Control: must-revalidate, public");
50 50
 		$this->CI->output->set_header("Vary: Accept");
51
-		
51
+
52 52
 		//Predefine charset and mime
53 53
 		$charset = "UTF-8";
54 54
 		$mime = "text/html";
@@ -59,17 +59,17 @@ class Page {
59 59
 		$this->CI->output->set_header("Content-Type: $mime;charset=$charset");
60 60
 		$this->CI->output->set_header("X-UA-Compatible: chrome=1");
61 61
 		$this->CI->output->set_output($doctype_string);
62
-		
62
+
63 63
 		return $this;
64 64
 	}
65
-	
65
+
66 66
 	// --------------------------------------------------------------------------
67 67
 
68 68
 	/**
69 69
 	 * Set Meta
70 70
 	 *
71 71
 	 * Sets meta tags, with codeigniter native meta tag helper
72
-	 * 
72
+	 *
73 73
 	 * @param array $meta
74 74
 	 * @return Page
75 75
 	 */
@@ -78,7 +78,7 @@ class Page {
78 78
 		$this->meta .= T1.meta($meta).NL;
79 79
 		return $this;
80 80
 	}
81
-	
81
+
82 82
 	// --------------------------------------------------------------------------
83 83
 
84 84
 	/**
@@ -94,7 +94,7 @@ class Page {
94 94
 		$this->head_js .= $this->script_tag($file, FALSE);
95 95
 		return $this;
96 96
 	}
97
-	
97
+
98 98
 	// --------------------------------------------------------------------------
99 99
 
100 100
 	/**
@@ -128,7 +128,7 @@ class Page {
128 128
 		$this->foot_js .= $this->script_tag($file, FALSE);
129 129
 		return $this;
130 130
 	}
131
-	
131
+
132 132
 	// --------------------------------------------------------------------------
133 133
 
134 134
 	/**
@@ -140,12 +140,12 @@ class Page {
140 140
 	{
141 141
 		$title = ($title == "") ?
142 142
 			$this->CI->config->item('default_title') : $title;
143
-			
143
+
144 144
 		$this->title = $title;
145
-		
145
+
146 146
 		return $this;
147 147
 	}
148
-	
148
+
149 149
 	// --------------------------------------------------------------------------
150 150
 
151 151
 	/**
@@ -160,7 +160,7 @@ class Page {
160 160
 	}
161 161
 
162 162
 	// --------------------------------------------------------------------------
163
-	
163
+
164 164
 	/**
165 165
 	 * Sets custom page header
166 166
 	 * @return $this
@@ -199,10 +199,10 @@ class Page {
199 199
 
200 200
 		//Output Header
201 201
 		$this->CI->load->view('header', $data);
202
-		
202
+
203 203
 		return $this;
204 204
 	}
205
-	
205
+
206 206
 	// --------------------------------------------------------------------------
207 207
 
208 208
 	/**
@@ -233,9 +233,9 @@ class Page {
233 233
 
234 234
 		$this->CI->load->view('footer', $data);
235 235
 	}
236
-	
236
+
237 237
 	// --------------------------------------------------------------------------
238
-	
238
+
239 239
 	/**
240 240
 	 * Script Tag
241 241
 	 *
@@ -261,21 +261,21 @@ class Page {
261 261
 	}
262 262
 
263 263
 	// --------------------------------------------------------------------------
264
-	
264
+
265 265
 	/**
266 266
 	 * Num Queries
267
-	 * 
267
+	 *
268 268
 	 * Returns number of queries run on a page
269
-	 * 
269
+	 *
270 270
 	 * @return int
271 271
 	 */
272 272
 	public function num_queries()
273 273
 	{
274 274
 		return	(isset($this->CI->db)) ? count($this->CI->db->queries) : 0;
275 275
 	}
276
-	
276
+
277 277
 	// --------------------------------------------------------------------------
278
-	
278
+
279 279
 	/**
280 280
 	 * Set Message
281 281
 	 *

+ 0
- 10
application/logs/index.html View File

@@ -1,10 +0,0 @@
1
-<html>
2
-<head>
3
-	<title>403 Forbidden</title>
4
-</head>
5
-<body>
6
-
7
-<p>Directory access is forbidden.</p>
8
-
9
-</body>
10
-</html>

+ 0
- 10
application/models/friend_model.php View File

@@ -5,16 +5,6 @@
5 5
  */
6 6
 class Friend_model extends CI_Model {
7 7
 
8
-	/**
9
-	 * Constructor
10
-	 */
11
-	public function __construct()
12
-	{
13
-		parent::__construct();
14
-	}
15
-
16
-	// --------------------------------------------------------------------------
17
-
18 8
 	/**
19 9
 	 * Get Friends
20 10
 	 *

+ 11
- 26
application/models/task_model.php View File

@@ -186,14 +186,9 @@ class Task_model extends CI_Model {
186 186
 			->where('user_id', $uid)
187 187
 			->delete('item_comments');
188 188
 
189
-		if($this->db->affected_rows() > 0)
190
-		{
191
-			return $this->db->affected_rows();
192
-		}
193
-		else
194
-		{
195
-			return -1;
196
-		}
189
+		return ($this->db->affected_rows() > 0)
190
+			? $this->db->affected_rows()
191
+			: -1;
197 192
 	}
198 193
 
199 194
 	// --------------------------------------------------------------------------
@@ -317,7 +312,7 @@ class Task_model extends CI_Model {
317 312
 			$result_array[$i] = $row;
318 313
 
319 314
 			// Overdue is set as false to cut down on visual noise.
320
-			// Since every task in the list is overdue, using the 
315
+			// Since every task in the list is overdue, using the
321 316
 			// visual style is redundant
322 317
 			$result_array[$i]['overdue'] = FALSE;
323 318
 			$i++;
@@ -616,12 +611,12 @@ class Task_model extends CI_Model {
616 611
 	 */
617 612
 	public function update_task()
618 613
 	{
619
-		$title = $this->title;
620
-		$desc = str_replace('<br>', '<br />', $this->description);
621
-		$category = $this->category;
622
-		$priority = $this->priority;
623
-		$status = $this->status;
624
-		$due = $this->due;
614
+		$title = $this->input->post('title');;
615
+		$desc = str_replace('<br>', '<br />', $this->input->post('desc'));
616
+		$category = $this->input->post('category');
617
+		$priority = $this->input->post('priority');
618
+		$status = $this->input->post('status');
619
+		$due = $this->input->post('due');
625 620
 		$uid = $this->user_id;
626 621
 		$task_id = $this->task_id;
627 622
 
@@ -1161,17 +1156,7 @@ class Task_model extends CI_Model {
1161 1156
 
1162 1157
 
1163 1158
 		//Check if the user has permission
1164
-		if($admin === TRUE)
1165
-		{
1166
-			$this->_remove_task($task_id);
1167
-			return;
1168
-		}
1169
-		else if($user_admin === TRUE)
1170
-		{
1171
-			$this->_remove_task($task_id);
1172
-			return;
1173
-		}
1174
-		else if($group_admin === TRUE)
1159
+		if($admin === TRUE || $user_admin === TRUE || $group_admin === TRUE)
1175 1160
 		{
1176 1161
 			$this->_remove_task($task_id);
1177 1162
 			return;

+ 1
- 1
application/views/friend/manage.php View File

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

+ 10
- 10
application/views/task/add.php View File

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

+ 18
- 16
application/views/task/edit.php View File

@@ -4,19 +4,19 @@
4 4
 	<?php if($user_perms == PERM_ADMIN_ACCESS): ?>
5 5
 	<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>
6 6
 	<?php endif ?>
7
-	<?= form_open('task/edit' . '/' . $this->uri->segment(3)); ?>
7
+	<?= form_open('task/edit' . '/' . (int)$this->uri->segment(3)); ?>
8 8
 
9 9
 	<fieldset>
10 10
 			<legend>Task</legend>
11 11
 			<dl>
12 12
 				<dt><label for="title">Title</label></dt>
13 13
 				<dd>
14
-					<input type="text" name="title" id="title" value="<?= set_value('title') ?>" placeholder="Task Heading" />
14
+					<input type="text" name="title" id="title" value="<?= $title ?>" placeholder="Task Heading" />
15 15
 				</dd>
16 16
 
17 17
 				<dt><label for="desc">Description</label></dt>
18 18
 				<dd>
19
-					<textarea rows="10" cols="80" name="desc" id="desc" placeholder="Task details"><?= set_value('description') ?></textarea>
19
+					<textarea rows="10" cols="80" name="desc" id="desc" placeholder="Task details"><?= $description ?></textarea>
20 20
 				</dd>
21 21
 
22 22
 				<dt><label for="category">Category</label></dt>
@@ -32,7 +32,7 @@
32 32
 						<?= $pri_list ?>
33 33
 					</select>
34 34
 				</dd>
35
-				
35
+
36 36
 				<dt><label for="status">Status</label></dt>
37 37
 				<dd>
38 38
 					<select name="status" id="status">
@@ -45,16 +45,16 @@
45 45
 					<input type="text" name="due" id="due" value="<?= ($due != 0) ? date('Y-m-d', $due) : 0 ?>" placeholder="YYYY-MM-DD" size="10" />
46 46
 					<label>Hour:
47 47
 						<select name="due_hour">
48
-							<option value="00"<?= (date('H', $due) == 00) ? ' selected="selected"' : "" ?>>Midnight</option>
49
-							<option value="01"<?= (date('H', $due) == 01) ? ' selected="selected"' : "" ?>>1 AM</option>
50
-							<option value="02"<?= (date('H', $due) == 02) ? ' selected="selected"' : "" ?>>2 AM</option>
51
-							<option value="03"<?= (date('H', $due) == 03) ? ' selected="selected"' : "" ?>>3 AM</option>
52
-							<option value="04"<?= (date('H', $due) == 04) ? ' selected="selected"' : "" ?>>4 AM</option>
53
-							<option value="05"<?= (date('H', $due) == 05) ? ' selected="selected"' : "" ?>>5 AM</option>
54
-							<option value="06"<?= (date('H', $due) == 06) ? ' selected="selected"' : "" ?>>6 AM</option>
55
-							<option value="07"<?= (date('H', $due) == 07) ? ' selected="selected"' : "" ?>>7 AM</option>
56
-							<option value="08"<?= (date('H', $due) == 08) ? ' selected="selected"' : "" ?>>8 AM</option>
57
-							<option value="09"<?= (date('H', $due) == 09) ? ' selected="selected"' : "" ?>>9 AM</option>
48
+							<option value="00"<?= (date('H', $due) == 0) ? ' selected="selected"' : "" ?>>Midnight</option>
49
+							<option value="01"<?= (date('H', $due) == 1) ? ' selected="selected"' : "" ?>>1 AM</option>
50
+							<option value="02"<?= (date('H', $due) == 2) ? ' selected="selected"' : "" ?>>2 AM</option>
51
+							<option value="03"<?= (date('H', $due) == 3) ? ' selected="selected"' : "" ?>>3 AM</option>
52
+							<option value="04"<?= (date('H', $due) == 4) ? ' selected="selected"' : "" ?>>4 AM</option>
53
+							<option value="05"<?= (date('H', $due) == 5) ? ' selected="selected"' : "" ?>>5 AM</option>
54
+							<option value="06"<?= (date('H', $due) == 6) ? ' selected="selected"' : "" ?>>6 AM</option>
55
+							<option value="07"<?= (date('H', $due) == 7) ? ' selected="selected"' : "" ?>>7 AM</option>
56
+							<option value="08"<?= (date('H', $due) == 8) ? ' selected="selected"' : "" ?>>8 AM</option>
57
+							<option value="09"<?= (date('H', $due) == 9) ? ' selected="selected"' : "" ?>>9 AM</option>
58 58
 							<option value="10"<?= (date('H', $due) == 10) ? ' selected="selected"' : "" ?>>10 AM</option>
59 59
 							<option value="11"<?= (date('H', $due) == 11) ? ' selected="selected"' : "" ?>>11 AM</option>
60 60
 							<option value="12"<?= (date('H', $due) == 12) ? ' selected="selected"' : "" ?>>12 Noon</option>
@@ -188,7 +188,8 @@
188 188
 				<dt><label for="check_desc">Checklist item:</label></dt>
189 189
 				<dd>
190 190
 					<input type="text" size="10" name="check_desc" id="check_desc" />&nbsp;&nbsp;
191
-					<input type="button" name="add_checklist_item" id="add_checklist_item" value="Add Checklist Item" />
191
+					<button name="add_checklist_item" id="add_checklist_item">Add Checklist Item</button>
192
+					<?php /*<input type="button" name="add_checklist_item" id="add_checklist_item" value="Add Checklist Item" /> */ ?>
192 193
 				</dd>
193 194
 			</dl>
194 195
 			<?php $this->load->view('task/checklist_view'); ?>
@@ -202,7 +203,8 @@
202 203
 				<dd>
203 204
 					<textarea rows="10" cols="80" name="comment" id="comment"></textarea>
204 205
 					<br />
205
-					<input type="button" name="add_task_comment" id="add_task_comment" value="Submit comment" />
206
+					<button name="add_task_comment" id="add_task_comment">Submit Comment</button>
207
+					<?php /*<input type="button" name="add_task_comment" id="add_task_comment" value="Submit comment" />*/ ?>
206 208
 				</dd>
207 209
 			</dl>
208 210
 			<?php $this->load->view('task/comments_view'); ?>

+ 268
- 0
build.xml View File

@@ -0,0 +1,268 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project name="animeclient" default="full-build">
3
+ <!-- By default, we assume all tools to be on the $PATH -->
4
+ <property name="pdepend" value="pdepend"/>
5
+ <property name="phpcpd"  value="phpcpd"/>
6
+ <property name="phpcs"   value="phpcs"/>
7
+ <property name="phploc"  value="phploc"/>
8
+ <property name="phpmd"   value="phpmd"/>
9
+ <property name="phpunit" value="phpunit"/>
10
+ <property name="sonar" value="sonar-runner"/>
11
+
12
+ <!-- Use this when the tools are located as PHARs in build/tools
13
+ <property name="pdepend" value="build/tools/pdepend.phar"/>
14
+ <property name="phpcpd"  value="build/tools/phpcpd.phar"/>
15
+ <property name="phpcs"   value="build/tools/phpcs.phar"/>
16
+ <property name="phpdox"  value="build/tools/phpdox.phar"/>
17
+ <property name="phploc"  value="build/tools/phploc.phar"/>
18
+ <property name="phpmd"   value="build/tools/phpmd.phar"/>
19
+ <property name="phpunit" value="build/tools/phpunit.phar"/> -->
20
+
21
+ <!-- Use this when the tools are managed by Composer in vendor/bin
22
+ <property name="pdepend" value="vendor/bin/pdepend"/>
23
+ <property name="phpcpd"  value="vendor/bin/phpcpd"/>
24
+ <property name="phpcs"   value="vendor/bin/phpcs"/>
25
+ <property name="phpdox"  value="vendor/bin/phpdox"/>
26
+ <property name="phploc"  value="vendor/bin/phploc"/>
27
+ <property name="phpmd"   value="vendor/bin/phpmd"/>
28
+ <property name="phpunit" value="vendor/bin/phpunit"/> -->
29
+
30
+ <target name="full-build"
31
+         depends="prepare,static-analysis,phpunit,sonar,-check-failure"
32
+         description="Performs static analysis, runs the tests, and generates project documentation"/>
33
+
34
+ <target name="full-build-parallel"
35
+         depends="prepare,static-analysis-parallel,phpunit,	-check-failure"
36
+         description="Performs static analysis (executing the tools in parallel), runs the tests, and generates project documentation"/>
37
+
38
+ <target name="quick-build"
39
+         depends="prepare,lint,phpunit-no-coverage"
40
+         description="Performs a lint check and runs the tests (without generating code coverage reports)"/>
41
+
42
+ <target name="static-analysis"
43
+         depends="lint,phploc-ci,pdepend,phpcs-ci,phpcpd-ci"
44
+         description="Performs static analysis" />
45
+
46
+ <!-- Adjust the threadCount attribute's value to the number of CPUs -->
47
+ <target name="static-analysis-parallel"
48
+         description="Performs static analysis (executing the tools in parallel)">
49
+  <parallel threadCount="2">
50
+   <sequential>
51
+    <antcall target="pdepend"/>
52
+   </sequential>
53
+   <antcall target="lint"/>
54
+   <antcall target="phpcpd-ci"/>
55
+   <antcall target="phpcs-ci"/>
56
+   <antcall target="phploc-ci"/>
57
+  </parallel>
58
+ </target>
59
+
60
+ <target name="clean"
61
+         unless="clean.done"
62
+         description="Cleanup build artifacts">
63
+  <delete dir="build/api"/>
64
+  <delete dir="build/coverage"/>
65
+  <delete dir="build/logs"/>
66
+  <delete dir="build/pdepend"/>
67
+  <property name="clean.done" value="true"/>
68
+ </target>
69
+
70
+ <target name="prepare"
71
+         unless="prepare.done"
72
+         depends="clean"
73
+         description="Prepare for build">
74
+  <mkdir dir="build/api"/>
75
+  <mkdir dir="build/coverage"/>
76
+  <mkdir dir="build/logs"/>
77
+  <mkdir dir="build/pdepend"/>
78
+  <property name="prepare.done" value="true"/>
79
+ </target>
80
+
81
+ <target name="lint"
82
+         unless="lint.done"
83
+         description="Perform syntax check of sourcecode files">
84
+  <apply executable="php" taskname="lint">
85
+   <arg value="-l" />
86
+
87
+   <fileset dir="application">
88
+    <include name="**/*.php" />
89
+    <exclude name="logs/*.php" />
90
+    <exclude name="config/**/*.php" />
91
+    <exclude name="errors/*.php" />
92
+    <exclude name="third_party/**/*.php" />
93
+    <exclude name="views/**/*.php" />
94
+    <modified />
95
+   </fileset>
96
+
97
+   <fileset dir="tests">
98
+    <include name="**/*.php" />
99
+    <modified />
100
+   </fileset>
101
+  </apply>
102
+
103
+  <property name="lint.done" value="true"/>
104
+ </target>
105
+
106
+ <target name="phploc"
107
+         unless="phploc.done"
108
+         description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
109
+  <exec executable="${phploc}" taskname="phploc">
110
+   <arg value="--count-tests" />
111
+   <arg path="application/controllers" />
112
+   <arg path="application/models" />
113
+   <arg path="application/libraries" />
114
+   <arg path="application/core" />
115
+   <arg path="application/hooks" />
116
+   <arg path="tests" />
117
+  </exec>
118
+
119
+  <property name="phploc.done" value="true"/>
120
+ </target>
121
+
122
+ <target name="phploc-ci"
123
+         unless="phploc.done"
124
+         depends="prepare"
125
+         description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment.">
126
+  <exec executable="${phploc}" taskname="phploc">
127
+   <arg value="--count-tests" />
128
+   <arg value="--log-csv" />
129
+   <arg path="build/logs/phploc.csv" />
130
+   <arg value="--log-xml" />
131
+   <arg path="build/logs/phploc.xml" />
132
+   <arg path="application/controllers" />
133
+   <arg path="application/models" />
134
+   <arg path="application/libraries" />
135
+   <arg path="application/core" />
136
+   <arg path="application/hooks" />
137
+   <arg path="tests" />
138
+  </exec>
139
+
140
+  <property name="phploc.done" value="true"/>
141
+ </target>
142
+
143
+ <target name="pdepend"
144
+         unless="pdepend.done"
145
+         depends="prepare"
146
+         description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment.">
147
+  <exec executable="${pdepend}" taskname="pdepend">
148
+   <arg value="--jdepend-xml=build/logs/jdepend.xml" />
149
+   <arg value="--jdepend-chart=build/pdepend/dependencies.svg" />
150
+   <arg value="--overview-pyramid=build/pdepend/overview-pyramid.svg" />
151
+   <arg path="application" />
152
+  </exec>
153
+
154
+  <property name="pdepend.done" value="true"/>
155
+ </target>
156
+
157
+ <target name="phpcs"
158
+         unless="phpcs.done"
159
+         description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
160
+  <exec executable="${phpcs}" taskname="phpcs">
161
+   <arg value="--standard=PSR2" />
162
+   <arg value="--extensions=php" />
163
+   <arg value="--ignore=autoload.php" />
164
+   <arg path="application/controllers" />
165
+   <arg path="application/models" />
166
+   <arg path="application/libraries" />
167
+   <arg path="application/core" />
168
+   <arg path="application/hooks" />
169
+   <arg path="tests" />
170
+  </exec>
171
+
172
+  <property name="phpcs.done" value="true"/>
173
+ </target>
174
+
175
+ <target name="phpcs-ci"
176
+         unless="phpcs.done"
177
+         depends="prepare"
178
+         description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
179
+  <exec executable="${phpcs}" output="/dev/null" taskname="phpcs">
180
+   <arg value="--report=checkstyle" />
181
+   <arg value="--report-file=build/logs/checkstyle.xml" />
182
+   <arg value="--standard=PSR2" />
183
+   <arg value="--extensions=php" />
184
+   <arg value="--ignore=autoload.php" />
185
+   <arg path="application/controllers" />
186
+   <arg path="application/models" />
187
+   <arg path="application/libraries" />
188
+   <arg path="application/core" />
189
+   <arg path="application/hooks" />
190
+   <arg path="tests" />
191
+  </exec>
192
+
193
+  <property name="phpcs.done" value="true"/>
194
+ </target>
195
+
196
+ <target name="phpcpd"
197
+         unless="phpcpd.done"
198
+         description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
199
+  <exec executable="${phpcpd}" taskname="phpcpd">
200
+   <arg path="application/controllers" />
201
+   <arg path="application/models" />
202
+   <arg path="application/libraries" />
203
+   <arg path="application/core" />
204
+   <arg path="application/hooks" />
205
+  </exec>
206
+
207
+  <property name="phpcpd.done" value="true"/>
208
+ </target>
209
+
210
+ <target name="phpcpd-ci"
211
+         unless="phpcpd.done"
212
+         depends="prepare"
213
+         description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment.">
214
+  <exec executable="${phpcpd}" taskname="phpcpd">
215
+   <arg value="--log-pmd" />
216
+   <arg path="build/logs/pmd-cpd.xml" />
217
+   <arg path="application/controllers" />
218
+   <arg path="application/models" />
219
+   <arg path="application/libraries" />
220
+   <arg path="application/core" />
221
+   <arg path="application/hooks" />
222
+  </exec>
223
+
224
+  <property name="phpcpd.done" value="true"/>
225
+ </target>
226
+
227
+ <target name="phpunit"
228
+         unless="phpunit.done"
229
+         depends="prepare"
230
+         description="Run unit tests with PHPUnit">
231
+  <exec executable="${phpunit}" resultproperty="result.phpunit" taskname="phpunit">
232
+   <arg value="--configuration"/>
233
+   <arg path="build/phpunit.xml"/>
234
+  </exec>
235
+
236
+  <property name="phpunit.done" value="true"/>
237
+ </target>
238
+
239
+ <target name="phpunit-no-coverage"
240
+         unless="phpunit.done"
241
+         depends="prepare"
242
+         description="Run unit tests with PHPUnit (without generating code coverage reports)">
243
+  <exec executable="${phpunit}" failonerror="true" taskname="phpunit">
244
+   <arg value="--configuration"/>
245
+   <arg path="build/phpunit.xml"/>
246
+   <arg value="--no-coverage"/>
247
+  </exec>
248
+
249
+  <property name="phpunit.done" value="true"/>
250
+ </target>
251
+
252
+<target name="sonar"
253
+		depends="phpunit">
254
+	<exec executable="${sonar}" taskname="sonar"/>
255
+	<property name="sonar.done" value="true"/>
256
+</target>
257
+
258
+ <target name="-check-failure">
259
+  <fail message="PHPUnit did not finish successfully">
260
+   <condition>
261
+    <not>
262
+     <equals arg1="${result.phpunit}" arg2="0"/>
263
+    </not>
264
+   </condition>
265
+  </fail>
266
+ </target>
267
+</project>
268
+

+ 48
- 0
build/phpunit.xml View File

@@ -0,0 +1,48 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+
3
+<phpunit
4
+	colors="true"
5
+	stopOnFailure="false"
6
+	bootstrap="../tests/bootstrap.php">
7
+	<php>
8
+		<server name="SERVER_NAME" value="http://example.com" />
9
+		<server name="REMOTE_ADDR" value="127.0.0.1" />
10
+		<server name="HTTP_USER_AGENT" value="PHPUnit" />
11
+	</php>
12
+	<filter>
13
+		<whitelist>
14
+			<directory suffix=".php">../application/controllers</directory>
15
+			<directory suffix=".php">../application/core</directory>
16
+			<directory suffix=".php">../application/libraries</directory>
17
+			<directory suffix=".php">../application/models</directory>
18
+			<directory suffix=".php">../application/helpers</directory>
19
+		</whitelist>
20
+	</filter>
21
+	<testsuites>
22
+		<testsuite name="ControllerTests">
23
+			<directory suffix=".php">../tests/controllers</directory>
24
+		</testsuite>
25
+		<testsuite name="ExtensionTests">
26
+			<directory suffix=".php">../tests/core</directory>
27
+		</testsuite>
28
+		<testsuite name="HelperTests">
29
+			<directory suffix=".php">../tests/helpers</directory>
30
+		</testsuite>
31
+		<testsuite name="LibTests">
32
+			<directory suffix=".php">../tests/libs</directory>
33
+		</testsuite>
34
+		<testsuite name="ModelTests">
35
+			<directory suffix=".php">../tests/models</directory>
36
+		</testsuite>
37
+		<testsuite name="SystemTests">
38
+			<directory suffix=".php">../tests/system</directory>
39
+		</testsuite>
40
+	</testsuites>
41
+	<logging>
42
+		<log type="coverage-html" target="coverage"/>
43
+		<log type="coverage-clover" target="logs/clover.xml"/>
44
+		<log type="coverage-crap4j" target="logs/crap4j.xml"/>
45
+		<log type="coverage-xml" target="logs/coverage" />
46
+		<log type="junit" target="logs/junit.xml" logIncompleteSkipped="false"/>
47
+	</logging>
48
+</phpunit>

+ 6
- 0
sonar-project.properties View File

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

+ 4
- 4
system/core/Common.php View File

@@ -274,7 +274,7 @@ if ( ! function_exists('config_item'))
274 274
 
275 275
 		if ( ! isset($_config_item[$item]))
276 276
 		{
277
-			$config =& get_config();
277
+			$config = get_config();
278 278
 
279 279
 			if ( ! isset($config[$item]))
280 280
 			{
@@ -514,16 +514,16 @@ if ( ! function_exists('remove_invisible_characters'))
514 514
 	function remove_invisible_characters($str, $url_encoded = TRUE)
515 515
 	{
516 516
 		$non_displayables = array();
517
-		
517
+
518 518
 		// every control character except newline (dec 10)
519 519
 		// carriage return (dec 13), and horizontal tab (dec 09)
520
-		
520
+
521 521
 		if ($url_encoded)
522 522
 		{
523 523
 			$non_displayables[] = '/%0[0-8bcef]/';	// url encoded 00-08, 11, 12, 14, 15
524 524
 			$non_displayables[] = '/%1[0-9a-f]/';	// url encoded 16-31
525 525
 		}
526
-		
526
+
527 527
 		$non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S';	// 00-08, 11, 12, 14-31, 127
528 528
 
529 529
 		do

+ 1
- 1
system/core/Config.php View File

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

+ 1
- 1
system/core/Lang.php View File

@@ -78,7 +78,7 @@ class CI_Lang {
78 78
 			return;
79 79
 		}
80 80
 
81
-		$config =& get_config();
81
+		$config = get_config();
82 82
 
83 83
 		if ($idiom == '')
84 84
 		{

+ 1
- 1
system/libraries/Log.php View File

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

+ 6
- 8
tests/env/autoloader.php View File

@@ -20,15 +20,13 @@ spl_autoload_register(function($class) {
20 20
 		$exact_file = "{$path}{$class}.php";
21 21
 		$lower_file = $path . mb_strtolower($class) . ".php";
22 22
 
23
-		if (file_exists($lower_file))
23
+		foreach([$lower_file, $exact_file] as $file)
24 24
 		{
25
-			require_once($lower_file);
26
-			return;
27
-		}
28
-		else if (file_exists($exact_file))
29
-		{
30
-			require_once($exact_file);
31
-			return;
25
+			if (file_exists($file))
26
+			{
27
+				require_once($file);
28
+				return;
29
+			}
32 30
 		}
33 31
 	}
34 32
 });

+ 10
- 10
tests/phpunit.xml View File

@@ -1,8 +1,8 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 
3
-<phpunit 
4
-	colors="true" 
5
-	stopOnFailure="false" 
3
+<phpunit
4
+	colors="true"
5
+	stopOnFailure="false"
6 6
 	bootstrap="bootstrap.php">
7 7
 	<php>
8 8
 		<server name="SERVER_NAME" value="http://example.com" />
@@ -10,13 +10,13 @@
10 10
 		<server name="HTTP_USER_AGENT" value="PHPUnit" />
11 11
 	</php>
12 12
 	<filter>
13
-		<blacklist>
14
-			<directory suffix=".php">../application/third_party</directory>
15
-			<directory suffix=".php">../application/config</directory>
16
-			<directory suffix=".php">../application/views</directory>
17
-			<directory suffix=".php">../system</directory>
18
-			<directory suffix=".php">.</directory>
19
-		</blacklist>
13
+		<whitelist>
14
+			<directory suffix=".php">../application/controllers</directory>
15
+			<directory suffix=".php">../application/core</directory>
16
+			<directory suffix=".php">../application/libraries</directory>
17
+			<directory suffix=".php">../application/models</directory>
18
+			<directory suffix=".php">../application/helpers</directory>
19
+		</whitelist>
20 20
 	</filter>
21 21
 	<testsuites>
22 22
 		<testsuite name="ControllerTests">

+ 19
- 19
web/css/todo.css View File

@@ -175,7 +175,7 @@ section{
175 175
 
176 176
 
177 177
 
178
-input[type="submit"], input[type="button"]{
178
+input[type="submit"], input[type="button"], button{
179 179
 	background:url('/images/bgs/Title.png');
180 180
 	color:#fff;
181 181
 	padding:0.5em;
@@ -601,7 +601,7 @@ select#friends option{
601 601
 		vertical-align:top;
602 602
 		display:inline-block;
603 603
 	}
604
-	
604
+
605 605
 	header nav{
606 606
 		width:80%;
607 607
 	}
@@ -609,7 +609,7 @@ select#friends option{
609 609
 	section, footer, nav{
610 610
 		border:0;
611 611
 	}
612
-	
612
+
613 613
 	dt{
614 614
 		text-align:right;
615 615
 		padding-right:0.5em;
@@ -633,7 +633,7 @@ select#friends option{
633 633
 		border-radius:5px;
634 634
 		margin-left:0.35%;
635 635
 	}
636
-	
636
+
637 637
 	#pagination strong{
638 638
 		letter-spacing:.5em;
639 639
 		margin-left:.5em;
@@ -658,34 +658,34 @@ select#friends option{
658 658
 		vertical-align:top;
659 659
 		background:transparent;
660 660
 	}
661
-	
661
+
662 662
 	.left{
663 663
 		border-radius:0;
664 664
 		text-align:left;
665 665
 		width:15%;
666 666
 	}
667
-	
667
+
668 668
 	#home .left{
669 669
 		width:74%;
670 670
 	}
671
-	
671
+
672 672
 	.left form{
673 673
 		width:100%;
674 674
 		margin:0 auto;
675 675
 	}
676
-	
676
+
677 677
 	.right{
678 678
 		border-bottom-left-radius:5px;
679 679
 		padding-top:0;
680 680
 		margin-left:.25%;
681 681
 		width:83%;
682
-		
682
+
683 683
 	}
684
-	
684
+
685 685
 	#home .right{
686 686
 		width:22%;
687 687
 	}
688
-	
688
+
689 689
 	dt{
690 690
 		width:13%;
691 691
 	}
@@ -693,25 +693,25 @@ select#friends option{
693 693
 	#left_nav li{
694 694
 		display:block;
695 695
 	}
696
-	
696
+
697 697
 	fieldset dt, fieldset dd{
698 698
 		display:inline-block;
699 699
 		vertical-align:top;
700 700
 		margin:.5% 0;
701 701
 	}
702
-	
702
+
703 703
 	strong {
704 704
 		font-weight:bold;
705 705
 	}
706
-	
706
+
707 707
 	#task_view dt, th a{
708 708
 		font-weight:bold;
709 709
 	}
710
-	
710
+
711 711
 	.error{
712 712
 		font-weight:300;
713 713
 	}
714
-	
714
+
715 715
 	#task_comment_list dt{
716 716
 		width:25%;
717 717
 		padding:.5em;
@@ -721,12 +721,12 @@ select#friends option{
721 721
 		width:70%;
722 722
 		padding:.5em;
723 723
 	}
724
-	
724
+
725 725
 	.immediate, td.immediate, .overdue td{
726 726
 		font-weight:bold;
727 727
 		font-style:italic;
728 728
 	}
729
-	
729
+
730 730
 	.overdue td{
731 731
 		font-weight:bold;
732 732
 	}
@@ -736,7 +736,7 @@ select#friends option{
736 736
 		vertical-align:top;
737 737
 		margin:.5em auto;
738 738
 	}
739
-	
739
+
740 740
 	#home .right dt, #home .right dd{
741 741
 		width:45%;
742 742
 		display:inline-block;