Showing 7,775 of 7,775 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
public static List<String> addProperties(String key, List<String> values) {
if (key == null) throw new NullPointerException();
if (key.length() == 0) throw new IllegalArgumentException();
synchronized (_props) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 83.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method zzRefill
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private boolean zzRefill() throws java.io.IOException {
/* first: make room (if you can) */
if (zzStartRead > 0) {
System.arraycopy(zzBuffer, zzStartRead,
Method normalize
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final String normalize(String path) {
if (path == null)
return "";
//remove consecutive slashes
Method checkNamespacePrefix
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final void checkNamespacePrefix(String prefix, Locator loc) {
if (prefix == null || prefix.length() == 0)
return; //OK: null or empty
String reason = null;
Method write
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private Method write(ELContext ctx) {
if (this.write == null) {
this.write = Util.getMethod(this.owner, descriptor.getWriteMethod());
//20110921, henrichen: Introspector is too strict for Setter(must return void), here we loosen it
Method Boolean
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
final public void Boolean() throws ParseException {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TRUE:
AstTrue jjtn001 = new AstTrue(JJTTRUE);
boolean jjtc001 = true;
Method buildParameters
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
static Object[] buildParameters(Class<?>[] parameterTypes,
boolean isVarArgs,Object[] params) {
ExpressionFactory factory = getExpressionFactory();
Object[] parameters = null;
if (parameterTypes.length > 0) {
Method buildStaticModel
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static TreeNode<User> buildStaticModel(String data) {
DefaultTreeNode<User> root = node("",
node(data + "-1",
node(data + "-1-1",
node(data + "-1-1-1"),
Method addTreeNode
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private BugOasiTreeNode<BugFormModel> addTreeNode(
BugOasiTreeNode<BugFormModel> parent,
BugOasiTreeNode<BugFormModel> newnod, BugFormModel myrow, boolean open,
Integer pos) {
if (parent == null) {
Method buildStaticModel
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static TreeNode<String> buildStaticModel(String data) {
DefaultTreeNode<String> root = node("",
node(data + "-1",
node(data + "-1-1",
node(data + "-1-1-1"),
Method outSpecialJS
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final String outSpecialJS(Desktop desktop) {
final StringBuffer sb = new StringBuffer();
//output application name
String oldnm = (String) desktop.getAttribute(ATTR_APPNM);
Method parseLibProperty
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void parseLibProperty(Element el) {
final String nm = IDOMs.getRequiredElementValue(el, "name");
Element valueElmn = el.getElement("value");
Element appendableElmn = el.getElement("appendable");
boolean appendable = appendableElmn != null ? "true".equals(appendableElmn.getText(true)) : false;
Method injectByMethod
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private boolean injectByMethod(Method md, Class<?> parmcls, Class<?> argcls, Object arg, String fdname) {
if (argcls == null || parmcls.isAssignableFrom(argcls)) {
final Field fd = _fldMaps.get(fdname);
if (fd != null && fd.getType().equals(parmcls)) {
final boolean old = fd.isAccessible();
Method lookup
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final LanguageDefinition lookup(String name) {
init();
if (name == null || name.length() == 0)
name = "xul/html";
Method parseTemplate
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static TemplateInfo parseTemplate(NodeInfo parent, Element el, AnnotationHelper annHelper)
throws Exception {
if (annHelper.clear())
log.warn(message("Annotations are ignored since <template> doesn't support them", el));
if (el.getAttributeItem("forEach") != null)
Method setPageBefore
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void setPageBefore(Page page, Component refRoot) {
beforeComponentPageChanged(page);
if (refRoot != null && (page == null || refRoot.getParent() != null || refRoot.getPage() != page))
refRoot = null;
if (refRoot != null /*&& refRoot.getPage() == page (checked)*/
Method addResponse
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void addResponse(String key, AuResponse response, int priority) {
if (response == null)
throw new IllegalArgumentException();
//relative fix BUG ZK-1464
Method onEvent
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void onEvent(Event event) throws Exception {
final long max = System.currentTimeMillis() + getMaxSchedTime();
if (log.isDebugEnabled()) {
log.debug("Handling schedule server push, _schedInfos is empty: [{}]", !scheduledServerPush());
}
Method meterAuClient
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void meterAuClient(PerformanceMeter pfmeter, Execution exec, String hdr, boolean complete) {
for (int j = 0;;) {
int k = hdr.indexOf(',', j);
String ids = k >= 0 ? hdr.substring(j, k) : j == 0 ? hdr : hdr.substring(j);
Method getDeviceByClient
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final Device getDeviceByClient(String userAgent) throws DeviceNotFoundException {
String[] devTypes;
synchronized (_devmap) {
Collection<String> c = _devmap.keySet();
devTypes = c.toArray(new String[c.size()]);