Call to undeclared method \Tests\Settings\ApiAddress::assertTrue
Open
$this->assertTrue($result, 'Error when saving global config var');
- Exclude checks
Call to undeclared method \Tests\Settings\ApiAddress::assertSame
Open
$this->assertSame((int) $result['global']['min_length'], $dataReference['min_length'], 'Global min_length config var is different from provided');
- Exclude checks
Call to undeclared method \Tests\Settings\ApiAddress::assertTrue
Open
$this->assertTrue($result, 'Error when setting global config var to default value');
- Exclude checks
Call to undeclared method \Tests\Settings\ApiAddress::assertSame
Open
$this->assertSame((int) $result['global']['result_num'], $dataReference['result_num'], 'Global result_num config var is different from provided');
- Exclude checks
Define a constant instead of duplicating this literal "global" 7 times. Open
['name' => 'min_length', 'type' => 'global', 'val' => 5],
- 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 "result_num" 5 times. Open
['name' => 'result_num', 'type' => 'global', 'val' => 15],
- 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 "min_length" 5 times. Open
['name' => 'min_length', 'type' => 'global', 'val' => 5],
- 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 "Settings:ApiAddress" 3 times. Open
$result = \Settings_ApiAddress_Module_Model::getInstance('Settings:ApiAddress')->setConfig([
- 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.
Spaces must be used to indent lines; tabs are not allowed Open
$dataReference = ['min_length' => 5, 'result_num' => 15];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((int) $result['global']['min_length'], $dataReference['min_length'], 'Global min_length config var is different from provided');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testSaveConfig()
- 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->assertTrue($result, 'Error when setting global config var to default value');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertTrue($result, 'Error when saving global config var');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = \Settings_ApiAddress_Module_Model::getInstance('Settings:ApiAddress')->getConfig('global');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Reset to default values.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['name' => 'result_num', 'type' => 'global', 'val' => 10],
- Exclude checks
Line exceeds 120 characters; contains 154 characters Open
$this->assertSame((int) $result['global']['min_length'], $dataReference['min_length'], 'Global min_length config var is different from provided');
- Exclude checks
Line exceeds 120 characters; contains 154 characters Open
$this->assertSame((int) $result['global']['result_num'], $dataReference['result_num'], 'Global result_num config var is different from provided');
- 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
['name' => 'min_length', 'type' => 'global', 'val' => 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
$this->assertSame((int) $result['global']['result_num'], $dataReference['result_num'], 'Global result_num config var is different from provided');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing global config getter.
- 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
$result = \Settings_ApiAddress_Module_Model::getInstance('Settings:ApiAddress')->setConfig([
- 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
['name' => 'min_length', 'type' => 'global', 'val' => 5],
- 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 testGetConfig()
- 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
$result = \Settings_ApiAddress_Module_Model::getInstance('Settings:ApiAddress')->setConfig([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing global config save.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['name' => 'result_num', 'type' => 'global', 'val' => 15],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testResetToDefault()
- 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