DarkaOnLine/SwaggerLume

View on GitHub
src/Http/Controllers/SwaggerLumeController.php

Summary

Maintainability
A
2 hrs
Test Coverage
D
69%

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

    public function docs()
    {
        $filePath = sprintf(
            '%s/%s',
            config('swagger-lume.paths.docs'),
Severity: Minor
Found in src/Http/Controllers/SwaggerLumeController.php - About 1 hr to fix

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

        public function docs()
        {
            $filePath = sprintf(
                '%s/%s',
                config('swagger-lume.paths.docs'),
    Severity: Minor
    Found in src/Http/Controllers/SwaggerLumeController.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

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

                    Log::error($e);

    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\File' in method 'docs'.
    Open

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

    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 '\SwaggerLume\Generator' in method 'api'.
    Open

                Generator::generateDocs();

    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\File' in method 'oauth2Callback'.
    Open

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

    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\Request' in method 'api'.
    Open

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

    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 '\SwaggerLume\Generator' in method 'docs'.
    Open

                    Generator::generateDocs();

    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\File' in method 'docs'.
    Open

            if (config('swagger-lume.generate_always') && ! File::exists($filePath)) {

    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\File' in method 'docs'.
    Open

            if (! File::exists($filePath)) {

    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

    Line exceeds 120 characters; contains 156 characters
    Open

                config('swagger-lume.paths.format_to_use_for_docs') === 'json' ? config('swagger-lume.paths.docs_json') : config('swagger-lume.paths.docs_yaml')

    Line exceeds 120 characters; contains 124 characters
    Open

                            'Unable to generate documentation file to: "%s". Please make sure directory is writable. Error: %s',

    There are no issues that match your filters.

    Category
    Status