Alibaba Java Development Protocol Plug-in Alibaba Java Development Protocol Plug-in p3c Detailed tutorial and experience

The content comes from: Alibaba Java development specification plugin p3c detailed tutorial and experience

 

Three versions have been changed so far. On September 25, 2017, the "Alibaba Java Development Manual (Ultimate Edition)" was officially released, and it was also the last PDF version officially released by Alibaba. The latest version download link is here .

 

Plugin introduction

Based on the content of the manual, Alibaba has developed a set of automated IDE detection plug-ins (IDEA, Eclipse). After scanning the code, the plug-in will display the code that does not conform to the "Manual" at the bottom according to the three levels of Blocker/Critical/Major. On IDEA, real-time detection is also provided based on the Inspection mechanism, and the problem can be found quickly while writing code. For historical code, some rules implement the function of batch one-click repair, improve code quality, and improve team R&D efficiency.

The code is open source, GitHub: https://github.com/alibaba/p3c

Let's experience it!

 

Plug-in simple tutorial (based on IDEA)

Search plugin

Open IDEA, select Preferences - Plugins - Browse repositories , enter "alibaba" in the input box, and you can see that "Alibaba Java Coding Guidelines" is in the returned result.

 

Install the plugin

Click the "install" button in the plugin details and follow the prompts to complete the installation. After the installation is complete, you need to restart IDEA.

 

Functional experience

After the installation is complete, you need to restart IDEA. After restarting, you can see its function buttons in the menu bar. There are three ways to scan the code:

  • Right-click on the project directory will also appear these two function buttons, click the green button to start scanning the code, or right-click on the project directory will also appear the detection function button.

 

  • If you don't want to scan all, but only scan the currently edited file, right-clicking in the current file panel will also appear this function button.

 

  • The two methods mentioned above are manual detection. The plug-in also provides the function of real-time monitoring. This function is enabled by default. Once enabled, it will be monitored in real time when you write code. Once there is a statement that does not conform to the specification, an error message will appear. .

 

After scanning the code, the code that does not conform to the specification will be displayed in the lower panel according to the three levels of Blocker/Critical/Major, as shown in the figure:

 

On the left is the scanned code that does not conform to the specification. Click in order to see how many lines of the code have the specification problem and which specification problem. The right side is the detailed description of the specification and the example code.

 

Not only that, there is also a quick fix button on the right side, you can directly correct the code after clicking, but not all problems have this button, and some problems still need to be modified manually.

Supported version

IDEA official warehouse: minimum supported version 14.1.7, JDK1.7+
Eclipse version plugin: support 4.2 (Juno, JDK1.8+) and above

Check for updates

You can check the new version of the plugin through Help >> Check for Udates

Plugin uninstall

Click "uninstall" in the plugin panel.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325311119&siteId=291194637