ReportIssue::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
ccs 0
cts 5
cp 0
crap 2
1
<?php defined('BASEPATH') OR exit('No direct script access allowed');
2
3
class ReportIssue extends MY_Controller {
4
	public function __construct() {
5
		parent::__construct();
6
		$this->load->helper('form');
7
		$this->load->library('form_validation');
8
	}
9
10
	public function index() : void {
11
		$this->header_data['title'] = 'Report Issue';
12
		$this->header_data['page']  = 'report-issue';
13
14
		show_404();
15
		return;
16
17
		$this->form_validation->set_rules('issue_description', 'Description', 'required|max_length[1000]');
0 ignored issues
show
Unused Code introduced by
$this->form_validation->...red|max_length[1000]'); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
18
		$this->form_validation->set_rules('issue_url',         'URL',         'valid_url');
19
20
21
		$this->body_data['issue_submitted'] = FALSE;
22
		if($isValid = ($this->form_validation->run() === TRUE)) {
23
			//send report
24
25
			if(!empty($this->input->post('website'))) {
26
				$this->body_data['issue_submitted'] = FALSE;
27
				log_message('error', 'Bot attempting to spam report issue form: "' . $this->input->post('issue_description') . '"');
0 ignored issues
show
Unused Code introduced by
The call to the function log_message() seems unnecessary as the function has no side-effects.
Loading history...
28
			} else {
29
				$this->body_data['issue_submitted'] = $this->Tracker->issue->report('USERID:' . $this->User->id . ' ||| ' . $this->input->post('issue_description'), NULL, $this->input->post('issue_url'));
30
			}
31
		}
32
33
		$this->body_data['form_description'] = [
34
			'name' => 'issue_description',
35
36
			'value' => $this->form_validation->set_value('issue_description') ?: '',
37
38
			'class' => 'form-control',
39
			'rows' => '3',
40
41
			'placeholder' => 'Please describe your issue and provide as much info as possible.&#10;If you have any feature requests, please use submit an issue to our Github instead.',
42
43
			'required' => TRUE
44
		];
45
46
		$this->body_data['form_url'] = array(
47
			'name'        => 'issue_url',
48
49
			'class'       => 'form-control',
50
51
			'value'       => $this->form_validation->set_value('issue_url') ?: $this->input->get('url', TRUE) ?: ''
52
		);
53
54
		if(!$isValid) {
55
			$this->body_data['form_url']['value'] = '';
56
		}
57
		$this->_render_page('ReportIssue');
58
	}
59
}
60