Strimoid/Strimoid

View on GitHub
app/Providers/ValidatorServiceProvider.php

Summary

Maintainability
B
4 hrs
Test Coverage

Method boot has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function boot(): void
    {
        Validator::extend('unique_email', function ($attribute, $value, $parameters) {
            if (isset($parameters[1])) {
                $attribute = $parameters[1];
Severity: Major
Found in app/Providers/ValidatorServiceProvider.php - About 3 hrs to fix

    Avoid too many return statements within this method.
    Open

                return !in_array($value, $names);
    Severity: Major
    Found in app/Providers/ValidatorServiceProvider.php - About 30 mins to fix

      The method boot() has 131 lines of code. Current threshold is set to 100. Avoid really long methods.
      Open

          public function boot(): void
          {
              Validator::extend('unique_email', function ($attribute, $value, $parameters) {
                  if (isset($parameters[1])) {
                      $attribute = $parameters[1];

      Avoid using static access to class '\Illuminate\Support\Facades\Validator' in method 'boot'.
      Open

              Validator::extend('strong_password', function ($attribute, $value, $parameters) {
                  $easyPasswords = [
                      '111111', '121212', '123456', 'qwerty', 'polska', 'zaq12wsx', '111111', 'aaaaaa', 'matrix', 'monika', 'marcin',
                      'misiek', 'master', 'abc123', 'qwerty1', 'qazwsx', 'mateusz', 'strims', 'strimoid', 'qwe123', 'zzzzzz',
                  ];

      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\Validator' in method 'boot'.
      Open

              Validator::extend('user_password', fn ($attribute, $value, $parameters) => Hash::check($value, Auth::user()->password));

      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\Validator' in method 'boot'.
      Open

              Validator::extend('unique_email', function ($attribute, $value, $parameters) {
                  if (isset($parameters[1])) {
                      $attribute = $parameters[1];
                  }
      
      

      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\Hash' in method 'boot'.
      Open

              Validator::extend('user_password', fn ($attribute, $value, $parameters) => Hash::check($value, Auth::user()->password));

      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\Validator' in method 'boot'.
      Open

              Validator::extend('real_email', function ($attribute, $value, $parameters) {
                  $blockedDomains = [
      
                      // normal mail mail providers (used to spam)
      
      

      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\Validator' in method 'boot'.
      Open

              Validator::extend('reserved_groupnames', function ($attribute, $value, $parameters) {
                  $names = [
                      'subscribed', 'moderated', 'blocked', 'random', 'all', 'observed', 'saved',
                      'subskrybowane', 'moderowane', 'zablokowane', 'blokowane', 'losowa', 'losowe',
                      'wszystko', 'wszystkie', 'obserwowani', 'obserwowane', 'zapisane', 'folder',

      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\Validator' in method 'boot'.
      Open

              Validator::extend('safe_url', fn ($attribute, $value, $parameters) => Str::startsWith($value, 'http'));

      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\Str' in method 'boot'.
      Open

              Validator::extend('safe_url', fn ($attribute, $value, $parameters) => Str::startsWith($value, 'http'));

      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\Validator' in method 'boot'.
      Open

              Validator::extend('url_custom', fn ($attribute, $value, $parameters) => preg_match('@^https?://[^\s/$.?#].[^\s]*$@iS', (string) $value));

      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\Str' in method 'boot'.
      Open

                  $parts = explode('.', Str::lower($domain[1]));

      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

      There are no issues that match your filters.

      Category
      Status