-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add a new rule #986
Comments
|
@godfather1103 Do you have any documentation or tutorial to add a rule? If you have, can you share it with me? |
@godfather1103 Thank you for your sharing the resource with me. |
@godfather1103 I want to add a sample rule but I have no idea to add it. I looked through the documentation but I couldn't find detail information about it. Do you have any video record or sample tutorial for it like build the rule from scratch. I hope you can help me. I'm waiting for your response as soon as possible. |
I don't have any experience writing rules independently, I just modified bugs in existing rules |
P3C pmd is based on pmd, so you may need to search for a tutorial on writing pmd rules |
@godfather1103 What I just want to ask is to learn if I can add a rule (after I've learnt) to the plugin. Is it possible to do that. Let me know. |
|
this is way to add custom rule for plugin |
2 ) Do I define the rule this location Link . Is it right? 3 ) Create class class extends AbstractAliRule in Link 4 ) How can I ad the rule as there are some xml files Link 5 ) Do I run this command Who can I connect with someone whose experience is enough to define a new ? I hope you can help me. |
2-4 is right |
@godfather1103 What about 3 and my last question? |
@godfather1103 I hope you can provide a video tutorial for adding a new rule to this plugin like building from scratch. |
I don't have any relevant tutorials, I hope others can provide them in the future. |
Are you a beginner? Do you have any experience in Java development? |
My English is not good and I need to rely on translation software, so I don't quite understand your needs. |
@godfather1103 I already had an experience in Java Development. You can look through my github profile. As I couldn't find any relevant tutorials like building to add a rule from scratch, I asked you about it. I hope other contributors can help me provide them. Is it possible to connect with them about it. |
If I have time on the weekend, I can try writing a document titled 'How to Add a Simple Custom Rule', hoping it will be helpful to you. |
@godfather1103 I hope you can do it. Is it possible to record a video like build from scratch? That's why I can easily get how to add a custom rule like detecting deprecated methods, greater or equal to or vice versa. I'm waiting for your feedback as soon as possible. |
@godfather1103 Hi, you forgot to share a video like "building a custom rule in the plugin and then using it from scratch". I hope you can prepare it as soon as possible. |
@Rapter1990 Sorry, due to the approaching holiday, I am working overtime to process work and currently do not have time to record videos. |
@Rapter1990 I recorded a video explaining how to add custom rules. After the video website review, I will attach the corresponding link. |
The language in the video is Chinese, and you can check the demo branch for the specific code |
this is video https://www.bilibili.com/video/BV1uN411E7TE/ |
example code |
@godfather1103 Thank you for your sharing video and documentation but the video cannot be enough clear to see even if I revised its settings. Can you reupload it with high resolution if you don't mind? |
I'm on vacation recently. I'll give it a try tomorrow evening |
@godfather1103 I also want to add a sample custom rule like methods written in camelCase and add it into plugin. Next, I can use it. Can you add me as a contributor in this repo? Can you help me how to define it? Can you direct me? |
@Rapter1990 https://github.com/alibaba/p3c? |
@godfather1103 Hi. I tried to download the repo as a zip file and added a sample custom rule. I have a problem when I run
Here is the error.
|
@godfather1103 I defined allowInsecureProtocol = true to build.gradle of idea plugin shown below
Then I run this command
How can I fix it? I use gradle 8.3 |
https://github.com/godfather1103/p3c.git
Download code from this repository.
There is an issue with the build script in alibaba/p3c.
| |
JackChu
|
|
***@***.***
|
|
@godfather1103 I downloaded your repository and tested it. I got the same issue which I mentioned before. How can I fix it? As I mentioned before, I use gradle 8.3 |
@godfather1103 I fixed it but there is another question to you. I saw Here is the error shown below
|
|
branch before-2022.3,supports versions up to and including 2022.3 |
idea-plugin/build.gradle.kts
|
@godfather1103 After adding a sample rule to check the method is camelcase of not, I tried to build the repo with Here are the code snippets shown below p3c-pmd/src/main/resources/messages.xml
p3c-pmd/src/main/resources/messages-en.xml
p3c-pmd/src/test/java/demo/CamelCaseMethodNameRuleTest
p3c-pmd/src/test/resources/rulesets/java/demo.xml
p3c-pmd/src/test/resources/demo/xml/CamelCaseMethodNameRule.xml
idea-plugin/p3c-common/src/main/resources/rulesets/java/ali-pmd.xml
|
Can you debug to see if relevant content has been injected |
@godfather1103 I can run CamelCaseMethodNameRuleTest without any error. After I get zip file from repo as plugin, I test it in Intellij Idea 2018 but it couldn't detect the rule and rule can appeared when I click "Analyze code through Ali Baba Java Guideness Plugin". |
@godfather1103 I downloaded your repo but I got this issue when I run this command
How can I fix it? |
use jdk 17 |
@godfather1103 I define |
@Rapter1990 What about the code for this class "demo.CamelCaseMethodNameRule" |
@godfather1103 I forgot to add it. You can see the post above to show all information about custom rule. I have also another problem which I mentioned before. I hope you can help me. |
2.Modify buildscript.repositories Order |
@godfather1103 Here is what I've done after your response. 1. Settings -> Build -> Gradle -> Gradle Jvm -> Oracle Open JDK version 11.0.20 In the file named gradle-wrapper.properties , here is the gradle version shown below
2. Move It works now. Thank you for your guideness. I can reach out you again if I have any problem. |
@godfather1103 How can I find rule example like xpath example such as FinallyStatement, ReturnStatement, ContinueStatement? Can you share its link if you have? Let me know. |
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_userdocs_extending_your_first_rule.html
Message ID: ***@***.***>
|
@godfather1103 I found this link ( https://josephallen.github.io/PMD-New-Site/writing_pmd_rules.html ) I try to find their usage like Do you have any idea about it? |
I don't know.
Message ID: ***@***.***>
|
@godfather1103 Which contributor has any idea about it? |
@godfather1103 I try to find more examples of writing custom rule. Where do I find more them? |
@godfather1103 Hi, I want to ask some questions to you?
Can you help me? |
Run in debug mode to confirm if the rules have been injected |
Follow the steps in the video I sent and check in sequence |
I tried to use your plugin in my Intellij IDEA 2023.2.1 Ultimate Edition and it feels very comfortable to analyze the code and suggest some major and minor ideas which help you revise the code.
What I just want to ask is to learn how to add a new rule in the plugin.
Which documentation do I follow that?
Can you guide me?
I hope you can help me.
I'm waiting for response as early as possible.
The text was updated successfully, but these errors were encountered: