Missing class import via use statement (line '59', column '77'). Open
$i = $db->createCommand()->update('vtiger_customview', ['sequence' => new yii\db\Expression($caseSequence)], ['cvid' => $params])->execute();
- 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
Missing class import via use statement (line '23', column '16'). Open
$query = new App\Db\Query();
- 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
Missing class import via use statement (line '107', column '22'). Open
$dataReader = (new App\Db\Query())
- 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
Avoid using static access to class '\App\CustomView' in method 'upadteSequences'. Open
\App\CustomView::clearCacheById($cvId);
- 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\Db' in method 'upadteSequences'. Open
$db = App\Db::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
Define a constant instead of duplicating this literal "&cvid=" 4 times. Open
return 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=default&sourceModule=' . $module . '&cvid=' . $cvid . '&isDefault=' . $isDefault;
- 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 \App\Db\Query::select
Open
$dataReader = (new App\Db\Query())
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$i = $db->createCommand()->update('vtiger_customview', ['sequence' => new yii\db\Expression($caseSequence)], ['cvid' => $params])->execute();
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query->select(['user'])
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query->select(['member'])
- Exclude checks
Call to method close
from undeclared class \yii\db\DataReader
Open
$dataReader->close();
- Exclude checks
Call to undeclared method \App\Db::quoteColumnName
Open
$caseSequence .= ' WHEN ' . $db->quoteColumnName('cvid') . ' = ' . $db->quoteValue($cvId) . ' THEN ' . $db->quoteValue($sequence);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query->select(['userid'])
- Exclude checks
Call to undeclared method \App\Db::quoteValue
Open
$caseSequence .= ' WHEN ' . $db->quoteColumnName('cvid') . ' = ' . $db->quoteValue($cvId) . ' THEN ' . $db->quoteValue($sequence);
- Exclude checks
Call to method __construct
from undeclared class \yii\db\Expression
Open
$i = $db->createCommand()->update('vtiger_customview', ['sequence' => new yii\db\Expression($caseSequence)], ['cvid' => $params])->execute();
- Exclude checks
Call to method readColumn
from undeclared class \yii\db\DataReader
Open
while ($user = $dataReader->readColumn(0)) {
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_CustomView_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = App\Db::getInstance();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The class Settings_CustomView_Module_Model is not named in CamelCase. Open
class Settings_CustomView_Module_Model extends Settings_Vtiger_Module_Model
{
/**
* Gets members filter by type.
*
- 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
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = $db->createCommand()->update('vtiger_customview', ['sequence' => new yii\db\Expression($caseSequence)], ['cvid' => $params])->execute();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Spaces must be used to indent lines; tabs are not allowed Open
* Gets members filter by type.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $cvId
- 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
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFilterPermissionsView(int $cvId, string $action): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('u_#__cv_privileges')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($params as $sequence => $cvId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$users = [];
- 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
$dataReader = $query->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = App\Db::getInstance();
- 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
} elseif ('permissions' == $action) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$caseSequence = 'CASE ';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- 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 string $action
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = new App\Db\Query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->select(['userid'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->orderBy(['user' => SORT_ASC]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['cvid' => $cvId])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $users;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->select(['user'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$caseSequence .= ' WHEN ' . $db->quoteColumnName('cvid') . ' = ' . $db->quoteValue($cvId) . ' THEN ' . $db->quoteValue($sequence);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($user = $dataReader->readColumn(0)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('u_#__featured_filter')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->select(['member'])
- 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
->from('vtiger_user_module_preferences')
- 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
if ('default' == $action) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('featured' == $action) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['cvid' => $cvId])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$users[$members[0]][] = $user;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->orderBy(['userid' => SORT_ASC]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->orderBy(['member' => SORT_ASC]);
- 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
->where(['default_cvid' => $cvId])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function upadteSequences($params)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$members = explode(':', $user);
- Exclude checks
Line exceeds 120 characters; contains 149 characters Open
$i = $db->createCommand()->update('vtiger_customview', ['sequence' => new yii\db\Expression($caseSequence)], ['cvid' => $params])->execute();
- Exclude checks
Line exceeds 120 characters; contains 169 characters Open
return 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=default&sourceModule=' . $module . '&cvid=' . $cvid . '&isDefault=' . $isDefault;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\CustomView::clearCacheById($cvId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=permissions&sourceModule=' . $module . '&cvid=' . $cvid;
- 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
$dataReader = (new App\Db\Query())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $i;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=featured&sourceModule=' . $module . '&cvid=' . $cvid;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'index.php?module=CustomView&view=EditAjax&source_module=' . $module;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modulesList = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getUrlDefaultUsers($module, $cvid, $isDefault)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->leftJoin('vtiger_tab', 'vtiger_tab.name = vtiger_customview.entitytype')
- 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
->where(['vtiger_tab.presence' => 0])
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
return 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=featured&sourceModule=' . $module . '&cvid=' . $cvid;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$i = $db->createCommand()->update('vtiger_customview', ['sequence' => new yii\db\Expression($caseSequence)], ['cvid' => $params])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($params as $cvId) {
- 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
Line exceeds 120 characters; contains 142 characters Open
$caseSequence .= ' WHEN ' . $db->quoteColumnName('cvid') . ' = ' . $db->quoteValue($cvId) . ' THEN ' . $db->quoteValue($sequence);
- 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 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=default&sourceModule=' . $module . '&cvid=' . $cvid . '&isDefault=' . $isDefault;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Gets URL for modal window with permission settings.
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getUrlToEdit($module, $record)
- 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
->select(['vtiger_tab.tabid', 'vtiger_customview.entitytype'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$caseSequence .= ' END';
- 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
$modulesList[$row['tabid']] = $row['entitytype'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'index.php?module=CustomView&parent=Settings&view=SortOrderModal&type=featured&sourceModule=' . $module . '&cvid=' . $cvid;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
return 'index.php?module=CustomView&parent=Settings&view=SortOrderModal&type=featured&sourceModule=' . $module . '&cvid=' . $cvid;
- 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
->from('vtiger_customview')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $modulesList;
- 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
* @param string $module
- 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 "index.php?module=CustomView&view=EditAjax&source_module=$module&record=$record";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getCreateFilterUrl($module)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getSortingFilterUrl($module, $cvid)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $cvid
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getPrivilegesUrl(string $module, int $cvid): 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
public function getFeaturedFilterUrl($module, $cvid)
- 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
Line exceeds 120 characters; contains 144 characters Open
return 'index.php?module=CustomView&parent=Settings&view=FilterPermissions&type=permissions&sourceModule=' . $module . '&cvid=' . $cvid;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSupportedModules()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createCommand()->query();
- Exclude checks
Class name "Settings_CustomView_Module_Model" is not in camel caps format Open
class Settings_CustomView_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks