When I watched Saving Private Ryan in bed last night, I couldn’t help but sigh, Spielberg’s movie is of high quality, and the opening movie truly reflects the brutality of world War II. After reading it, MY spirit was extremely excited, so I wanted to write an article to help us improve the quality of the code. After all, my second brother is also an author with attitude, learning from Spielberg.
I don’t need to belabor the importance of code quality. No one likes bad code, just like no one likes a bad movie. Here are two excellent IDE plug-ins for you to take care of to improve the quality of your code, I personally hands-on, really good.
01. Alibaba Java code specification plug-in
Alibaba’s “Java development manual”, I believe everyone will not feel strange, its supporting code specification plug-in download times is said to have reached 800,000 times. Well, I did it again today. ๐.
The GitHub address of the plugin is as follows:
github.com/alibaba/p3c
The star number of this project has reached 19.9K at the moment, which is quite good.
The installation tutorial address of the plug-in (available in IDEA and Eclipse versions) is shown below:
Github.com/alibaba/p3c…
To Install IDEA, directly search for the keyword “Alibaba” in the [Plugins] panel. The first option is the plugin. Click [Install]. See below.
After the installation was successful, I scanned the current project [right-click menu โ Code Protocol Scan] and found these suggestions in the image below.
At this point, I can only use Jay’s words: “Oh, not bad.”
PS: The project code has been synchronized to GitHub, the address is itwanger.JavaPoint, welcome everyone star and issue.
02. SonarLint plugin
The official address of the SonarLint plugin is as follows:
www.sonarlint.org/
Take a look at the plug-in’s description:
Translate it in my broken English:
SonarLint is an IDE plug-in that helps you detect problems while writing code and fix them. Like a spell checker in real time, SonarLint makes it easy to fix code before you commit it.
The SonarLint plugin is also available in various versions, supporting not only Eclipse and IDEA but also Visual Studio and VS Code. IDEA is also easy to Install by searching for the keyword “SonarLint” in the [Plugins] panel and clicking “Install”. See below.
After the installation was successful, I scanned the current project [right-click menu โSonarLint โ Analysis With SonarLint] and found the following suggestions.
PPS: the project code has been synchronized to GitHub, the address is itwanger.JavaPoint, welcome everyone star and issue.
03. Compare the Alibaba code specification plugin with the SonarLint plugin
The two plugins are different. The first and biggest difference is that the Alibaba code specification plugin is in Chinese and SonarLint is in English, ๐.
Secondly, comparing the screenshots scanned by the two plug-ins, it can be found that the Alibaba code specification plug-ins are classified according to the level of problems. SonarLint plugins are classified according to different classes.
Can we get to the point? Okay, okay, okay. Don’t worry, guest officer.
-
The Alibaba code specification plug-in is more concerned with the specification of the coding style, such as the assignment of long variables, curly braces after conditional statements, whether the @override annotation is used when overwriting, etc.
-
SonarLint is concerned with code correctness, such as not overwriting clone methods, using logging instead of system.out, and not returning null when overwriting Clone methods.
In general, there is no conflict between the two. It is recommended to use them together, with the Alibaba code specification plugin to regulate code and the SonarLint plugin to find hidden code problems. In this way, it can avoid risks, eliminate hidden dangers and improve the robustness of the program in the code writing stage.
04, thanks
Well, readers, that’s all for this article. Can see here are the most excellent programmers, promotion pay is you ๐. If you don’t like it and want to see more, I recommend a few more.
Stunned! These are the 10 most common mistakes Java programmers make
In 2019, my 10 most popular articles on the Internet were read more than 600,000 times
Can Java strings be passed by reference?
Original is not easy, if you feel a little use, please don’t be stingy with your hands like the power; If you want to see the second brother’s updated article for the first time, please scan the qr code below and follow the official account of Silent King ii. See you in the next article!