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

Merged
merged 1 commit into from
Mar 24, 2023
Merged

Laravel Linter #1292

merged 1 commit into from
Mar 24, 2023

Conversation

DariusIII
Copy link
Member

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

Before merging, you need to:

  • Checkout the shift-86066 branch
  • Review all pull request comments for additional changes
  • Thoroughly test your application (no tests?, no CI?)

Much of the lint detected may be automatically fixed by running the Laravel Fixer or tasks within the Shift Workbench.

@DariusIII
Copy link
Member Author

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

2 similar comments
@DariusIII
Copy link
Member Author

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

@DariusIII
Copy link
Member Author

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

@DariusIII
Copy link
Member 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'.

@DariusIII
Copy link
Member Author

❌ The following configuration files differ from the Laravel defaults. If you are modifying configuration values directly, consider using an environment variable instead to keep these files maintainable. You should compare your configuration files against the latest version and merge any updates.

  • 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

@DariusIII
Copy link
Member Author

ℹ️ Starting with Laravel 8, the model property within factories may be removed when your models are stored within a conventional location such as app/Models. Unless your factory is for a model outside of this location, you may remove this property.

@DariusIII
Copy link
Member 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 may rework these into resource controllers.

  • app/Http/Controllers/Admin/AdminAjaxController.php
  • app/Http/Controllers/Admin/AdminCollectionRegexesController.php
  • app/Http/Controllers/Admin/AdminGroupController.php
  • app/Http/Controllers/Admin/AdminNzbController.php
  • app/Http/Controllers/Admin/AdminReleaseNamingRegexesController.php
  • app/Http/Controllers/Admin/AdminSiteController.php
  • app/Http/Controllers/Admin/AdminUserController.php
  • app/Http/Controllers/AjaxController.php
  • app/Http/Controllers/AnimeController.php
  • app/Http/Controllers/Api/API.php
  • app/Http/Controllers/Api/ApiController.php
  • app/Http/Controllers/Api/ApiInformController.php
  • app/Http/Controllers/Api/ApiV2Controller.php
  • app/Http/Controllers/Api/Capabilities.php
  • app/Http/Controllers/Api/RSS.php
  • app/Http/Controllers/Api/XML_Response.php
  • app/Http/Controllers/ApiHelpController.php
  • app/Http/Controllers/BasePageController.php
  • app/Http/Controllers/BrowseController.php
  • app/Http/Controllers/BtcPaymentController.php
  • app/Http/Controllers/ContactUsController.php
  • app/Http/Controllers/FailedReleasesController.php
  • app/Http/Controllers/ForumController.php
  • app/Http/Controllers/GetNzbController.php
  • app/Http/Controllers/MovieController.php
  • app/Http/Controllers/MyShowsController.php
  • app/Http/Controllers/NfoController.php
  • app/Http/Controllers/PasswordSecurityController.php
  • app/Http/Controllers/RssController.php
  • app/Http/Controllers/SearchController.php
  • app/Http/Controllers/TermsController.php

@DariusIII
Copy link
Member 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/ForgotPasswordController.php
  • app/Http/Controllers/Auth/LoginController.php
  • app/Http/Controllers/ContactUsController.php
  • app/Http/Controllers/PasswordSecurityController.php
  • app/Http/Controllers/ProfileController.php

@DariusIII
Copy link
Member Author

⚠️ Shift detected the following HTTP components using the Request or Input facade to access the request. Within these components you should leverage the request object which is automatically injected to any controller action or Middleware.

  • app/Http/Controllers/Api/ApiController.php
  • app/Http/Controllers/Api/ApiV2Controller.php
  • app/Http/Controllers/ProfileController.php
  • app/Http/Controllers/RssController.php

@DariusIII
Copy link
Member Author

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

  • app/Http/Controllers/PasswordSecurityController.php
  • app/Http/Middleware/ClearanceMiddleware.php

@DariusIII
Copy link
Member Author

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

  • resources/views/auth/2fa.blade.php
  • resources/views/auth/google2fa.blade.php

@DariusIII
Copy link
Member Author

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

  • app/Http/Controllers/Auth/RegisterController.php
  • app/Http/Controllers/BtcPaymentController.php

@DariusIII
Copy link
Member Author

⚠️ Laravel 10.0 no longer includes the resources/lang folder by default. Instead, you may publish if you need to make customizations. Shift detected your language files match the defaults and as such your resources/lang folder may be removed.

@DariusIII
Copy link
Member Author

❌ Laravel 9.0 moved the resources/lang folder to a top-level lang folder. While Laravel allows the old folder, future versions may not. You should migrate this folder and add any new files.

@DariusIII
Copy link
Member Author

ℹ️ Shift detected legacy model factories. Laravel 8 introduced class based model factories. You may automate the conversion to class based model factories using the Shift Workbench.

@DariusIII
Copy link
Member Author

ℹ️ Shift detected controller namespaces being set in your RouteServiceProvider. Laravel 8 began registering routes using static class references instead of namespace prefixes and action strings.

@DariusIII
Copy link
Member Author

❌ Laravel 10 added PHP type hints to all user-land code included in a new Laravel application. Shift detected these files are missing type hints. Shift recommends adding them to align with the latest Laravel conventions. You may automate this process by running the Laravel Type Hints task within Shift Workbench.

@DariusIII
Copy link
Member Author

⚠️ Laravel uses PSR-4 autoloading for the app/ folder. While you may 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/Extensions/helper/helpers.php

@DariusIII
Copy link
Member 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.

@DariusIII DariusIII merged commit f89dba4 into master Mar 24, 2023
@DariusIII DariusIII deleted the shift-86066 branch September 4, 2023 06:58
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