Passed
Push — main ( c1d479...a20d4a )
by Rafael
46:41
created

testSqlAndScriptInject()   C

Complexity

Conditions 11
Paths 128

Size

Total Lines 129
Code Lines 67

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 11
eloc 67
c 1
b 0
f 0
nc 128
nop 2
dl 0
loc 129
rs 6.3865

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * Copyright (C) 2024       Rafael San José         <[email protected]>
5
 *
6
 * This program is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
use Alxarafe\Base\Config as BaseConfig;
21
use DoliCore\Tools\Load;
22
use DoliLib\DolibarrAuth;
23
24
$authenticated = $_SESSION['dol_login'] ?? false;
25
if (!$authenticated) {
26
    header('Location: ' . constant('BASE_URL') . '/index.php?module=Auth&controller=Login');
27
    die();
28
}
29
30
global $conf;
31
global $config;
32
global $db;
33
global $hookmanager;
34
global $langs;
35
global $user;
36
global $menumanager;
37
global $mysoc; // From master.inc.php
38
39
DolibarrAuth::setSession($authenticated);
40
41
$conf = Load::getConfig();
42
$config = BaseConfig::getConfig();
43
$db = Load::getDB();
44
$hookmanager = Load::getHookManager();
45
$langs = Load::getLangs();
46
$user = Load::getUser();
47
$menumanager = Load::getMenuManager();
48
if (isset($menumanager)) {
49
    $menumanager->loadMenu();
50
}
51
$mysoc = Load::getMySoc();
52