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 #53

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

Laravel Linter #53

wants to merge 1 commit into from

Conversation

clarkewing
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-37550 branch.

Before merging, you need to:

  • Checkout the shift-37550 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.

@clarkewing
Copy link
Owner Author

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

@clarkewing
Copy link
Owner Author

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

  • app/Models/Profile.php

@clarkewing
Copy link
Owner Author

⚠️ Shift detected Eloquent calls in the following views. You should keep views from interacting directly with your models by passing the necessary data from the controller.

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

@clarkewing
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/PostsController.php

@clarkewing
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/AccountInfoController.php
  • app/Http/Controllers/Api/TagsController.php
  • app/Http/Controllers/Api/UserAvatarController.php
  • app/Http/Controllers/AttachmentsController.php
  • app/Http/Controllers/CompaniesController.php
  • app/Http/Controllers/PaymentMethodsController.php
  • app/Http/Controllers/PollVotesController.php
  • app/Http/Controllers/PostsController.php
  • app/Http/Controllers/ProfilesController.php
  • app/Http/Controllers/SubscriptionController.php
  • app/Http/Controllers/ThreadsController.php

@clarkewing
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/AccountInfoController.php
  • app/Http/Controllers/PaymentMethodsController.php
  • app/Http/Controllers/SubscriptionController.php
  • app/Http/Controllers/ThreadsController.php
  • app/Http/Controllers/UserNotificationsController.php

@clarkewing
Copy link
Owner Author

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

  • resources/views/layouts/app.blade.php

@clarkewing
Copy link
Owner Author

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

  • Response::json()
  • Response::make()
  • Response::view()

@clarkewing
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/filesystems.php

@clarkewing
Copy link
Owner Author

ℹ️ Your Laravel application contains 253 classes and 24,469 lines of code.

Most of your classes are controllers. Your models contain the most lines of code (2,141 loc) and your middleware have the highest lines of code per method (6 loc).

@clarkewing
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