Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel Linter #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Laravel Linter #20

wants to merge 1 commit into from

Conversation

Alanaktion
Copy link
Owner

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

Before merging, you need to:

  • Checkout the shift-59695 branch
  • Review all pull request comments for additional changes
  • Thoroughly test your application

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.

@Alanaktion
Copy link
Owner Author

⚠️ 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.

  • app/Http/Controllers/AdminController.php
  • app/Http/Controllers/ChannelController.php
  • app/Http/Controllers/FavoritesController.php
  • app/Http/Controllers/HomeController.php
  • app/Http/Controllers/ImageController.php
  • app/Http/Controllers/MetaController.php
  • app/Http/Controllers/PlaylistController.php
  • app/Http/Controllers/UserController.php
  • app/Http/Controllers/VideoController.php

@Alanaktion
Copy link
Owner Author

⚠️ 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.

  • app/Http/Controllers/AdminController.php
  • app/Http/Controllers/ChannelController.php
  • app/Http/Controllers/FavoritesController.php
  • app/Http/Controllers/PlaylistController.php
  • app/Http/Controllers/UserController.php
  • app/Http/Controllers/VideoController.php

@Alanaktion
Copy link
Owner Author

⚠️ 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.

  • app/Http/Controllers/FavoritesController.php
  • app/Http/Controllers/UserController.php

@Alanaktion
Copy link
Owner Author

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

  • resources/views/playlists/show.blade.php

@Alanaktion
Copy link
Owner Author

ℹ️ 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.

@Alanaktion
Copy link
Owner Author

⚠️ 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.

  • config/app.php
  • config/database.php
  • config/services.php

@Alanaktion
Copy link
Owner Author

⚠️ Laravel uses PSR-4 autoloading for the app/ folder. While you can configure your application to load these files within composer.json, all files under the app folder should be classes with a PSR-4 compliant namespace.

The following PHP files are missing a namespace:

  • app/helpers.php

@Alanaktion
Copy link
Owner Author

ℹ️ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants