excessivelengthrule.java
来自「检查Java程序漏洞」· Java 代码 · 共 42 行
JAVA
42 行
/** * BSD-style license; for more info see http://pmd.sourceforge.net/license.html*/package net.sourceforge.pmd.rules.design;import net.sourceforge.pmd.ast.SimpleNode;import net.sourceforge.pmd.stat.DataPoint;import net.sourceforge.pmd.stat.StatisticalRule;/** * This is a common super class for things which * have excessive length. * * i.e. LongMethod and LongClass rules. * * To implement an ExcessiveLength rule, you pass * in the Class of node you want to check, and this * does the rest for you. */public class ExcessiveLengthRule extends StatisticalRule { private Class nodeClass; public ExcessiveLengthRule(Class nodeClass) { this.nodeClass = nodeClass; } public Object visit(SimpleNode node, Object data) { if (nodeClass.isInstance(node)) { DataPoint point = new DataPoint(); point.setLineNumber(node.getBeginLine()); point.setScore(1.0 * (node.getEndLine() - node.getBeginLine())); point.setRule(this); point.setMessage(getMessage()); addDataPoint(point); } return node.childrenAccept(this, data); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?