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

 
Kho phần mềm nguồn mở hosted tại Việt Nam

Kho phần mềm nguồn mở hosted tại Việt Nam

Một số công ty, tổ chức tại Việt nam hiện đã cung cấp các server lưu trữ phần mềm nguồn mở. Tìm kiếm, tải về và cập nhật từ các kho này đương nhiên là nhanh hơn nhiều so với các kho ở nước ngoài.

Cách tạo server để truy cập trang web trong mạng nội bộ

Cách tạo window server để truy cập trang web trong mạng nội bộ

Trong một số trường hợp cần thực hiện một website chỉ dành riêng cho các máy tính trong hệ thống  mạng nội bộ truy cập để làm việc dựa trên một ứng dụng web chuyên nghiệp hoặc đơn giản là chỉ dùng để phổ biến thông tin nội bộ.

Deepnet Explorer

10 browser đang được sử dụng nhiều nhất hiện nay

Gần đây, các hãng phát hành liên tục tung ra những phiên bản mới, cùng những công nghệ riêng, khiến cho cuộc chiến tranh giành thị phần giữa các trình duyệt web trở nên khốc liệt. Dựa vào số lượng người dùng và tính năng, website TopTenReviews đã chọn ra 10 đại diện sáng giá nhất dưới đây.

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

 

Diet con trung