Missing class import via use statement (line '35', column '25'). Open
self::$instance = new \App\ConfigFile('component', 'YetiForce');
- 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\Config' in method 'testSave'. Open
$this->assertNotSame($previousValue, \App\Config::component('YetiForce', $flagName, false));
- 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 'testSave'. Open
$previousValue = \App\Config::component('YetiForce', $flagName, false);
- 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 "YetiForce" 3 times. Open
self::$instance = new \App\ConfigFile('component', 'YetiForce');
- 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.
Assigning false
to property but \Tests\App\Configurator::$instance
is \App\ConfigFile
Open
public static $instance = false;
- Exclude checks
Call to undeclared method \Tests\App\Configurator::assertInstanceOf
Open
$this->assertInstanceOf('\App\ConfigFile', self::$instance);
- Exclude checks
Call to undeclared method \Tests\App\Configurator::assertNotSame
Open
$this->assertNotSame($previousValue, \App\Config::component('YetiForce', $flagName, false));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertInstanceOf('\App\ConfigFile', self::$instance);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$instance->create();
- 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 $instance = 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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing constructor method.
- 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
* @throws \App\Exceptions\AppException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$instance->set($flagName, !$previousValue);
- 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 testInstance()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$previousValue = \App\Config::component('YetiForce', $flagName, false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- 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
* @throws \ReflectionException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$instance = new \App\ConfigFile('component', 'YetiForce');
- 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
* @var \App\ConfigFile
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotSame($previousValue, \App\Config::component('YetiForce', $flagName, false));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$flagName = \array_search('bool', \App\YetiForce\Watchdog::$variables);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Instance container.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testSave()
- 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
* @throws \App\Exceptions\IllegalValue
- 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
* Testing set and save methods.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks