• PMD教程



    1.单词
    violations outline:错误大纲
    2.错误级别
    红色
    很高的错误
    橙色
    错误
    黄色
    很高的警告
    绿色
    警告
    蓝色
    输出信息
    3.提示
    Avoid excessively long variable names like machineLineService
    避免像machineLineService的命名
    Local variable 'queryString' could be declared fina
    变量应该定义为final
    Package name contains upper case characters
    包名不应该大写
    - Avoid instantiating new objects
    inside loops
    避免再循环中重复的构建实例
    parameter 'ch' is not assigned and could be declared final
    参数不分,可以声明为final
    Variables that are not final should not contain underscores (except for underscores in standard prefix/suffix).
    不是最终的变量不应该带有下划线
    Assigning an Object to null is a code smell. Consider
    refactoring.
    为分配一个对象的代码认为时重构的
    得出来的规范
    1.变量名字要短
    2.不变的string变量要定义为final
    3.包名不应该大写
    4.最终的变量应该多次命名应该带有下划线
    5.avoid循环重复new对象
    6.不应该多用括号
    7.一个方法应该只有一个返回点
    8.使用集合的类的isEmpty()判断集合是否为空
    9.符号之间的要空格
    10.捕捉了异常再抛出了异常
    11.如果字符串的变量多次使用,那么定义为常量
    12.不要实例化Sting对象,那样会破坏享元策略
    13.方法的名字一定要第一个单词小写,之后每一个单词的首字母大写
    14.
    violations Overview
    Element 包中类的建议提示
    #Violations
    建议级别
    #Violations/LOC
    #Violations/Method
    Project
    属于那个项目里边的
    violations Overview 视图的提示
    LongVariable
    变量过长
    MethodeArgumentCouldBeFinal
    AvoidInstantiatingObjectsInLoops
    循环中重复new对象
    LocalVariableCouldBeFinal
    变量定义应该用final
    使用的时候检测错误有没有解决就手动 在Violations Overview中右键类选择check code with pmd
    优化策略
    1.避免多个返回点
    2.简化if-else 如果出现在返回值时,返回决定
    3.不要给Boolean,Integer和String 类型创建新的实例
    4.以final类型标记方法参数
    5.switch里面要有default
    6.final只会负责不可变他负责的那一片内存地址

  • 相关阅读:
    UWP开发必备:常用数据列表控件汇总比较
    CodeForces 372 A. Counting Kangaroos is Fun
    ubuntu 13.10 eclipse 菜单栏不可用的问题
    Codeforces Round #219(Div. 2)373 B. Making Sequences is Fun(二分+找规律)
    Git/Github使用方法小记
    Ubuntu 下jdk的安装
    VIM简明教程
    codeforces 371 C-Hamburgers
    codeforces 371A K-Periodic Array
    计算机网络中IP地址和MAC地址
  • 原文地址:https://www.cnblogs.com/thehugo/p/6755114.html
Copyright © 2020-2023  润新知