Showing 7,775 of 7,775 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
private static boolean doSort(Listbox listbox) {
Listhead hds = listbox.getListhead();
if (!listbox.isAutosort() || hds == null)
return false;
for (Iterator<Component> it = hds.getChildren().iterator(); it.hasNext();) {
- 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 102.
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 checkAdd
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void checkAdd(Item newVal, Item other, boolean replace) {
//allowed type?
if (!(newVal instanceof Element) && !(newVal instanceof Text)
&& !(newVal instanceof CData) && !(newVal instanceof Comment)
&& !(newVal instanceof EntityReference) && !(newVal instanceof Binary)
Method doGet
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Servlets.getBrowser(request); //update request info
final String path = Https.getThisServletPath(request);
Method toString
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final String toString(Object o) {
if (o == null) return null;
if (o instanceof Date) return DateFormats.format((Date)o, false);
if (o instanceof Class) {
final Class cls = (Class)o;
Method initialise
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuffer expected = new StringBuffer();
Method coerceToCollection
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressWarnings({ "rawtypes", "unchecked" })
private static Object coerceToCollection(Object obj, Class<?> type) {
if(obj==null) return null;
// since 8.0.0 support proxy form binding
if (ProxyFactory.isProxyClass(type)) {
Method render
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void render(final Treeitem treeItem, B70_ZK_2460_ContactTreeNode treeNode, int index) throws Exception {
B70_ZK_2460_ContactTreeNode ctn = treeNode;
B70_ZK_2460_Contact B70_ZK_2460_Contact = (B70_ZK_2460_Contact) ctn.getData();
final Treerow dataRow = new Treerow();
dataRow.setParent(treeItem);
Method isAnnotation
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static boolean isAnnotation(String val) {
int len = val.length();
if (len >= 4) {
len = (val = val.trim()).length();
if (len >= 4 && val.charAt(0) == '@') {
Method destroy
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void destroy() {
final ExecutionMonitor execmon = _wapp != null //just in case
? _wapp.getConfiguration().getExecutionMonitor() : null;
_rque = null; //denote it is destroyed
Method execNonComponent
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static final void execNonComponent(CreateInfo ci, Component comp, Object meta) {
final Page page = ci.page;
if (meta instanceof AttributesInfo) {
final AttributesInfo attrs = (AttributesInfo) meta;
if (comp != null)
Method create
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Component[] create(Component parent, Component insertBefore, VariableResolver resolver,
Composer composer) {
final Execution exec = Executions.getCurrent();
final ExecutionCtrl execCtrl = (ExecutionCtrl) exec;
final Component[] cs;
Method doBeforeComposeChildren
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void doBeforeComposeChildren(final Component comp) throws Exception {
//ZK-3831
if (comp.getPage() == null) {
final Map<?, ?> currentArg = Executions.getCurrent().getArg();
((ComponentCtrl) comp).addCallback(ComponentCtrl.AFTER_PAGE_ATTACHED, new Callback() {
Method initRendererIfAny
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void initRendererIfAny(Component comp, String attr) {
final Object installed = comp.getAttribute(BinderCtrl.RENDERER_INSTALLED);
if (installed != null) { //renderer was set already init
return;
}
Method getConverter
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Converter getConverter(String name) {
checkInit();
Converter converter = null;
if (_hasGetConverterMethod) {
Object vm = getViewModel();
Method getValidator
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Validator getValidator(String name) {
checkInit();
Validator validator = null;
if (_hasGetValidatorMethod) {
Object vm = getViewModel();
Method addFormAssociatedSaveBinding
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void addFormAssociatedSaveBinding(Component associatedComp, String formId, SaveBinding saveBinding,
String fieldName) {
checkInit();
//find the form component by form id and a associated/nested component
Component formComp = lookupAssociatedFormComponent(formId, associatedComp);
Method getLoadBindingsPerProperty
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void getLoadBindingsPerProperty(Collection<TrackerNode> nodes, String prop,
LinkedHashSet<LoadBinding> bindings, LinkedHashSet<Object> kidbases, Set<TrackerNode> visited) {
if (".".equals(prop)) { //all base object
for (TrackerNode node : nodes) {
getLoadBindings0(node, bindings, kidbases, visited);
Method show
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Button show(String message, String title, Button[] buttons, String[] btnLabels, String icon,
Button focus, EventListener<ClickEvent> listener, Map<String, String> params) {
final Map<String, Object> arg = new HashMap<String, Object>();
final Desktop desktop = Executions.getCurrent().getDesktop();
arg.put("message", message);
Method getAvailableAtClient
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected Set<? extends Component> getAvailableAtClient(int offset, int limit, boolean itemOnly) {
final Set<Component> avail = new LinkedHashSet<Component>(32);
if (!itemOnly) {
avail.addAll(_listbox.getHeads());
final Listfoot listfoot = _listbox.getListfoot();
Method include
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void include(RenderRequest request, RenderResponse response) throws PortletException, java.io.IOException {
try {
// B60-ZK-1337: issues with RenderHttpServletRequest/RenderHttpServletResponse Wrapper
// will cause ServletException: Original SevletRequest or wrapped original ServletRequest
// not passed to RequestDispatcher in violation of SRV.8.2 and SRV.14.2.5.1