首页 > 其他分享 >Pmd-ida 插件安装使用

Pmd-ida 插件安装使用

时间:2024-02-29 11:23:08浏览次数:29  
标签:pmd 插件 idea Pmd https com ida

Pmd-ida代码工程: https://github.com/ybroeker/pmd-idea

Pmd-idea主页:https://plugins.jetbrains.com/plugin/15412-pmd-idea

 

路径:file->setting->plugins->Marketplace,国内在线安装下载吧不到安装包,到https://github.com/ybroeker/pmd-idea  在release界面下载和idea版本适配的zip包安装

安装完成后,设置pmd检查规则文件,设置路径:file->setting->Tools->PMD-IDEA

选择规则文件

 

 提供官网一个规则参考内容

<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Default Maven PMD Plugin Ruleset" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
    <description>
        GeoTools ruleset. See https://pmd.github.io/latest/pmd_userdocs_understanding_rulesets.html
    </description>
    <rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>
    <rule ref="category/java/bestpractices.xml/CheckResultSet"/>
    <!--rule ref="category/java/bestpractices.xml/UnusedFormalParameter" /-->
    <rule ref="category/java/bestpractices.xml/UnusedLocalVariable"/>
    <rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
    <rule ref="category/java/bestpractices.xml/UnusedPrivateMethod"/>
    <rule ref="category/java/bestpractices.xml/SystemPrintln"/>
    <rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach" />
    <rule ref="category/java/bestpractices.xml/UseTryWithResources" >
        <properties>
            // The rule reports false positives for closeable arguments that are used
            // closed within the method body. This suppression tries to avoid false positives for
            // this case, until we can switch to Java 9 and just use try(variable) {...} without
            // the need to instatiate the variable in the try
            <property name="violationSuppressXPath" value="./FinallyStatement//Name[substring-after(@Image, '.') = 'close' or substring-after(@Image, '.') = 'closeQuietly'][pmd-java:typeIs('java.lang.AutoCloseable') and fn:substring-before(@Image, '.') = ancestor::MethodDeclaration/MethodDeclarator//VariableDeclaratorId/@Name]"/>
        </properties>
    </rule>
    <rule ref="category/java/bestpractices.xml/ReplaceHashtableWithMap" />
    <rule ref="category/java/bestpractices.xml/ReplaceVectorWithList" />
    <rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace" />
    <rule ref="category/java/bestpractices.xml/MissingOverride" />
    <rule ref="category/java/bestpractices.xml/UseStandardCharsets" />
    <rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation" />
    <rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty" />

    <rule ref="category/java/codestyle.xml/EmptyControlStatement"/>
    <rule ref="category/java/codestyle.xml/ExtendsObject"/>
    <rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/>
    <rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName"/>
    <rule ref="category/java/codestyle.xml/UseDiamondOperator" />
    <rule ref="category/java/codestyle.xml/UnnecessaryReturn"/>
    <rule ref="category/java/codestyle.xml/UselessParentheses"/>
    <rule ref="category/java/codestyle.xml/UselessQualifiedThis"/>
    <rule ref="category/java/codestyle.xml/UnnecessaryCast" />
    <rule ref="category/java/codestyle.xml/IdenticalCatchBranches" />
    <rule ref="category/java/codestyle.xml/UseShortArrayInitializer" />
    <rule ref="category/java/codestyle.xml/UnnecessaryImport" />

    <rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor"/>
    <rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators"/>
    <rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/>
    <rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
    <rule ref="category/java/errorprone.xml/CheckSkipResult"/>
    <rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray"/>
    <rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices"/>
    <rule ref="category/java/errorprone.xml/JumbledIncrementer"/>
    <rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
    <rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/>
    <rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock"/>
    <rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/>
    <rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary"/>
    <rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals"/>
    <rule ref="category/java/errorprone.xml/UselessOperationOnImmutable"/>
    <rule ref="category/java/errorprone.xml/CloseResource">
        <properties>
            <!-- When calling the store to close, PMD wants the full prefix before the call to the method to match, so let's try to use common var names for store ... -->
            <property name="closeTargets" value="releaseConnection,store.releaseConnection,closeQuietly,closeConnection,closeSafe,store.closeSafe,dataStore.closeSafe,getDataStore().closeSafe,close,closeResultSet,closeStmt"/>
            <property name="allowedResourceTypes" value="java.io.ByteArrayOutputStream|java.io.ByteArrayInputStream|java.io.StringWriter|java.io.CharArrayWriter|java.util.stream.Stream|java.util.stream.IntStream|java.util.stream.LongStream|java.util.stream.DoubleStream|java.io.StringReader" />
        </properties>
    </rule>

    <rule ref="category/java/multithreading.xml/AvoidThreadGroup"/>
    <rule ref="category/java/multithreading.xml/DontCallThreadRun"/>
    <rule ref="category/java/multithreading.xml/DoubleCheckedLocking"/>

    <rule ref="category/java/performance.xml/UseArrayListInsteadOfVector" />
    <rule ref="category/java/performance.xml/BigIntegerInstantiation"/>
    <rule ref="category/java/performance.xml/StringInstantiation"/>
    <rule name="wildcards" language="java" message="No Wildcard Imports" class="net.sourceforge.pmd.lang.rule.XPathRule">
        <description>
            Don't use wildcard imports
        </description>
        <priority>3</priority>
        <properties>
            <property name="version" value="2.0"/>
            <property name="xpath">
                <value><![CDATA[
          //ImportDeclaration[@ImportedName=@PackageName]
          ]]></value>
            </property>
        </properties>
    </rule>

    <rule ref="category/java/design.xml/CognitiveComplexity">
        <properties>
            <property name="reportLevel" value="140"/>
        </properties>
    </rule>
</ruleset>
View Code

执行检查扫描

 

标签:pmd,插件,idea,Pmd,https,com,ida
From: https://www.cnblogs.com/liwutao/p/18043045

相关文章

  • Chrome浏览器插件安装几种方式
    1、将Edge中的扩展安装到Chrome查看Edge扩展安装目录edge://extensions/打开Edge浏览器插件位置:C:\Users\Administrator\AppData\Local\Microsoft\Edge\UserData\Default\Extensions查看Chrome的扩展安装目录chrome://extensions/将该目录下的文件,复制到Chrome的目录下:C:\Use......
  • kettle从入门到精通 第四十九课 ETL之kettle 自定义插件01
    1、kettle插件是什么kettle本身有足够多的转换或者job步骤,但是依然不能覆盖所有的业务场景,所以Kettle自定义插件在有些独特的业务场景可以大显身手。Kettle的插件架构使得我们可以不用修改Kettle本身代码,通过一些独立的代码就可以扩展Kettle的功能。这些独立的代码称为插件。Ke......
  • 假期vue学习笔记04 插件
    exportdefault{  install(Vue){    //全局过滤器    Vue.filter('mySclice',function(value){      returnvalue.slice(0,4)    }),    //定义全局指令    Vue.directive('fbind',{      bind(......
  • PageHelper插件使用
    1.pom.xml引入依赖<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper</artifactId><version>5.1.11</version></dependency>2.mybatis-config.xml配置分页插件在MyBatis的配置文件中添加Page......
  • webpack-dev-server 插件问题 Content not from webpack is served from
    在安装了webpack-dev-server插件后启动然后一直报错 Contentnotfromwebpackisservedfrom XXXX在浏览器中访问 一直显示cannot  / 解决办法在wenbpack.config.js的配置文件中加入输出文件路径配置  devServer:{    static:{     ......
  • BOSHIDA DC电源模块如何故障排除与维修
    BOSHIDADC电源模块如何故障排除与维修首先,进行故障排查前,需要了解DC电源模块的工作原理和基本构造。DC电源模块通常由输入端子、输出端子、电感、电容、变压器、整流电路等组成。常见的故障包括输出电压异常、输出电流异常、过载保护触发、短路保护触发、输入电压异常等。 ......
  • 统一异常处理@ControllerAdvice及参数校验@Validated
    一、异常处理有异常就必须处理,通常会在方法后面throws异常,或者是在方法内部进行trycatch处理。直接throwsException直接throwsException,抛的异常太过宽泛,最好能抛出准确的异常,比如throwsIOException之类。UsergetUserById(Integerid)throwsIOException,BusinessE......
  • Vue3学习(二十)- 富文本插件wangeditor的使用
    写在前面学习、写作、工作、生活,都跟心情有很大关系,甚至有时候我更喜欢一个人独处,戴上耳机coding的感觉。明显现在的心情,比中午和上午好多了,心情超棒的,靠自己解决了两个问题:新增的时候点击TreeSelect控件控制台会给出报错分类新增和编辑时,报错父类和电子书iD不能为空的问题......
  • 【APP逆向16】frida反调试
    1.当我们对莫个app进行fridahook的时候,如果已启动hook脚本,app就自动退出了。这个时候可能就是app对frida进行了反调试。2.如何解决这种问题呢?反调试一般在so中实现,如果有frida使用,就给关闭app启动过程中,都有加载so文件下面的问题是如何找到反调试的so文件3.hookapp......
  • idea使用MybatisX插件根据表自动生成代码
    1.情景展示在实际开发过程中,根据数据库的表生成对应的增删改查代码,最为常见。除了使用公司封装的代码自动生成外,有没有通用的呢?2.具体分析在idea当中,我们可以使用MybatisX插件生成:表对应的实体类、dao层所使用的的mapper.java文件、mybatis对应的xml文件、service层所需的......