DarkaOnLine/L5-Swagger

View on GitHub

Showing 36 of 36 total issues

The class RoutesTest has 15 public methods. Consider refactoring RoutesTest to keep number of public methods under 10.
Open

class RoutesTest extends TestCase
{
    /** @test */
    public function userCantAccessJsonFileIfItIsNotGenerated(): void
    {
Severity: Minor
Found in tests/RoutesTest.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

Method configDataProvider has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function configDataProvider(): array
    {
        return [
            [
                [
Severity: Major
Found in tests/ConfigFactoryTest.php - About 2 hrs to fix

    Method docs has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function docs(Request $request)
        {
            $fileSystem = new Filesystem();
            $documentation = $request->offsetGet('documentation');
            $config = $request->offsetGet('config');
    Severity: Minor
    Found in src/Http/Controllers/SwaggerController.php - About 1 hr to fix

      Avoid excessively long variable names like $securitySchemesConfig. Keep variable name length under 20.
      Open

          protected $securitySchemesConfig;
      Severity: Minor
      Found in src/SecurityDefinitions.php by phpmd

      LongVariable

      Since: 0.2

      Detects when a field, formal or local variable is declared with a long name.

      Example

      class Something {
          protected $reallyLongIntName = -3; // VIOLATION - Field
          public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
              $otherReallyLongName = -5; // VIOLATION - Local
              for ($interestingIntIndex = 0; // VIOLATION - For
                   $interestingIntIndex < 10;
                   $interestingIntIndex++ ) {
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#longvariable

      Avoid excessively long class names like L5SwaggerAnnotationsExampleSecurityScheme. Keep class name length under 40.
      Open

      class L5SwaggerAnnotationsExampleSecurityScheme
      {
      }

      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

      Avoid excessively long variable names like $securitySchemesConfig. Keep variable name length under 20.
      Open

          public function __construct(array $securitySchemesConfig = [], array $securityConfig = [])
      Severity: Minor
      Found in src/SecurityDefinitions.php by phpmd

      LongVariable

      Since: 0.2

      Detects when a field, formal or local variable is declared with a long name.

      Example

      class Something {
          protected $reallyLongIntName = -3; // VIOLATION - Field
          public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
              $otherReallyLongName = -5; // VIOLATION - Local
              for ($interestingIntIndex = 0; // VIOLATION - For
                   $interestingIntIndex < 10;
                   $interestingIntIndex++ ) {
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#longvariable

      Method api has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function api(Request $request)
          {
              $documentation = $request->offsetGet('documentation');
              $config = $request->offsetGet('config');
      
      
      Severity: Minor
      Found in src/Http/Controllers/SwaggerController.php - About 1 hr to fix

        Method canGenerateWithScanOptions has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function canGenerateWithScanOptions(): void
            {
                $cfg = config('l5-swagger.documentations.default');
        
                $cfg['scanOptions']['exclude'] = [
        Severity: Minor
        Found in tests/GeneratorTest.php - About 1 hr to fix

          Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  array $paths,
                  array $constants,
                  bool $yamlCopyRequired,
                  SecurityDefinitions $security,
                  array $scanOptions,
          Severity: Minor
          Found in src/Generator.php - About 45 mins to fix

            Function docs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function docs(Request $request)
                {
                    $fileSystem = new Filesystem();
                    $documentation = $request->offsetGet('documentation');
                    $config = $request->offsetGet('config');
            Severity: Minor
            Found in src/Http/Controllers/SwaggerController.php - About 45 mins 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

            The class Generator has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
            Open

            class Generator
            {
                public const OPEN_API_DEFAULT_SPEC_VERSION = '3.0.0';
            
                protected const SCAN_OPTION_PROCESSORS = 'processors';
            Severity: Minor
            Found in src/Generator.php by phpmd

            CouplingBetweenObjects

            Since: 1.1.0

            A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

            Example

            class Foo {
                /**
                 * @var \foo\bar\X
                 */
                private $x = null;
            
                /**
                 * @var \foo\bar\Y
                 */
                private $y = null;
            
                /**
                 * @var \foo\bar\Z
                 */
                private $z = null;
            
                public function setFoo(\Foo $foo) {}
                public function setBar(\Bar $bar) {}
                public function setBaz(\Baz $baz) {}
            
                /**
                 * @return \SplObjectStorage
                 * @throws \OutOfRangeException
                 * @throws \InvalidArgumentException
                 * @throws \ErrorException
                 */
                public function process(\Iterator $it) {}
            
                // ...
            }

            Source https://phpmd.org/rules/design.html#couplingbetweenobjects

            Function setProcessors has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function setProcessors(OpenApiGenerator $generator): void
                {
                    $processorClasses = Arr::get($this->scanOptions, self::SCAN_OPTION_PROCESSORS, []);
                    $processors = [];
            
            
            Severity: Minor
            Found in src/Generator.php - About 35 mins 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

            Missing class import via use statement (line '32', column '34').
            Open

                            ->setExpires(new \DateTime('+1 year'));

            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 '233', column '104').
            Open

                    $mockGenerator->expects($this->once())->method('generateDocs')->will($this->throwException(new \Exception));
            Severity: Minor
            Found in tests/RoutesTest.php by phpmd

            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

            Function copyAssets has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function copyAssets(): void
                {
                    $fileSystem = new Filesystem();
                    $src = __DIR__.'/../vendor/swagger-api/swagger-ui/dist/';
                    $destination = __DIR__.'/../vendor/orchestra/testbench-core/laravel/vendor/swagger-api/swagger-ui/dist/';
            Severity: Minor
            Found in tests/TestCase.php - About 25 mins 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

            Avoid using static access to class '\Illuminate\Http\Request' in method 'api'.
            Open

                        Request::setTrustedProxies(
                            $proxy,
                            Request::HEADER_X_FORWARDED_FOR |
                            Request::HEADER_X_FORWARDED_HOST |
                            Request::HEADER_X_FORWARDED_PORT |

            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 '\Illuminate\Support\Arr' in method 'createScanFinder'.
            Open

                    $pattern = Arr::get($this->scanOptions, self::SCAN_OPTION_PATTERN);
            Severity: Minor
            Found in src/Generator.php by phpmd

            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 '\Illuminate\Support\Arr' in method 'setAnalyser'.
            Open

                    $analyser = Arr::get($this->scanOptions, self::SCAN_OPTION_ANALYSER);
            Severity: Minor
            Found in src/Generator.php by phpmd

            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 '\Illuminate\Support\Facades\Artisan' in method 'canGenerate'.
            Open

                    Artisan::call($artisanCommand);
            Severity: Minor
            Found in tests/ConsoleTest.php by phpmd

            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 '\Illuminate\Support\Arr' in method 'scanFilesForDocumentation'.
            Open

                    $analysis = Arr::get($this->scanOptions, self::SCAN_OPTION_ANALYSIS);
            Severity: Minor
            Found in src/Generator.php by phpmd

            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

            Severity
            Category
            Status
            Source
            Language