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

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

Laravel Linter #29

wants to merge 1 commit into from

Conversation

bahdcoder
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-23857 branch.

Before merging, you need to:

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

@bahdcoder
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'.

@bahdcoder
Copy link
Owner Author

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

  • app/Http/Controllers/Servers/UfwController.php
  • app/Jobs/Servers/DeleteFirewallRule.php
  • app/Jobs/Servers/Initialize.php
  • app/Notifications/Servers/Alert.php
  • app/Notifications/Servers/DatabasesUpdated.php
  • app/Notifications/Servers/ServerProvisioned.php
  • app/Notifications/Sites/DeploymentFailed.php
  • app/Server.php

@bahdcoder
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/Activity.php
  • app/BalancedServer.php
  • app/Daemon.php
  • app/Database.php
  • app/DatabaseUser.php
  • app/FirewallRule.php
  • app/FriendServer.php
  • app/Job.php
  • app/Model.php
  • app/Pm2Process.php
  • app/Server.php
  • app/Site.php
  • app/Sshkey.php
  • app/Subscription.php
  • app/Team.php
  • app/TeamInvite.php

@bahdcoder
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/Auth/LogoutController.php
  • app/Http/Controllers/Auth/SocialiteController.php
  • app/Http/Controllers/Auth/UserController.php
  • app/Http/Controllers/FileController.php
  • app/Http/Controllers/NginxController.php
  • app/Http/Controllers/NotificationsController.php
  • app/Http/Controllers/Servers/AwsController.php
  • app/Http/Controllers/Servers/CreateServersController.php
  • app/Http/Controllers/Servers/CronJobController.php
  • app/Http/Controllers/Servers/CustomServerController.php
  • app/Http/Controllers/Servers/DaemonController.php
  • app/Http/Controllers/Servers/DigitalOceanController.php
  • app/Http/Controllers/Servers/FileContentController.php
  • app/Http/Controllers/Servers/GetServerController.php
  • app/Http/Controllers/Servers/GetServersController.php
  • app/Http/Controllers/Servers/InitializationCallbackController.php
  • app/Http/Controllers/Servers/MongodbController.php
  • app/Http/Controllers/Servers/RegionAndSizeController.php
  • app/Http/Controllers/Settings/ServerProvidersController.php
  • app/Http/Controllers/Settings/SourceControlProvidersController.php
  • app/Http/Controllers/Sites/DeploymentController.php
  • app/Http/Controllers/Sites/GhostController.php
  • app/Http/Controllers/Sites/PushToDeployController.php
  • app/Http/Controllers/Sites/SslCertificateController.php
  • app/Http/Controllers/SourceControl/GithubController.php
  • app/Http/Controllers/Ssl/FileController.php
  • app/Http/Controllers/Users/TeamController.php

@bahdcoder
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/Auth/ResetPasswordController.php
  • app/Http/Controllers/NginxController.php
  • app/Http/Controllers/Pm2Controller.php

@bahdcoder
Copy link
Owner Author

bahdcoder commented Mar 3, 2020

⚠️ 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/auth.php
  • config/broadcasting.php
  • config/cache.php
  • config/database.php
  • config/filesystems.php
  • config/hashing.php
  • config/logging.php
  • config/mail.php
  • config/queue.php
  • config/services.php
  • config/session.php
  • config/view.php

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