arborrow / montserrat

A retreat management application written in Laravel
12 stars 4 forks source link

Laravel Linter #495

Closed arborrow closed 2 years ago

arborrow commented 2 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-56662 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.

arborrow commented 2 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.

arborrow commented 2 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.

arborrow commented 2 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.

arborrow commented 2 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.

arborrow commented 2 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.

arborrow commented 2 years ago

:warning: Shift detected the following HTTP components accessing the authenticated user through Auth::user(). Within these components, you can access the authenticated user through the request object as well. Doing so limits your dependencies by leveraging objects already available.

arborrow commented 2 years ago

:warning: Shift detected direct Mail::send() calls. Laravel 5.4 introduced Mailables which better encapsulate the code for sending emails.

arborrow commented 2 years ago

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

arborrow commented 2 years ago

:warning: To improve performance by caching your configuration, Laravel recommends you only use the env() helper within configuration files and use config() everywhere else. Shift found potential uses of env() in:

arborrow commented 2 years ago

:information_source: Shift detected controller namespaces being set in your RouteServiceProvider. Laravel 8 began registering controllers using static class references instead of namespace prefixes and controller names.

You may automate this conversion using the Laravel Fixer or tasks within the Shift Workbench.

arborrow commented 2 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.

arborrow commented 2 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.