RTippin / messenger-demo

Laravel messenger demo app using rtippin/messenger. Private and group threads with real-time messaging, reactions, attachments, calling, chat bots, and more!
https://tippindev.com
151 stars 47 forks source link

Laravel Linter #1

Closed RTippin closed 4 years ago

RTippin commented 4 years ago

This pull request includes changes and recommendations for crafting your application "The Laravel Way". Feel free to commit any additional changes to the shift-21666 branch.

Before merging, you need to:

If you need help with your upgrade, check out the Human Shifts. You may also join the Shifty Coders Slack workspace to level-up your Laravel skills.

RTippin commented 4 years ago

:warning: Shift found uses of the old array() syntax. Laravel adopted the short array syntax [] since it became available in PHP 5.4.

RTippin commented 4 years ago

:warning: Shift found uses of the old array() syntax. Laravel adopted the short array syntax [] since it became available in PHP 5.4.

RTippin commented 4 years ago

:warning: Shift found instances of string based class references. Laravel adopted the ::class static property since it became available in PHP 5.5. You should update your code to use references like App\SomeModel::class instead of strings like 'App\SomeModel'.

RTippin commented 4 years ago

:warning: The following files reference Laravel facades through the global namespace. For example, you're referencing \DB or importing use DB. Instead import Illuminate\Support\Facades\DB and reference DB.

While global references are allowed through aliases, you should import the facade explicitly. This can improve clarity not only for developers, but static analysis used by your IDE.

RTippin commented 4 years ago

:warning: The following classes do not extend the standard Laravel Model and Controller class. This may add complexity which makes your application harder to upgrade. Often a trait can be used instead of inheritance. You should review the following classes:

RTippin commented 4 years ago

:warning: The following controllers contain actions outside of the 7 resource actions (index, create, store, show, edit, update, destroy). For more details, review the docs or watch Cruddy by Design to see if you can rework these into resource controllers.

RTippin commented 4 years ago

:warning: Shift found inline validation in the following controllers. Unless you require this level of control, you should use a Form Request to encapsulate this validation logic and keep your controller clean. You may automate this conversion with the Laravel Fixer.

RTippin commented 4 years ago

:warning: Shift found opportunities to use the built-in Blade directives like @auth in the following views:

RTippin commented 4 years ago

:warning: Laravel contains many built-in helpers functions which allow you to write more expressive code or leverage core functionality from anywhere in your app.

Shift found the following code which could use a helper instead:

RTippin commented 4 years ago

:warning: Shift found the following config files differ from the defaults. While you are welcome to customize your configuration, you should leverage ENV variables rather than hardcode values. If you find you're adding a lot of configuration options, consider creating a domain specific config file, such as core.php. Both will make app upgrades and deployments easier.

RTippin commented 4 years ago

:information_source: Shift detected your application only has the default tests. You can quickly start adding tests by using the Test Generator to automatically create the model factories, test classes, and sample tests cases for your Laravel application.

RTippin commented 4 years ago

:information_source: As noted, much of the lint detected above can be automatically fixed using the Laravel Fixer. Save yourself time and clean up your codebase quickly with this new Shift.