Showing 252 of 252 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
declare(strict_types=1);
namespace K911\Swoole\Bridge\Symfony\Bundle\Command;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 215.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
declare(strict_types=1);
namespace K911\Swoole\Bridge\Symfony\Bundle\Command;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 215.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
HttpServerConfiguration
has 34 functions (exceeds 20 allowed). Consider refactoring. Open
class HttpServerConfiguration
{
private const SWOOLE_HTTP_SERVER_CONFIG_DAEMONIZE = 'daemonize';
private const SWOOLE_HTTP_SERVER_CONFIG_SERVE_STATIC = 'serve_static';
private const SWOOLE_HTTP_SERVER_CONFIG_REACTOR_COUNT = 'reactor_count';
File ContainerModifier.php
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace K911\Swoole\Bridge\Symfony\Container;
File HttpServerConfiguration.php
has 306 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace K911\Swoole\Server;
The class HttpServerConfiguration has an overall complexity of 67 which is very high. The configured complexity threshold is 50. Open
class HttpServerConfiguration
{
private const SWOOLE_HTTP_SERVER_CONFIG_DAEMONIZE = 'daemonize';
private const SWOOLE_HTTP_SERVER_CONFIG_SERVE_STATIC = 'serve_static';
private const SWOOLE_HTTP_SERVER_CONFIG_REACTOR_COUNT = 'reactor_count';
- Exclude checks
Method validateSetting
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function validateSetting(string $key, mixed $value): void
{
Assertion::keyExists(self::SWOOLE_HTTP_SERVER_CONFIGURATION, $key, 'There is no configuration mapping for setting "%s".');
switch ($key) {
Method generateOverriddenDoInExtension
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function generateOverriddenDoInExtension(
Filesystem $fs,
string $containerDir,
string $fileToLoad,
string $class,
Method overrideGeneratedContainer
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function overrideGeneratedContainer(ReflectionClass $reflContainer, string $cacheDir, bool $isDebug): void
{
$fs = new Filesystem();
$containerFqcn = $reflContainer->getName();
$overriddenFqcn = $containerFqcn.'_Overridden';
Function process
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function process(ContainerBuilder $container, Proxifier $proxifier): void
{
$resetterDefId = 'swoole_bundle.coroutines_support.cache_adapter_resetter';
$resetterDef = new Definition(SimpleResetter::class);
$resetterDef->setArguments(['reset']);
- 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
Method newInstance
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function newInstance(
object $instance,
array $factoryConfigs,
int $globalInstancesLimit
): object {
Avoid excessively long class names like BlockingProxyFactoryOverridingManagerConfigurator. Keep class name length under 40. Open
final class BlockingProxyFactoryOverridingManagerConfigurator
{
private static ?\ReflectionProperty $emProxyFactoryPropRefl = null;
public function __construct(
- Read upRead up
- Exclude checks
LongClassName
Since: 2.9
Detects when classes or interfaces are declared with excessively long names.
Example
class ATooLongClassNameThatHintsAtADesignProblem {
}
interface ATooLongInterfaceNameThatHintsAtADesignProblem {
}
Source https://phpmd.org/rules/naming.html#longclassname
Function validateSetting
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function validateSetting(string $key, mixed $value): void
{
Assertion::keyExists(self::SWOOLE_HTTP_SERVER_CONFIGURATION, $key, 'There is no configuration mapping for setting "%s".');
switch ($key) {
- 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
Method generate
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator): void
{
CanProxyAssertion::assertClassCanBeProxied($originalClass);
$interfaces = [
Method generateLazyGetter
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function generateLazyGetter(string $methodName, array $internals): string
{
$sharedCheck = PHP_EOL;
if (!empty($internals)) {
Avoid using undefined variables such as '$runtimeConfiguration' which will lead to PHP notices. Open
$runtimeConfiguration['trustedProxies'] = \array_filter($runtimeConfiguration['trustedProxies'], fn (string $trustedProxy): bool => '*' !== $trustedProxy);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$runtimeConfiguration' which will lead to PHP notices. Open
$runtimeConfiguration['trustedProxies'] = \array_filter($runtimeConfiguration['trustedProxies'], fn (string $trustedProxy): bool => '*' !== $trustedProxy);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$runtimeConfiguration' which will lead to PHP notices. Open
$runtimeConfiguration['trustAllProxies'] = true;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$runtimeConfiguration' which will lead to PHP notices. Open
$runtimeConfiguration['trustedHosts'] = $this->decodeSet($trustedHosts);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$this' which will lead to PHP notices. Open
return \Closure::bind(fn &(string $propertyName) => $this->$propertyName, $obj, $scope ?? $obj)($propertyName);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}