Method testAddRole
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testAddRole()
{
$recordModel = new \Settings_Roles_Record_Model();
$parentRole = \Settings_Roles_Record_Model::getInstanceById('H2');
$this->assertNotNull($parentRole);
Method testEditRole
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testEditRole()
{
$recordModel = \Settings_Roles_Record_Model::getInstanceById(self::$id);
$this->assertNotNull($recordModel);
Missing class import via use statement (line '102', column '15'). Open
$row = (new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->one();
- 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 '26', column '22'). Open
$recordModel = new \Settings_Roles_Record_Model();
- 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 '48', column '15'). Open
$row = (new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->one();
- 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 '75', column '15'). Open
$row = (new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->one();
- 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 '130', column '27'). Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->exists(), 'The record was not removed from the database ID: ' . self::$id);
- 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 '\Settings_Roles_Record_Model' in method 'testDeleteRole'. Open
$recordModel = \Settings_Roles_Record_Model::getInstanceById(self::$id);
- 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 '\Settings_Roles_Record_Model' in method 'testAddRole'. Open
$parentRole = \Settings_Roles_Record_Model::getInstanceById('H2');
- 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 '\Settings_Roles_Record_Model' in method 'testDeleteRole'. Open
$transferToRole = \Settings_Roles_Record_Model::getInstanceById('H6');
- 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 '\Settings_Roles_Record_Model' in method 'testMoveRole'. Open
$parentRole = \Settings_Roles_Record_Model::getInstanceById('H1');
- 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 '\Settings_Roles_Record_Model' in method 'testMoveRole'. Open
$recordModel = \Settings_Roles_Record_Model::getInstanceById(self::$id);
- 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 '\Settings_Roles_Record_Model' in method 'testEditRole'. Open
$recordModel = \Settings_Roles_Record_Model::getInstanceById(self::$id);
- 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 "previewrelatedrecord" 4 times. Open
$recordModel->set('previewrelatedrecord', 0);
- 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 "changeowner" 4 times. Open
$recordModel->set('changeowner', 1);
- 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 "parentrole" 3 times. Open
$this->assertSame($row['parentrole'], 'H1::H2::' . self::$id);
- 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 "searchunpriv" 4 times. Open
$recordModel->set('searchunpriv', ['Contacts']);
- 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 "vtiger_role" 4 times. Open
$row = (new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->one();
- 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 "roleid" 4 times. Open
$row = (new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->one();
- 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 "listrelatedrecord" 4 times. Open
$recordModel->set('listrelatedrecord', 0);
- 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 "assignedmultiowner" 4 times. Open
$recordModel->set('assignedmultiowner', 1);
- 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 "allowassignedrecordsto" 4 times. Open
$recordModel->set('allowassignedrecordsto', 1);
- 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 "permissionsrelatedfield" 4 times. Open
$recordModel->set('permissionsrelatedfield', [0]);
- 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 "clendarallorecords" 6 times. Open
$recordModel->set('clendarallorecords', 1);
- 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 "rolename" 4 times. Open
$recordModel->set('rolename', 'Test');
- 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 "auto_assign" 4 times. Open
$recordModel->set('auto_assign', 1);
- 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 "editrelatedrecord" 4 times. Open
$recordModel->set('editrelatedrecord', 1);
- 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 "Contacts" 3 times. Open
$recordModel->set('searchunpriv', ['Contacts']);
- 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 "globalsearchadv" 4 times. Open
$recordModel->set('globalsearchadv', 1);
- 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::from
Open
$row = (new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->one();
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertNotFalse
Open
$this->assertNotFalse($row, 'No record id: ' . self::$id);
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['changeowner'], '1');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['allowassignedrecordsto'], '1');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['previewrelatedrecord'], '0');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertNotNull
Open
$this->assertNotNull($recordModel);
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame($row['rolename'], 'Test edit');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['auto_assign'], '0');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame($row['parentrole'], 'H1::H2::' . self::$id);
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['clendarallorecords'], '2');
- Exclude checks
Argument 1 (roleId)
is 'H6'
but \Settings_Roles_Record_Model::getInstanceById()
takes int
defined at /code/modules/Settings/Roles/models/Record.php:493
Open
$transferToRole = \Settings_Roles_Record_Model::getInstanceById('H6');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->exists(), 'The record was not removed from the database ID: ' . self::$id);
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame($row['permissionsrelatedfield'], '0,1');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertNotNull
Open
$this->assertNotNull($transferToRole);
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertNotNull
Open
$this->assertNotNull($parentRole);
- Exclude checks
Argument 1 (roleId)
is 'H1'
but \Settings_Roles_Record_Model::getInstanceById()
takes int
defined at /code/modules/Settings/Roles/models/Record.php:493
Open
$parentRole = \Settings_Roles_Record_Model::getInstanceById('H1');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame($row['parentrole'], 'H1::' . self::$id);
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['assignedmultiowner'], '4');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertNotNull
Open
$this->assertNotNull(self::$id);
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['clendarallorecords'], '1');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['assignedmultiowner'], '1');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$row = (new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->one();
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame($row['searchunpriv'], 'Contacts,Accounts');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertNotNull
Open
$this->assertNotNull($recordModel);
- Exclude checks
Argument 1 (roleId)
is 'H2'
but \Settings_Roles_Record_Model::getInstanceById()
takes int
defined at /code/modules/Settings/Roles/models/Record.php:493
Open
$parentRole = \Settings_Roles_Record_Model::getInstanceById('H2');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame($row['searchunpriv'], 'Contacts');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$row = (new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->one();
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['listrelatedrecord'], '1');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['editrelatedrecord'], '0');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertFalse
Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->exists(), 'The record was not removed from the database ID: ' . self::$id);
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['changeowner'], '0');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['listrelatedrecord'], '0');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['editrelatedrecord'], '1');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['globalsearchadv'], '1');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['previewrelatedrecord'], '1');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertNotFalse
Open
$this->assertNotFalse($row, 'No record id: ' . self::$id);
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['permissionsrelatedfield'], '0');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['auto_assign'], '1');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['allowassignedrecordsto'], '4');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame($row['parentrole'], 'H1::' . self::$id);
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame($row['rolename'], 'Test');
- Exclude checks
Call to undeclared method \Tests\Settings\Roles::assertSame
Open
$this->assertSame((string) $row['globalsearchadv'], '0');
- Exclude checks
Avoid variables with short names like $id. Configured minimum length is 3. Open
private static $id;
- 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
$recordModel->set('clendarallorecords', 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('auto_assign', 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotNull(self::$id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = (new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->one();
- 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
$recordModel->set('searchunpriv', ['Contacts', 'Accounts']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['previewrelatedrecord'], '1');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('searchunpriv', ['Contacts']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('editrelatedrecord', 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->setParent($parentRole);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('permissionsrelatedfield', [0]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['changeowner'], '1');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['auto_assign'], '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
$recordModel->set('previewrelatedrecord', 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['changeowner'], '0');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($row['searchunpriv'], 'Contacts,Accounts');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['clendarallorecords'], '2');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['clendarallorecords'], '1');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('clendarallorecords', 2);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['listrelatedrecord'], '1');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Role id.
- 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
$recordModel->set('rolename', 'Test');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($row['rolename'], 'Test');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['editrelatedrecord'], '1');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('globalsearchadv', 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotNull($parentRole);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['globalsearchadv'], '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
$this->assertSame($row['parentrole'], 'H1::' . self::$id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['globalsearchadv'], '0');
- 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
* Testing role creation.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('listrelatedrecord', 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['previewrelatedrecord'], '0');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = \Settings_Roles_Record_Model::getInstanceById(self::$id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->moveTo($parentRole);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = \Settings_Roles_Record_Model::getInstanceById(self::$id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('rolename', 'Test edit');
- 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
$recordModel->set('clendarallorecords', 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotNull($recordModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('listrelatedrecord', 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('assignedmultiowner', 4);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('auto_assign', 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = (new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->one();
- 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
$recordModel = new \Settings_Roles_Record_Model();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['listrelatedrecord'], '0');
- 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 testDeleteRole()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotNull($transferToRole);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentRole = \Settings_Roles_Record_Model::getInstanceById('H1');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($row['parentrole'], 'H1::' . self::$id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('allowassignedrecordsto', 4);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotFalse($row, 'No record id: ' . self::$id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing role deletion.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->delete($transferToRole);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('globalsearchadv', 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing move role.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->setParent($parentRole);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($row['rolename'], 'Test edit');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = \Settings_Roles_Record_Model::getInstanceById(self::$id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$transferToRole = \Settings_Roles_Record_Model::getInstanceById('H6');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentRole = \Settings_Roles_Record_Model::getInstanceById('H2');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('changeowner', 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testEditRole()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('changeowner', 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('clendarallorecords', 2);
- Exclude checks
Line exceeds 120 characters; contains 178 characters Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->exists(), 'The record was not removed from the database ID: ' . self::$id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('profileIds', ['1']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotFalse($row, 'No record id: ' . self::$id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($row['parentrole'], 'H1::H2::' . self::$id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['permissionsrelatedfield'], '0');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testMoveRole()
- 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
$recordModel->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['allowassignedrecordsto'], '4');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('previewrelatedrecord', 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['allowassignedrecordsto'], '1');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['assignedmultiowner'], '4');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['assignedmultiowner'], '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
$this->assertSame((string) $row['editrelatedrecord'], '0');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((string) $row['auto_assign'], '0');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $id;
- 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 testAddRole()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$id = $recordModel->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($row['searchunpriv'], 'Contacts');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing role edition.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('editrelatedrecord', 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($row['permissionsrelatedfield'], '0,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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->exists(), 'The record was not removed from the database ID: ' . self::$id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('allowassignedrecordsto', 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = (new \App\Db\Query())->from('vtiger_role')->where(['roleid' => self::$id])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('permissionsrelatedfield', [0, 1]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotNull($recordModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('assignedmultiowner', 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks