Kỹ thuật Reviewing Code với IDE PHPStorm to inspect code

Kỹ thuật Reviewing Code với IDE PHPStorm to inspect code

One of the main responsibilities of a Drupal core committer is doing a final review of patches before committing them. Since July 1, 2014, I’ve committed over 250 patches to Drupal 8. Thanks to Chapter Three for making that possible.

Reviewing code is time consuming. Here are some things that make my job easier:

  • Well written issue summaries
  • Screenshots of before and after, if the user interface has changed
  • Evidence that the person who sets the issue status to "Reviewed & tested by the community" has considered Drupal’s core gates
  • A draft change record or a list of change records that need updating, if necessary

This process can be overkill for a one line patch, but once the patch is more than a couple of lines is helps the reviewer a great deal.

There is a part of reviewing that feels a bit like playing Papers, Please, but some of the most mundane parts are automatable.

My current IDE, PHPStorm, allows me to inspect code for obvious mistakes. After applying the patch from the issue to review, I select Code > Inspect Code… from the menu.

Kỹ thuật Reviewing Code với IDE PHPStorm to inspect code

By setting the scope to be "Uncommitted files," PHPStorm will only inspect the files changed by the patch. PHPStorm will then detect unused variables, spelling mistakes, PHPDoc issues, and a plethora of other common problems. My favorite inspection is a duplicate array key, as this can be quite difficult to spot.

PHPStorm has helped me find bugs in Drupal. For example, while reviewing a patch that changed core/includes/theme.inc, the inspection informed me that it was unable to find the JSON class. As a result, I created https://www.drupal.org/node/2217755 which is now a critical bug because it prevents the language switcher block from working.

If you set up PHPStorm to use PHP Codesniffer and get the sniffs for Drupal installed, the code inspection tool will also check the code against our coding standards. Note that it is entirely possible to use this without PHPStorm.

Drupal has not yet reached the level of automation of other projects like Symfony, which does an automated code style review on all contributions, but hopefully the recent work on testbot infrastructure by jthorson and others will get us there.

I look forward to reviewing your patches for Drupal 8!

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
HTC Desire S Review

HTC Desire S Review

HTC recently introduced the newest member of its Desire series, the HTC Desire S. Actually it is the more affordable option for its cutting-edge predecessor, HTC Desire.

Công cụ từ chối Backlink: Google’s Disavow Tool

Giới thiệu Ngày 16/10 chuyên gia nghiên cứu thuật toán, Matt Cutts đã thông báo về việc Google thêm một công cụ mới vào Google Webmaster Tools: Google’s Disavow Tool tạm dịch là “công cụ từ chối backlink”. Ai nên sử dụng tool này?

Hướng dẫn seo hình ảnh cho website của bạn

Hướng dẫn seo hình ảnh cho website của bạn

Nhiều vẫn còn thắc mắc là làm sao để có hình ảnh xuất hiện trên google khi search một  từ khóa nào đó. SEO123 sẽ hướng dẫn các bạn cách SEO hình ảnh cho website để xuất hiện hình ảnh lên trang đầu trong kết quả tìm kiếm.

Công ty diệt chuột T&C

 

Diet con trung