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

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

Laravel Linter #11

wants to merge 1 commit into from

Conversation

yolanmees
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-55818 branch.

Before merging, you need to:

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

@yolanmees
Copy link
Owner Author

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

1 similar comment
@yolanmees
Copy link
Owner Author

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

@yolanmees
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/Console/Commands/runWorkflows.php
  • app/Console/Commands/testCommand.php
  • app/Console/CreateWorkflowController.php
  • app/Console/Kernel.php
  • app/Http/Controllers/CreateWorkflowController.php
  • app/Http/Controllers/PostColController.php
  • app/Http/Controllers/SearchController.php
  • app/classes/GetApps.php
  • app/classes/Steps.php
  • app/classes/StepsHelper.php
  • app/classes/UploadPostCol.php
  • app/classes/UsersAndRoles.php
  • app/classes/functions/createTable.php

@yolanmees
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/pages/connections.blade.php
  • resources/views/report/requests_logs.blade.php
  • resources/views/workflows/index.blade.php
  • resources/views/workflows/newstep.blade.php

@yolanmees
Copy link
Owner Author

⚠️ The following classes do not contain any public methods. These may be better served as a helper or service rather than a controller:

  • app/Http/Controllers/CreateWorkflowController.php

@yolanmees
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/SearchController.php
  • app/Http/Controllers/TestConnection.php
  • app/Http/Controllers/backendController.php
  • app/Http/Controllers/saveConnection.php

@yolanmees
Copy link
Owner Author

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

  • resources/views/collections/postman.blade.php
  • resources/views/collections/requestsByCol.blade.php
  • resources/views/pages/connections/connection.blade.php
  • resources/views/workflows/edit.blade.php
  • resources/views/workflows/editor.blade.php

@yolanmees
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.

@yolanmees
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/auth.php
  • config/services.php

@yolanmees
Copy link
Owner Author

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

@yolanmees
Copy link
Owner Author

⚠️ Laravel 8 began PSR-4 autoloading for factories and seeders. Shift detected the following files are missing a namespace:

  • database/factories/UserFactory.php

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