validateFileUpload accesses the super-global variable $_FILES. Open
public static function validateFileUpload(App\Request $request)
{
$currentUser = \App\User::getCurrentUserModel();
$uploadMaxSize = \App\Config::getMaxUploadSize();
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
validateFileUpload accesses the super-global variable $_FILES. Open
public static function validateFileUpload(App\Request $request)
{
$currentUser = \App\User::getCurrentUserModel();
$uploadMaxSize = \App\Config::getMaxUploadSize();
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
validateFileUpload accesses the super-global variable $_FILES. Open
public static function validateFileUpload(App\Request $request)
{
$currentUser = \App\User::getCurrentUserModel();
$uploadMaxSize = \App\Config::getMaxUploadSize();
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
validateFileUpload accesses the super-global variable $_FILES. Open
public static function validateFileUpload(App\Request $request)
{
$currentUser = \App\User::getCurrentUserModel();
$uploadMaxSize = \App\Config::getMaxUploadSize();
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
validateFileUpload accesses the super-global variable $_FILES. Open
public static function validateFileUpload(App\Request $request)
{
$currentUser = \App\User::getCurrentUserModel();
$uploadMaxSize = \App\Config::getMaxUploadSize();
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Method validateFileUpload
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function validateFileUpload(App\Request $request)
{
$currentUser = \App\User::getCurrentUserModel();
$uploadMaxSize = \App\Config::getMaxUploadSize();
Function validateFileUpload
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function validateFileUpload(App\Request $request)
{
$currentUser = \App\User::getCurrentUserModel();
$uploadMaxSize = \App\Config::getMaxUploadSize();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
The method validateFileUpload() has an NPath complexity of 384. The configured NPath complexity threshold is 200. Open
public static function validateFileUpload(App\Request $request)
{
$currentUser = \App\User::getCurrentUserModel();
$uploadMaxSize = \App\Config::getMaxUploadSize();
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method validateFileUpload() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public static function validateFileUpload(App\Request $request)
{
$currentUser = \App\User::getCurrentUserModel();
$uploadMaxSize = \App\Config::getMaxUploadSize();
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Reduce the number of returns of this function 9, down to the maximum allowed 3. Open
public static function validateFileUpload(App\Request $request)
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Missing class import via use statement (line '66', column '17'). Open
$viewer = new Vtiger_Viewer();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method showErrorPage has a boolean flag argument $customActions, which is a certain sign of a Single Responsibility Principle violation. Open
public static function showErrorPage($errorMessage, $errorDetails = false, $customActions = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method showErrorPage has a boolean flag argument $errorDetails, which is a certain sign of a Single Responsibility Principle violation. Open
public static function showErrorPage($errorMessage, $errorDetails = false, $customActions = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid using static access to class '\App\User' in method 'getAssignedToGroupList'. Open
if ($cache->getGroupList($module, \App\User::getCurrentUserId())) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Import_Module_Model' in method 'validateFileUpload'. Open
$fileReader = Import_Module_Model::getFileReader($request, $currentUser);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'validateFileUpload'. Open
$request->set('error_message', \App\Language::translate('LBL_NO_ROWS_FOUND', 'Import'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'showImportLockedError'. Open
$errorMessage = \App\Language::translate('ERR_MODULE_IMPORT_LOCKED', 'Import');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\User' in method 'getAssignedToUserList'. Open
if ($cache->getUserList($module, \App\User::getCurrentUserId())) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Fields\File' in method 'validateFileUpload'. Open
$request->set('error_message', \App\Fields\File::getErrorMessage($_FILES['import_file']['error']));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'validateFileUpload'. Open
$uploadMaxSize . ' ' . \App\Language::translate('LBL_IMPORT_CHANGE_UPLOAD_SIZE', 'Import'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Module' in method 'showImportLockedError'. Open
$errorDetails = [\App\Language::translate('LBL_MODULE_NAME', 'Import') => \App\Module::getModuleName($lockInfo['tabid']),
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'showImportLockedError'. Open
\App\Language::translate('LBL_USER_NAME', 'Import') => \App\Fields\Owner::getUserLabel($lockInfo['userid']),
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Vtiger_Cache' in method 'getAssignedToGroupList'. Open
$cache = Vtiger_Cache::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'validateFileUpload'. Open
$request->set('error_message', \App\Language::translate('LBL_IMPORT_DIRECTORY_NOT_WRITABLE', 'Import'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'validateFileUpload'. Open
$request->set('error_message', \App\Language::translateArgs('LBL_IMPORT_FILE_DIFFERENT_ENCODING', 'Import', $fileInstance->getEncoding()));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Fields\File' in method 'validateFileUpload'. Open
$fileInstance = \App\Fields\File::loadFromRequest($_FILES['import_file']);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'validateFileUpload'. Open
$request->set('error_message', \App\Language::translate('LBL_IMPORT_FILE_COPY_FAILED', 'Import'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\User' in method 'getAssignedToUserList'. Open
$cache->setUserList($module, $userList, \App\User::getCurrentUserId());
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\User' in method 'getAssignedToGroupList'. Open
$cache->setGroupList($module, $groupList, \App\User::getCurrentUserId());
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'showImportTableBlockedError'. Open
$errorMessage = \App\Language::translate('ERR_UNIMPORTED_RECORDS_EXIST', 'Import');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Fields\File' in method 'getImportFilePath'. Open
return App\Fields\File::getTmpPath() . 'IMPORT_' . $user->getId();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\User' in method 'validateFileUpload'. Open
$currentUser = \App\User::getCurrentUserModel();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'validateFileUpload'. Open
$uploadMaxSize = \App\Config::getMaxUploadSize();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'validateFileUpload'. Open
$request->set('error_message', \App\Language::translate('LBL_INVALID_FILE', 'Import'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Vtiger_Cache' in method 'getAssignedToUserList'. Open
$cache = Vtiger_Cache::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'validateFileUpload'. Open
$request->set('error_message', \App\Language::translate('LBL_FILE_UPLOAD_FAILED', 'Import'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'validateFileUpload'. Open
$request->set('error_message', \App\Language::translate('LBL_IMPORT_ERROR_LARGE_FILE', 'Import') .
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Fields\Owner' in method 'showImportLockedError'. Open
\App\Language::translate('LBL_USER_NAME', 'Import') => \App\Fields\Owner::getUserLabel($lockInfo['userid']),
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'showImportLockedError'. Open
\App\Language::translate('LBL_LOCKED_TIME', 'Import') => $lockInfo['locked_since'], ];
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\User' in method 'getAssignedToGroupList'. Open
return $cache->getGroupList($module, \App\User::getCurrentUserId());
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Fields\File' in method 'validateFileUpload'. Open
$importDirectory = App\Fields\File::getTmpPath();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\User' in method 'getAssignedToUserList'. Open
return $cache->getUserList($module, \App\User::getCurrentUserId());
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'showImportLockedError'. Open
$errorDetails = [\App\Language::translate('LBL_MODULE_NAME', 'Import') => \App\Module::getModuleName($lockInfo['tabid']),
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Define a constant instead of duplicating this literal "import_file" 5 times. Open
if ($_FILES['import_file']['error']) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "error_message" 8 times. Open
$request->set('error_message', \App\Fields\File::getErrorMessage($_FILES['import_file']['error']));
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Import" 15 times. Open
$viewer->assign('MODULE_NAME', 'Import');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('CUSTOM_ACTIONS', $customActions);
- Exclude checks
Call to method setUserList
on non-class type false
Open
$cache->setUserList($module, $userList, \App\User::getCurrentUserId());
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
if ($cache->getUserList($module, \App\User::getCurrentUserId())) {
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$cache->setUserList($module, $userList, \App\User::getCurrentUserId());
- Exclude checks
Parameter $user
has undeclared type \App\User
(Did you mean class \Tests\App\User) Open
public static function getImportFilePath(App\User $user)
- Exclude checks
Call to method getId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
return App\Fields\File::getTmpPath() . 'IMPORT_' . $user->getId();
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('ERROR_MESSAGE', $errorMessage);
- Exclude checks
Call to method getInstance
from undeclared class \App\Fields\Owner
Open
$userList = \App\Fields\Owner::getInstance($module)->getAccessibleUsers('', 'owner');
- Exclude checks
Call to method getGroupList
on non-class type false
Open
if ($cache->getGroupList($module, \App\User::getCurrentUserId())) {
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
return $cache->getGroupList($module, \App\User::getCurrentUserId());
- Exclude checks
Call to method getUserList
on non-class type false
Open
return $cache->getUserList($module, \App\User::getCurrentUserId());
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('ERROR_DETAILS', $errorDetails);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('MODULE_NAME', 'Import');
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
return $cache->getUserList($module, \App\User::getCurrentUserId());
- Exclude checks
Call to method getInstance
from undeclared class \App\Fields\Owner
Open
$groupList = \App\Fields\Owner::getInstance()->getGroups(false);
- Exclude checks
Call to method getUserLabel
from undeclared class \App\Fields\Owner
Open
\App\Language::translate('LBL_USER_NAME', 'Import') => \App\Fields\Owner::getUserLabel($lockInfo['userid']),
- Exclude checks
Call to method getUserList
on non-class type false
Open
if ($cache->getUserList($module, \App\User::getCurrentUserId())) {
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$cache->setGroupList($module, $groupList, \App\User::getCurrentUserId());
- Exclude checks
Call to method getCurrentUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$currentUser = \App\User::getCurrentUserModel();
- Exclude checks
Call to method getGroupList
on non-class type false
Open
return $cache->getGroupList($module, \App\User::getCurrentUserId());
- Exclude checks
Call to method setGroupList
on non-class type false
Open
$cache->setGroupList($module, $groupList, \App\User::getCurrentUserId());
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
if ($cache->getGroupList($module, \App\User::getCurrentUserId())) {
- Exclude checks
Avoid excessively long variable names like $supportedFileExtensionsByModule. Keep variable name length under 20. Open
public static $supportedFileExtensionsByModule = ['Contacts' => ['csv', 'vcf'], 'Calendar' => ['csv', 'ical', 'ics'], 'Default' => ['csv', 'xml', 'zip']];
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $supportedFileExtensions. Keep variable name length under 20. Open
public static $supportedFileExtensions = ['csv', 'vcf', 'ical', 'xml', 'ics'];
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $AUTO_MERGE_MERGEFIELDS. Keep variable name length under 20. Open
public static $AUTO_MERGE_MERGEFIELDS = 3;
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Import_Utils_Helper
- Exclude checks
The property $AUTO_MERGE_MERGEFIELDS is not named in camelCase. Open
class Import_Utils_Helper
{
public static $AUTO_MERGE_NONE = 0;
public static $AUTO_MERGE_IGNORE = 1;
public static $AUTO_MERGE_OVERWRITE = 2;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $AUTO_MERGE_IGNORE is not named in camelCase. Open
class Import_Utils_Helper
{
public static $AUTO_MERGE_NONE = 0;
public static $AUTO_MERGE_IGNORE = 1;
public static $AUTO_MERGE_OVERWRITE = 2;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The class Import_Utils_Helper is not named in CamelCase. Open
class Import_Utils_Helper
{
public static $AUTO_MERGE_NONE = 0;
public static $AUTO_MERGE_IGNORE = 1;
public static $AUTO_MERGE_OVERWRITE = 2;
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
The property $AUTO_MERGE_OVERWRITE is not named in camelCase. Open
class Import_Utils_Helper
{
public static $AUTO_MERGE_NONE = 0;
public static $AUTO_MERGE_IGNORE = 1;
public static $AUTO_MERGE_OVERWRITE = 2;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $AUTO_MERGE_NONE is not named in camelCase. Open
class Import_Utils_Helper
{
public static $AUTO_MERGE_NONE = 0;
public static $AUTO_MERGE_IGNORE = 1;
public static $AUTO_MERGE_OVERWRITE = 2;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Terminating statement must be indented to the same level as the CASE body Open
return self::$supportedFileExtensionsByModule[$moduleName];
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
return self::$supportedFileExtensionsByModule['Default'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $AUTO_MERGE_IGNORE = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Language::translate('LBL_USER_NAME', 'Import') => \App\Fields\Owner::getUserLabel($lockInfo['userid']),
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
$customActions = ['LBL_CLEAR_DATA' => "location.href='index.php?module={$moduleName}&view=Import&mode=clearCorruptedData'"];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($cache->getUserList($module, \App\User::getCurrentUserId())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get supported file extensions description.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('ERROR_MESSAGE', $errorMessage);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('MODULE_NAME', 'Import');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
$errorDetails = [\App\Language::translate('LBL_MODULE_NAME', 'Import') => \App\Module::getModuleName($lockInfo['tabid']),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Language::translate('LBL_LOCKED_TIME', 'Import') => $lockInfo['locked_since'], ];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::showErrorPage($errorMessage, $errorDetails);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $userList;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $supportedFileExtensions = ['csv', 'vcf', 'ical', 'xml', 'ics'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSupportedFileExtensions($moduleName = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer = new Vtiger_Viewer();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::$supportedFileExtensionsByModule[$moduleName];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Shows import errors in the table.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getAssignedToGroupList($module)
- Exclude checks
Line exceeds 120 characters; contains 158 characters Open
public static $supportedFileExtensionsByModule = ['Contacts' => ['csv', 'vcf'], 'Calendar' => ['csv', 'ical', 'ics'], 'Default' => ['csv', 'xml', 'zip']];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($supportedFileTypes as $fileType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$supportedFileTypes = self::getSupportedFileExtensions($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userList = \App\Fields\Owner::getInstance($module)->getAccessibleUsers('', 'owner');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cache = Vtiger_Cache::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$errorMessage = \App\Language::translate('ERR_UNIMPORTED_RECORDS_EXIST', 'Import');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getAssignedToUserList($module)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $AUTO_MERGE_OVERWRITE = 2;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $supportedFileExtensionsByModule = ['Contacts' => ['csv', 'vcf'], 'Calendar' => ['csv', 'ical', 'ics'], 'Default' => ['csv', 'xml', 'zip']];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$moduleName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'Calendar':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSupportedFileExtensionsDescription(string $moduleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $cache->getUserList($module, \App\User::getCurrentUserId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $cache->getGroupList($module, \App\User::getCurrentUserId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $AUTO_MERGE_MERGEFIELDS = 3;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getImportFilePath(App\User $user)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return App\Fields\File::getTmpPath() . 'IMPORT_' . $user->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$errorMessage = \App\Language::translate('ERR_MODULE_IMPORT_LOCKED', 'Import');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$customActions = ['LBL_CLEAR_DATA' => "location.href='index.php?module={$moduleName}&view=Import&mode=clearCorruptedData'"];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cache->setUserList($module, $userList, \App\User::getCurrentUserId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$groupList = \App\Fields\Owner::getInstance()->getGroups(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $AUTO_MERGE_NONE = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'Contacts':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function showImportLockedError($lockInfo)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$description[] = '.' . strtoupper($fileType);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function showErrorPage($errorMessage, $errorDetails = false, $customActions = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function showImportTableBlockedError($moduleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cache = Vtiger_Cache::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($moduleName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('CUSTOM_ACTIONS', $customActions);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('ImportError.tpl', 'Import');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\User $user
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('ERROR_DETAILS', $errorDetails);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::showErrorPage($errorMessage, '', $customActions);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::$supportedFileExtensions;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::$supportedFileExtensionsByModule['Default'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return implode(', ', $description);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* The function takes the path of the file to be imported.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($cache->getGroupList($module, \App\User::getCurrentUserId())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!is_uploaded_file($_FILES['import_file']['tmp_name'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$description = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$errorDetails = [\App\Language::translate('LBL_MODULE_NAME', 'Import') => \App\Module::getModuleName($lockInfo['tabid']),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$assignableGroupsList = self::getAssignedToGroupList($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request->set('error_message', \App\Language::translate('LBL_FILE_UPLOAD_FAILED', 'Import'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($_FILES['import_file']['size'] > $uploadMaxSize) {
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
$request->set('error_message', \App\Language::translateArgs('LBL_IMPORT_FILE_DIFFERENT_ENCODING', 'Import', $fileInstance->getEncoding()));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$fileInstance->moveFile($temporaryFileName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileReader = Import_Module_Model::getFileReader($request, $currentUser);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request->set('error_message', \App\Language::translate('LBL_INVALID_FILE', 'Import'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$temporaryFileName = self::getImportFilePath($currentUser);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($_FILES['import_file']['error']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function hasAssignPrivilege($moduleName, $assignToUserId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request->set('error_message', \App\Fields\File::getErrorMessage($_FILES['import_file']['error']));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileInstance = \App\Fields\File::loadFromRequest($_FILES['import_file']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request->set('error_message', \App\Language::translate('LBL_IMPORT_DIRECTORY_NOT_WRITABLE', 'Import'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function validateFileUpload(App\Request $request)
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
if ('zip' !== $fileInstance->getExtension(true) && $fileInstance->getEncoding() !== strtoupper($request->getByType('file_encoding', 'Text'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $groupList;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\array_key_exists($assignToUserId, $assignableGroupsList)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!is_writable($importDirectory)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\array_key_exists($assignToUserId, $assignableUsersList)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null === $fileReader) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false === $firstRow) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$assignableUsersList = self::getAssignedToUserList($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Validates uploads file.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$firstRow = $fileReader->getFirstRowData($fileReader->hasHeader());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$importDirectory = App\Fields\File::getTmpPath();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('zip' !== $fileInstance->getExtension(true) && $fileInstance->getEncoding() !== strtoupper($request->getByType('file_encoding', 'Text'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request->set('error_message', \App\Language::translate('LBL_NO_ROWS_FOUND', 'Import'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$uploadMaxSize = \App\Config::getMaxUploadSize();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request->set('error_message', \App\Language::translateArgs('LBL_IMPORT_FILE_DIFFERENT_ENCODING', 'Import', $fileInstance->getEncoding()));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentUser = \App\User::getCurrentUserModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cache->setGroupList($module, $groupList, \App\User::getCurrentUserId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request->set('error_message', \App\Language::translate('LBL_IMPORT_ERROR_LARGE_FILE', 'Import') .
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$uploadMaxSize . ' ' . \App\Language::translate('LBL_IMPORT_CHANGE_UPLOAD_SIZE', 'Import'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request->set('error_message', \App\Language::translate('LBL_IMPORT_FILE_COPY_FAILED', 'Import'));
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
case 'Calendar':
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 12 Open
}
- Exclude checks
Closing brace indented incorrectly; expected 8 spaces, found 12 Open
}
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
default:
- Exclude checks
Class name "Import_Utils_Helper" is not in camel caps format Open
class Import_Utils_Helper
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
case 'Contacts':
- Exclude checks