data-aggregator icon indicating copy to clipboard operation
data-aggregator copied to clipboard

Laravel Linter

Open IllyaMoskvin opened this issue 5 years ago • 10 comments

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

Before merging, you should:

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

If you want help with your upgrade, check out the Shift Human Services or join the Shifty Coders Slack room to get answers to all your Laravel questions.

IllyaMoskvin avatar Mar 27 '19 21:03 IllyaMoskvin

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

IllyaMoskvin avatar Mar 27 '19 21:03 IllyaMoskvin

:warning: 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'.

IllyaMoskvin avatar Mar 27 '19 21:03 IllyaMoskvin

:warning: 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/Search/SearchInstall.php
  • [ ] app/Http/Controllers/SearchController.php

IllyaMoskvin avatar Mar 27 '19 21:03 IllyaMoskvin

:warning: 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/Http/Controllers/AbstractController.php
  • [ ] app/Http/Controllers/SearchController.php
  • [ ] app/Models/Archive/ArchiveImage.php
  • [ ] app/Models/BaseModel.php
  • [ ] app/Models/Collections/Agent.php
  • [ ] app/Models/Collections/AgentRole.php
  • [ ] app/Models/Collections/AgentType.php
  • [ ] app/Models/Collections/Artwork.php
  • [ ] app/Models/Collections/ArtworkArtistPivot.php
  • [ ] app/Models/Collections/ArtworkAssetPivot.php
  • [ ] app/Models/Collections/ArtworkCatalogue.php
  • [ ] app/Models/Collections/ArtworkDate.php
  • [ ] app/Models/Collections/ArtworkDateQualifier.php
  • [ ] app/Models/Collections/ArtworkImagePivot.php
  • [ ] app/Models/Collections/ArtworkPlacePivot.php
  • [ ] app/Models/Collections/ArtworkPlaceQualifier.php
  • [ ] app/Models/Collections/ArtworkTerm.php
  • [ ] app/Models/Collections/ArtworkType.php
  • [ ] app/Models/Collections/Asset.php
  • [ ] app/Models/Collections/Catalogue.php
  • [ ] app/Models/Collections/Category.php
  • [ ] app/Models/Collections/CategoryTerm.php
  • [ ] app/Models/Collections/Exhibition.php
  • [ ] app/Models/Collections/Gallery.php
  • [ ] app/Models/Collections/Image.php
  • [ ] app/Models/Collections/Place.php
  • [ ] app/Models/Collections/Sound.php
  • [ ] app/Models/Collections/Term.php
  • [ ] app/Models/Collections/Text.php
  • [ ] app/Models/Collections/Video.php
  • [ ] app/Models/CollectionsModel.php
  • [ ] app/Models/DigitalLabel/Exhibition.php
  • [ ] app/Models/DigitalLabel/Label.php
  • [ ] app/Models/DigitalLabelModel.php
  • [ ] app/Models/Dsc/Publication.php
  • [ ] app/Models/Dsc/Section.php
  • [ ] app/Models/DscModel.php
  • [ ] app/Models/Library/Material.php
  • [ ] app/Models/Library/Term.php
  • [ ] app/Models/LibraryModel.php
  • [ ] app/Models/Membership/TicketedEvent.php
  • [ ] app/Models/Membership/TicketedEventType.php
  • [ ] app/Models/MembershipModel.php
  • [ ] app/Models/Mobile/Artwork.php
  • [ ] app/Models/Mobile/Sound.php
  • [ ] app/Models/Mobile/Tour.php
  • [ ] app/Models/Mobile/TourStop.php
  • [ ] app/Models/MobileModel.php
  • [ ] app/Models/Shop/Category.php
  • [ ] app/Models/Shop/Product.php
  • [ ] app/Models/ShopModel.php
  • [ ] app/Models/StaticArchive/Site.php
  • [ ] app/Models/Web/Article.php
  • [ ] app/Models/Web/Artist.php
  • [ ] app/Models/Web/Closure.php
  • [ ] app/Models/Web/DigitalCatalog.php
  • [ ] app/Models/Web/EducatorResource.php
  • [ ] app/Models/Web/Event.php
  • [ ] app/Models/Web/EventOccurrence.php
  • [ ] app/Models/Web/EventProgram.php
  • [ ] app/Models/Web/Exhibition.php
  • [ ] app/Models/Web/GenericPage.php
  • [ ] app/Models/Web/Hour.php
  • [ ] app/Models/Web/Location.php
  • [ ] app/Models/Web/Page.php
  • [ ] app/Models/Web/PressRelease.php
  • [ ] app/Models/Web/PrintedCatalog.php
  • [ ] app/Models/Web/ResearchGuide.php
  • [ ] app/Models/Web/Selection.php
  • [ ] app/Models/Web/StaticPage.php
  • [ ] app/Models/Web/Tag.php
  • [ ] app/Models/WebModel.php

IllyaMoskvin avatar Mar 27 '19 21:03 IllyaMoskvin

:warning: 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

IllyaMoskvin avatar Mar 27 '19 21:03 IllyaMoskvin

:warning: 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/AbstractController.php
  • [ ] app/Http/Controllers/SearchController.php

IllyaMoskvin avatar Mar 27 '19 21:03 IllyaMoskvin

:warning: Laravel 5.2 added the env configuration option. Laravel recommends you only use env() within configuration files and use config() everywhere else.

Shift found potential uses of env() in:

  • [ ] app/Console/Commands/Dump/DumpDownload.php
  • [ ] app/Console/Commands/Dump/DumpUpload.php
  • [ ] app/Console/Commands/Import/DeleteCollectionsRecords.php
  • [ ] app/Console/Commands/Import/ImportArchive.php
  • [ ] app/Console/Commands/Import/ImportCatalogues.php
  • [ ] app/Console/Commands/Import/ImportCollections.php
  • [ ] app/Console/Commands/Import/ImportCollectionsFull.php
  • [ ] app/Console/Commands/Import/ImportCollectionsOne.php
  • [ ] app/Console/Commands/Import/ImportDigitalLabels.php
  • [ ] app/Console/Commands/Import/ImportImages.php
  • [ ] app/Console/Commands/Import/ImportLibrary.php
  • [ ] app/Console/Commands/Import/ImportMobile.php
  • [ ] app/Console/Commands/Import/ImportProducts.php
  • [ ] app/Console/Commands/Import/ImportProductsFull.php
  • [ ] app/Console/Commands/Import/ImportSetUlanUris.php
  • [ ] app/Console/Commands/Import/ImportSites.php
  • [ ] app/Console/Commands/Import/ImportTicketedEventTypesFull.php
  • [ ] app/Console/Commands/Import/ImportTicketedEvents.php
  • [ ] app/Console/Commands/Import/ImportTicketedEventsFull.php
  • [ ] app/Console/Commands/Import/ImportWeb.php
  • [ ] app/Console/Commands/Import/ImportWebFull.php
  • [ ] app/Console/Commands/Import/ImportWebOne.php
  • [ ] app/Console/Commands/Report/ReportAltText.php
  • [ ] app/Console/Commands/Search/SearchAlias.php
  • [ ] app/Console/Commands/Search/SearchInstall.php
  • [ ] app/Console/Commands/Search/SearchReindex.php
  • [ ] app/Console/Commands/Search/SearchUninstall.php
  • [ ] app/Console/Helpers/Indexer.php
  • [ ] app/Helpers/Util.php
  • [ ] app/Http/Search/Request.php
  • [ ] app/Models/Collections/Image.php
  • [ ] app/Models/Library/Material.php
  • [ ] app/Models/Shop/Category.php
  • [ ] app/Models/Shop/Product.php
  • [ ] app/Providers/SearchServiceProvider.php
  • [ ] app/Transformers/Inbound/DigitalLabel/Label.php
  • [ ] app/Transformers/Outbound/Collections/Artwork.php
  • [ ] app/Transformers/Outbound/Shop/Product.php
  • [ ] routes/api.php

IllyaMoskvin avatar Mar 27 '19 21:03 IllyaMoskvin

:x: Shift could not run composer install for your application. As such, the analysis for lines of code are unavailable.

IllyaMoskvin avatar Mar 27 '19 21:03 IllyaMoskvin

:warning: 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/database.php
  • [ ] config/filesystems.php
  • [ ] config/hashing.php
  • [ ] config/logging.php
  • [ ] config/queue.php
  • [ ] config/view.php

IllyaMoskvin avatar Mar 27 '19 21:03 IllyaMoskvin

:information_source: As noted, much of the code detected above can be automatically fixed using the Laravel Fixer. Save yourself time and clean up your codebase quickly with this new Shift.

IllyaMoskvin avatar Mar 27 '19 21:03 IllyaMoskvin