Current words , I （Guide Brother ） Is in Github Open source has two wheels , A simple RPC frame , A lightweight HTTP frame . The code structure is clear , Achieve elegance （ This boast is shameless ）, Interested partners can have a look at .
When writing code , There are several IDEA Plug-ins are very effective for me to standardize my code and to do coding more efficiently .
So today, I will talk about the process of writing code , What are they? IDEA Plugins help me the most ！
One of the plug-ins I've been using , It's very easy to use （ Many big guys around me usually write code and use this plug-in ）.
Codota This plug-in is used for intelligent code completion , It's based on millions Java Program , Be able to prompt to complete the code according to the program context . Compared with IDEA In terms of the self-contained intelligent prompt ,Codota More comprehensive .
If you think IDEA Too many plug-ins are installed in the case of a carton , Never mind ！Codota The plug-in also has a corresponding online website （https://www.codota.com/code）, On this website, you can search relevant code examples according to code keywords , Very good ！
I often use it in my work , To be honest, it really brought me a lot of convenience , For example, we search
Files.readAllLines Related code , The search results are shown in the following figure ：
in addition ,Codota The basic functions of plug-ins are free . Your code will not be leaked , You don't have to worry about that .
Take a simple look Codota Plug in the Sao operation ！
HttpUrlConnection It's really like to build a network connection ：
Let's create the thread pool as follows ：
It's just to demonstrate the power of this plug-in , This is not recommended for creating thread pools , Recommended
ThreadPoolExecutor Constructor to create a thread pool . I'd like to introduce a plug-in of Alibaba -Alibaba Java Code Guidelines That's the problem , therefore ,
Executors The bottom is marked with wavy lines .
except , Beyond the intelligent prompt when writing code . You can also select the code directly and search for relevant code samples .
Alibaba Java Code specification , Corresponding Github The address is ：https://github.com/alibaba/p3c . Very recommended installation ！
After installation, it is recommended to replace the language with Chinese , More friendly tips .
According to the official description ：
At present, this plug-in implements the 53 Bar rule , Mostly based on PMD Realization , Among them is 4 Rules based on IDEA Realization , And based on IDEA Inspection Real time detection function is realized . Some rules are implemented Quick Fix function , For available Quick Fix But not provided , We will achieve it as soon as possible , Also welcome interested students to join in and work together . At present, plug-in detection has two modes ： real-time detection 、 Manual trigger .
The development manual mentioned above is Java Well known in the field of development 《 Alibaba Java Development Manual 》.
You can also manually configure related inspection The rules ：
This plug-in will detect in real time where our code doesn't match its rules , And it will give suggestions for modification . For example, if we create a thread pool in the following way , This plug-in will help us detect it , As shown in the figure below .
This can correspond to 《 Alibaba Java Development Manual 》 How to create thread pool in this book .
CheckStyle Almost Java A necessary plug-in for project development , It will help us check Java There are problems with the format of the code, such as whether the variable naming format is wrong 、 Is the length of a line of code too long, etc .
On the project , It is not reliable to standardize code format by self-restraint of project developers ！ therefore , We need a tool like this to help us standardize the code format .
If you've seen the wheel I wrote , I can find that I have integrated for every project CheckStyle, And set up Git Commit hook , Make sure that there is no problem with the code format before submitting the code .
Guide The wheel made by brother （ The code is concise , The structure is clear , Welcome to learn , Welcome to perfect ）：
- guide-rpc-framework ：A custom RPC framework implemented by Netty+Kyro+Zookeeper.（ Based on a Netty+Kyro+Zookeeper Implemented customization RPC frame - The detailed implementation process and related tutorials are attached ）
- jsoncat ： Imitation Spring Boot But it's different from Spring Boot A lightweight of HTTP frame
Git hook ： Git Be able to perform certain important actions such as commit、push Trigger custom script when it happens . Hooks are stored in Git In the catalog
hooksSubdirectory . In most projects
In general , We all integrate it into the project , And set the corresponding Git hook . There are corresponding articles on the Internet , There's not much to talk about here .
If you don't think the online article is intuitive , I can refer to the above mentioned two wheels ：
If you integrate Checksytle Words , Each test generates a HTML The format file tells you where the code format is not correct , It's not intuitive . adopt Checksytle Plug-ins can be very intuitive to show the format problems in the project .
If you just use it locally , I don't want to integrate... In the project Checksytle You can also , Just download one Checksytle Plug-ins are enough .
We are directly in the IDEA This plug-in can be found in the plug-in market . I've installed it here .
After installing the plug-in, restart IDEA, You will find it on the bottom menu bar CheckStyle 了 .
If you need to customize code format detection rules , You can configure it as follows （ You can import the
CheckStyle.xml file ）.
Once the configuration is complete , Use the plug-in as follows ！
You can see it very clearly ：CheckStyle Plug-ins have detected the format problems in the code in the project according to our custom rules .
SonarLint Help you find bugs and bugs in your code , It's like a code spell checker ,SonarLint Can show the problem of the code in real time , And provide clear repair guidance , So that you can fix the code before you submit it .
also , Many projects have integrated SonarQube,SonarLint Can be very convenient with SonarQube Integrate .
I am a Guide Brother , One Java The backend development , A little bit of the front end , Free youth . See you next time ！ Wechat search “JavaGuide” reply “ Interview shock ” Get what I've arranged 4 Original PDF