DarkaOnLine/L5-Swagger

View on GitHub

Showing 27 of 27 total issues

The class RoutesTest has 11 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

Since: PHPMD 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'.

Source: http://phpmd.org/rules/codesize.txt

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

    public function configDataProvider(): array
    {
        return [
            [
                [
Severity: Major
Found in tests/ConfigFactoryTest.php - About 2 hrs 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

    Since: PHPMD 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 $argumentsList[] ) { // VIOLATION - Formal
              $otherReallyLongName = -5; // VIOLATION - Local
              for ($interestingIntIndex = 0; // VIOLATION - For
                   $interestingIntIndex < 10;
                   $interestingIntIndex++ ) {
              }
          }
      }

    Source: http://phpmd.org/rules/naming.txt

    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

    Since: PHPMD 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 $argumentsList[] ) { // VIOLATION - Formal
              $otherReallyLongName = -5; // VIOLATION - Local
              for ($interestingIntIndex = 0; // VIOLATION - For
                   $interestingIntIndex < 10;
                   $interestingIntIndex++ ) {
              }
          }
      }

    Source: http://phpmd.org/rules/naming.txt

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

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

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

          public function docs(Request $request, string $file = null)
          {
              $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

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

          protected function copyAssets(): void
          {
              $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\Support\Facades\File' in method 'prepareDirectory'.
      Open

              if (File::exists($this->docDir) && ! is_writable($this->docDir)) {
      Severity: Minor
      Found in src/Generator.php by phpmd

      Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

      Avoid using static access to class '\Illuminate\Support\Facades\File' in method 'docs'.
      Open

              $content = File::get($filePath);

      Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

      Avoid using static access to class '\Illuminate\Support\Facades\Response' in method 'docs'.
      Open

              return ResponseFacade::make($content, 200, [
                  'Content-Type' => 'application/json',
              ]);

      Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

      Avoid using static access to class '\Illuminate\Support\Facades\File' in method 'oauth2Callback'.
      Open

              return File::get(swagger_ui_dist_path($documentation, 'oauth2-redirect.html'));

      Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

      Avoid using static access to class '\Illuminate\Support\Facades\File' in method 'prepareDirectory'.
      Open

                  File::makeDirectory($this->docDir);
      Severity: Minor
      Found in src/Generator.php by phpmd

      Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

      Avoid using static access to class '\Illuminate\Support\Facades\Response' in method 'docs'.
      Open

                  return ResponseFacade::make($content, 200, [
                      'Content-Type' => 'application/yaml',
                      'Content-Disposition' => 'inline',
                  ]);

      Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

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

                  Request::setTrustedProxies($proxy, Request::HEADER_X_FORWARDED_ALL);

      Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

      Avoid using static access to class '\Illuminate\Support\Facades\File' in method 'prepareDirectory'.
      Open

              if (! File::exists($this->docDir)) {
      Severity: Minor
      Found in src/Generator.php by phpmd

      Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

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

      }
      Severity: Minor
      Found in tests/GeneratorTest.php by phpmd

      Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

      Avoid using static access to class '\Illuminate\Support\Facades\Response' in method 'api'.
      Open

              return ResponseFacade::make(
                  view('l5-swagger::index', [
                      'documentation' => $documentation,
                      'secure' => RequestFacade::secure(),
                      'urlToDocs' => $urlToDocs,

      Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

      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

      Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

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

                      'secure' => RequestFacade::secure(),

      Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

      Avoid using static access to class '\Illuminate\Support\Facades\Log' in method 'docs'.
      Open

                      Log::error($e);

      Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

      Severity
      Category
      Status
      Source
      Language