EscolaLMS/Consultations

View on GitHub
database/seeders/ConsultationsPermissionSeeder.php

Summary

Maintainability
A
1 hr
Test Coverage

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

    public function run()
    {
        // create permissions
        $admin = Role::findOrCreate(UserRole::ADMIN, 'api');
        $tutor = Role::findOrCreate(UserRole::TUTOR, 'api');
Severity: Minor
Found in database/seeders/ConsultationsPermissionSeeder.php - About 1 hr to fix

    Avoid using static access to class '\Spatie\Permission\Models\Permission' in method 'run'.
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_UPDATE_OWN, 'api');

    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 '\Spatie\Permission\Models\Permission' in method 'run'.
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_READ, 'api');

    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 '\Spatie\Permission\Models\Permission' in method 'run'.
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_LIST_OWN, 'api');

    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 '\Spatie\Permission\Models\Permission' in method 'run'.
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_DELETE, 'api');

    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 '\Spatie\Permission\Models\Permission' in method 'run'.
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_CHANGE_TERM, 'api');

    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 '\Spatie\Permission\Models\Role' in method 'run'.
    Open

            $admin = Role::findOrCreate(UserRole::ADMIN, 'api');

    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 '\Spatie\Permission\Models\Permission' in method 'run'.
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_UPDATE, 'api');

    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 '\Spatie\Permission\Models\Permission' in method 'run'.
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_CREATE, 'api');

    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 '\Spatie\Permission\Models\Permission' in method 'run'.
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_READ_OWN, 'api');

    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 '\Spatie\Permission\Models\Role' in method 'run'.
    Open

            $tutor = Role::findOrCreate(UserRole::TUTOR, 'api');

    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 '\Spatie\Permission\Models\Permission' in method 'run'.
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_LIST, 'api');

    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 '\Spatie\Permission\Models\Permission' in method 'run'.
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_DELETE_OWN, 'api');

    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

    Reference to constant ADMIN from undeclared class \EscolaLms\Core\Enums\UserRole
    Open

            $admin = Role::findOrCreate(UserRole::ADMIN, 'api');

    Call to method findOrCreate from undeclared class \Spatie\Permission\Models\Permission
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_UPDATE_OWN, 'api');

    Class extends undeclared class \Illuminate\Database\Seeder
    Open

    class ConsultationsPermissionSeeder extends Seeder

    Call to method findOrCreate from undeclared class \Spatie\Permission\Models\Permission
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_DELETE_OWN, 'api');

    Reference to constant TUTOR from undeclared class \EscolaLms\Core\Enums\UserRole
    Open

            $tutor = Role::findOrCreate(UserRole::TUTOR, 'api');

    Call to method findOrCreate from undeclared class \Spatie\Permission\Models\Permission
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_LIST, 'api');

    Call to method findOrCreate from undeclared class \Spatie\Permission\Models\Permission
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_UPDATE, 'api');

    Call to method findOrCreate from undeclared class \Spatie\Permission\Models\Role
    Open

            $admin = Role::findOrCreate(UserRole::ADMIN, 'api');

    Call to method findOrCreate from undeclared class \Spatie\Permission\Models\Permission
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_LIST_OWN, 'api');

    Call to method findOrCreate from undeclared class \Spatie\Permission\Models\Permission
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_DELETE, 'api');

    Call to method findOrCreate from undeclared class \Spatie\Permission\Models\Permission
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_READ_OWN, 'api');

    Call to method findOrCreate from undeclared class \Spatie\Permission\Models\Role
    Open

            $tutor = Role::findOrCreate(UserRole::TUTOR, 'api');

    Call to method findOrCreate from undeclared class \Spatie\Permission\Models\Permission
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_CREATE, 'api');

    Call to method findOrCreate from undeclared class \Spatie\Permission\Models\Permission
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_READ, 'api');

    Call to method findOrCreate from undeclared class \Spatie\Permission\Models\Permission
    Open

            Permission::findOrCreate(ConsultationsPermissionsEnum::CONSULTATION_CHANGE_TERM, 'api');

    There are no issues that match your filters.

    Category
    Status