auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public boolean isValid(Object[] array, ConstraintValidatorContext constraintValidatorContext) { if ( array == null ) { return false; } START return Array.getLength( array ) > 0; END } Interesting, what's the rationale for not using array.length?

Target:
public boolean isValid(Object[] array, ConstraintValidatorContext constraintValidatorContext) { if ( array == null ) { return false; } return array.length > 0; }
Source:
public String getDescription() { START return null; END } This needs to be implemented?

Target:
public String getDescription() { return ""; }
Source:
private static HttpScheme connectionScheme(ChannelHandlerContext ctx) { final HttpScheme scheme = connectionSchemeAttribute(ctx).get(); START return (scheme == null) ? HttpScheme.HTTP : scheme; END } nit: you can remove the `()`

Target:
private static HttpScheme connectionScheme(ChannelHandlerContext ctx) { final HttpScheme scheme = connectionSchemeAttribute(ctx).get(); return scheme == null ? HttpScheme.HTTP : scheme; }
Source:
public String START getDescription() END { if (description == null || description.isEmpty()) { } return description; } set your feature as transient

Target:
public String getDescription() { return description; }
Source:
public String getTitle() { START return this.id; END } `this.id` -> `id`

Target:
public String getTitle() { return id; }
Source:
private void buildIndex() { int i = 0; index.clear(); Entry q = head; while (q != null) { START if (++i % 100 == 0) { END index.add(q); } q = q.next; } } style nit: we don't use braces around single line blocks

Target:
private void buildIndex() { int i = 0; index.clear(); Entry q = head; while (q != null) { if (++i % 100 == 0) index.add(q); q = q.next; } }
Source:
private URL deploymentOne() throws Throwable { START System.out.println("deployment"); END return new URL("http://blah.com"); } Remove this

Target:
private URL deploymentOne() throws Throwable { return new URL("http://blah.com"); }
Source:
public static void initialize(Props props) { if (props == null) { throw new NullPointerException("props argument can't be null"); } START instance = new JobCallbackRequestMaker(props); END isInitialized = true; logger.info("Initialization for " + JobCallbackRequestMaker.class.getName() + " is completed"); } return right away if initialized already?

Target:
public static void initialize(Props props) { if (props == null) { throw new NullPointerException("props argument can't be null"); } if (isInitialized) { return; } instance = new JobCallbackRequestMaker(props); isInitialized = true; logger.info("Initialization for " + JobCallbackRequestMaker.class.getName() + " is completed"); }
Source:
void cancel() { START if (callback != null) { END callback = null; } ImageView target = this.target.get(); if (target == null) { return; } ViewTreeObserver vto = target.getViewTreeObserver(); if (!vto.isAlive()) { return; } vto.removeOnPreDrawListener(this); } This check can be dropped.

Target:
void cancel() { callback = null; ImageView target = this.target.get(); if (target == null) { return; } ViewTreeObserver vto = target.getViewTreeObserver(); if (!vto.isAlive()) { return; } vto.removeOnPreDrawListener(this); }
Source:
protected Map<K, V> copy(Map<K, V> source, Map dest) { for (Entry<K, V> entry : source.entrySet()) { K key = entry.getKey(); START K altKey; END if (key instanceof String) { altKey = (K) new CaseInsensitiveString((String) key); } else { altKey = key; } dest.put(altKey, entry.getValue()); } return dest; } I think we could get rid of the `altKey` variable and the corresponding else block as well.

Target:
protected Map<K, V> copy(Map<K, V> source, Map dest) { for (Entry<K, V> entry : source.entrySet()) { K key = entry.getKey(); if (key instanceof String) { key = (K) new CaseInsensitiveString((String) key); } dest.put(key, entry.getValue()); } return dest; }
Source:
protected void limitTotalNumberOfCnxns() throws IOException { if (maxCnxns <= 0) { // maxCnxns limit is disabled return; } int cnxns = getNumAliveConnections(); if (cnxns >= maxCnxns) { START throw new IOException("Too many connections " + cnxns + " - max is " + maxCnxns); END } } A graceful shutdown would be nice. See the use of `ServerMetrics.getMetrics().CONNECTION_REJECTED` in the code base. Alternately, could reuse the `ClientCnxnLimitException` exception.

Target:
protected boolean limitTotalNumberOfCnxns() { if (maxCnxns <= 0) { // maxCnxns limit is disabled return false; } int cnxns = getNumAliveConnections(); if (cnxns >= maxCnxns) { LOG.error("Too many connections " + cnxns + " - max is " + maxCnxns); return true; } return false; }
Source:
START public static TLSClientParametersFactory getInstance() { END if (tlsCPFactory == null) { tlsCPFactory = new TLSClientParametersFactory(); } return tlsCPFactory; } Consider using a Singleton pattern here. For an example within the CONNECT codebase, see X12EntityExceptionBuilder.java.

Target:
public static TLSClientParametersFactory getInstance() { return tlsCPFactory; }
Source:
public static XmlForm parse(String xml, boolean strict) throws IOException { ObjectMapper objectMapper = new XmlMapper(); if (!strict) { objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); //For production, ignore unknown stuff } XmlForm form = objectMapper.readValue(xml, XmlForm.class); START System.out.println(form); //Debug only END return form; } Maybe incorportate it into debug logging instead? `log.fine`?

Target:
public static XmlForm parse(String xml, boolean strict) throws IOException { ObjectMapper objectMapper = new XmlMapper(); if (!strict) { objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); //For production, ignore unknown stuff } XmlForm form = objectMapper.readValue(xml, XmlForm.class); return form; }
Source:
protected BitmapFont newBitmapFont(BitmapFont.BitmapFontData data, Array<TextureRegion> pageRegions, boolean integer) { START return new BitmapFont(data, pageRegions, true); END } it should use integer parameter instead of true i think

Target:
protected BitmapFont newBitmapFont(BitmapFont.BitmapFontData data, Array<TextureRegion> pageRegions, boolean integer) { return new BitmapFont(data, pageRegions, integer); }