pixelfederation/swoole-bundle

View on GitHub

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;
Severity: Major
Found in src/Bridge/Symfony/Bundle/Command/ServerStopCommand.php and 1 other location - About 6 hrs to fix
src/Bridge/Symfony/Bundle/Command/ServerReloadCommand.php on lines 1..64

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace K911\Swoole\Bridge\Symfony\Bundle\Command;
Severity: Major
Found in src/Bridge/Symfony/Bundle/Command/ServerReloadCommand.php and 1 other location - About 6 hrs to fix
src/Bridge/Symfony/Bundle/Command/ServerStopCommand.php on lines 1..64

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

Further Reading

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';
Severity: Minor
Found in src/Server/HttpServerConfiguration.php - About 4 hrs to fix

    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;
    Severity: Minor
    Found in src/Bridge/Symfony/Container/ContainerModifier.php - About 3 hrs to fix

      File HttpServerConfiguration.php has 306 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      declare(strict_types=1);
      
      namespace K911\Swoole\Server;
      Severity: Minor
      Found in src/Server/HttpServerConfiguration.php - About 3 hrs to fix

        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';

        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) {
        Severity: Major
        Found in src/Server/HttpServerConfiguration.php - About 2 hrs to fix

          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,
          Severity: Major
          Found in src/Bridge/Symfony/Container/ContainerModifier.php - About 2 hrs to fix

            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';
            Severity: Minor
            Found in src/Bridge/Symfony/Container/ContainerModifier.php - About 1 hr to fix

              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']);
              Severity: Minor
              Found in src/Bridge/Symfony/Cache/CacheAdapterProcessor.php - About 1 hr to fix

              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 {
              Severity: Minor
              Found in src/Bridge/Symfony/Container/Proxy/UnmanagedFactoryInstantiator.php - About 1 hr to fix

                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(

                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) {
                Severity: Minor
                Found in src/Server/HttpServerConfiguration.php - About 1 hr to fix

                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)) {
                  Severity: Minor
                  Found in src/Bridge/Symfony/Container/ContainerModifier.php - About 1 hr to fix

                    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);

                    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);

                    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;

                    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);

                    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);
                    Severity: Minor
                    Found in src/functions.php by phpmd

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language