DarkaOnLine/SwaggerLume

View on GitHub

Showing 34 of 34 total issues

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 'generateDocs'.
Open

                File::deleteDirectory($docDir);
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\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

The method publishDirectory uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $dir = opendir($source);

            if (! is_dir($destination)) {
                if (! mkdir($destination, 0755, true)) {
Severity: Minor
Found in src/Console/Helpers/Publisher.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

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

Avoid using static access to class '\SwaggerLume\Generator' in method 'handle'.
Open

        Generator::generateDocs();
Severity: Minor
Found in src/Console/GenerateDocsCommand.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 unused parameters such as '$route'.
Open

        $this->app->router->group(['namespace' => 'SwaggerLume'], function ($route) {
Severity: Minor
Found in src/ServiceProvider.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Only one argument is allowed per line in a multi-line function call
Open

            file_get_contents($path), 200, [

Only one argument is allowed per line in a multi-line function call
Open

            file_get_contents($path), 200, [

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

Line exceeds 120 characters; contains 147 characters
Open

        return route('swagger-lume.asset', ['asset' => $asset, 'v' => md5($file)], config('swagger-lume.force_https')) ?? app('request')->secure();
Severity: Minor
Found in src/helpers.php by phpcodesniffer

The variable $allowed_files is not named in camelCase.
Open

    function swagger_ui_dist_path($asset = null)
    {
        $allowed_files = [
            'favicon-16x16.png',
            'favicon-32x32.png',
Severity: Minor
Found in src/helpers.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $allowed_files is not named in camelCase.
Open

    function swagger_ui_dist_path($asset = null)
    {
        $allowed_files = [
            'favicon-16x16.png',
            'favicon-32x32.png',
Severity: Minor
Found in src/helpers.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

Severity
Category
Status
Source
Language