GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

LocaliseController   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 76
Duplicated Lines 52.63 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 15
lcom 0
cbo 0
dl 40
loc 76
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C display() 40 63 15

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @package     Com_Localise
4
 * @subpackage  Controller
5
 *
6
 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
7
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
8
 */
9
10
defined('_JEXEC') or die;
11
12
/**
13
 * Controller class for the localise component
14
 *
15
 * @package     Extensions.Components
16
 * @subpackage  Localise
17
 * @since       1.0
18
 */
19
class LocaliseController extends JControllerLegacy
20
{
21
	/**
22
	 * Method to display a view.
23
	 *
24
	 * @param   boolean  $cachable   If true, the view output will be cached
25
	 * @param   array    $urlparams  An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
26
	 *
27
	 * @return  JController  This object to support chaining.
28
	 *
29
	 * @since   1.5
30
	 */
31
	public function display($cachable = false, $urlparams = false)
32
	{
33
		require_once JPATH_COMPONENT . '/helpers/localise.php';
34
		$app = JFactory::getApplication('administrator');
0 ignored issues
show
Unused Code introduced by
$app is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
35
36
		$vName = $this->input->get('view', 'languages');
37
		$layout = $this->input->get('layout', 'default');
38
		$id     = $this->input->getInt('id');
39
40
		if ($vName == 'translations')
41
		{
42
			$view     = $this->getView('translations', 'html');
43
			$packages = $this->getModel('Packages', 'LocaliseModel', array('ignore_request' => true));
44
			$view->setModel($packages);
45
		}
46
		// Check for edit form.
47 View Code Duplication
		elseif ($vName == 'language' && $layout == 'edit'
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
			&& !$this->checkEditId('com_localise.edit.language', $id))
49
		{
50
			// Somehow the person just went to the form - we don't allow that.
51
			$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
52
			$this->setMessage($this->getError(), 'error');
53
			$this->setRedirect(JRoute::_('index.php?option=com_localise&view=languages', false));
54
55
			return false;
56
		}
57 View Code Duplication
		elseif ($vName == 'translation' && ($layout == 'edit' || $layout == 'raw')
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
			&& !$this->checkEditId('com_localise.edit.translation', $id))
59
		{
60
			// Somehow the person just went to the form - we don't allow that.
61
			$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
62
			$this->setMessage($this->getError(), 'error');
63
			$this->setRedirect(JRoute::_('index.php?option=com_localise&view=translations', false));
64
65
			return false;
66
		}
67 View Code Duplication
		elseif ($vName == 'packagefile' && $layout == 'edit'
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
68
			&& !$this->checkEditId('com_localise.edit.packagefile', $id))
69
		{
70
			// Somehow the person just went to the form - we don't allow that.
71
			$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
72
			$this->setMessage($this->getError(), 'error');
73
			$this->setRedirect(JRoute::_('index.php?option=com_localise&view=packages', false));
74
75
			return false;
76
		}
77 View Code Duplication
		elseif ($vName == 'package' && $layout == 'edit'
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
78
			&& !$this->checkEditId('com_localise.edit.package', $id))
79
		{
80
			// Somehow the person just went to the form - we don't allow that.
81
			$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
82
			$this->setMessage($this->getError(), 'error');
83
			$this->setRedirect(JRoute::_('index.php?option=com_localise&view=packages', false));
84
85
			return false;
86
		}
87
		else
88
		{
89
			$this->input->set('view', $vName);
90
		}
91
92
		parent::display($cachable, $urlparams);
93
	}
94
}
95