if (cfg.getNumOutgoingEdges(bb) == 2) { Iterator<Edge> iei = cfg.outgoingEdgeIterator(bb); while (iei.hasNext()) { Edge e = iei.next(); if (e.getType() == EdgeTypes.IFCMP_EDGE) { elseBB = e.getTarget(); } else if (e.getType() == EdgeTypes.FALL_THROUGH_EDGE) { thenBB = e.getTarget(); } } }  if ((thenBB == null) || (elseBB == null) ||  (thenBB.getFirstInstruction() == null) || (elseBB.getFirstInstruction() == null)) continue;  int thenStartPos = thenBB.getFirstInstruction().getPosition(); int elseStartPos = elseBB.getFirstInstruction().getPosition();  BasicBlock thenFinishBlock = findThenFinish(cfg, thenBB, elseStartPos);  if (thenFinishBlock == null) continue;  Instruction lastFinishIns = thenFinishBlock.getLastInstruction().getInstruction(); if (!(lastFinishIns instanceof GotoInstruction)) continue;  int thenFinishPos = thenFinishBlock.getLastInstruction().getPosition(); int elseFinishPos = ((GotoInstruction) lastFinishIns).getTarget().getPosition();  if (thenFinishPos >= elseStartPos) continue;  if ((thenFinishPos - thenStartPos) != (elseFinishPos - elseStartPos)) continue;  byte[] thenBytes = getCodeBytes(method, thenStartPos, thenFinishPos); byte[] elseBytes = getCodeBytes(method, elseStartPos, elseFinishPos);  if (!Arrays.equals(thenBytes, elseBytes)) continue;  bugReporter.reportBug(new BugInstance(this, "DB_DUPLICATE_BRANCHES", LOW_PRIORITY) .addClass(classContext.getJavaClass()) .addMethod(classContext.getJavaClass().getClassName(), method.getName(), method.getSignature()) .addSourceLineRange(this, thenBB.getFirstInstruction().getPosition(), thenBB.getLastInstruction().getPosition()) .addSourceLineRange(this, elseBB.getFirstInstruction().getPosition(), elseBB.getLastInstruction().getPosition()));
int numOutgoing = cfg.getNumOutgoingEdges(bb); if (numOutgoing == 2) findIfElseDuplicates(cfg, method, bb); else if (numOutgoing > 2) findSwitchDuplicates(cfg, method, bb);
	public void visitMethod(Method method) {		try {			if (method.getCode() == null)				return;						CFG cfg = classContext.getCFG(method);				Iterator<BasicBlock> bbi = cfg.blockIterator();			while (bbi.hasNext()) {				BasicBlock bb = bbi.next();				BasicBlock thenBB = null, elseBB = null;								if (cfg.getNumOutgoingEdges(bb) == 2) {					Iterator<Edge> iei = cfg.outgoingEdgeIterator(bb);					while (iei.hasNext()) {						Edge e = iei.next();						if (e.getType() == EdgeTypes.IFCMP_EDGE) {							elseBB = e.getTarget();						}						else if (e.getType() == EdgeTypes.FALL_THROUGH_EDGE) {							thenBB = e.getTarget();						}					}				}								if ((thenBB == null) || (elseBB == null) 				||  (thenBB.getFirstInstruction() == null) || (elseBB.getFirstInstruction() == null))					continue;								int thenStartPos = thenBB.getFirstInstruction().getPosition();				int elseStartPos = elseBB.getFirstInstruction().getPosition();								BasicBlock thenFinishBlock = findThenFinish(cfg, thenBB, elseStartPos);								if (thenFinishBlock == null)					continue;								Instruction lastFinishIns = thenFinishBlock.getLastInstruction().getInstruction();				if (!(lastFinishIns instanceof GotoInstruction))					continue;								int thenFinishPos = thenFinishBlock.getLastInstruction().getPosition();				int elseFinishPos = ((GotoInstruction) lastFinishIns).getTarget().getPosition();								if (thenFinishPos >= elseStartPos)					continue;								if ((thenFinishPos - thenStartPos) != (elseFinishPos - elseStartPos))					continue;								byte[] thenBytes = getCodeBytes(method, thenStartPos, thenFinishPos);				byte[] elseBytes = getCodeBytes(method, elseStartPos, elseFinishPos);								if (!Arrays.equals(thenBytes, elseBytes))					continue;								bugReporter.reportBug(new BugInstance(this, "DB_DUPLICATE_BRANCHES", LOW_PRIORITY)						.addClass(classContext.getJavaClass())						.addMethod(classContext.getJavaClass().getClassName(), method.getName(), method.getSignature())						.addSourceLineRange(this, 								thenBB.getFirstInstruction().getPosition(),								thenBB.getLastInstruction().getPosition())						.addSourceLineRange(this, 								elseBB.getFirstInstruction().getPosition(),								elseBB.getLastInstruction().getPosition()));			}		} catch (Exception e) {			bugReporter.logError("Failure examining basic blocks in Duplicate Branches detector", e);		}	}