auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected void onLoad() { enableForm(false); super.onLoad(); Util.PROJECT_SVC.projectDetail(projectName, new GerritCallback<ProjectDetail>() { public void onSuccess(final ProjectDetail result) { enableForm(true); display(result); <START> addPanel.setVisible(result.canModifyData); <END> delRight.setVisible(result.canModifyData); } }); }</code><technical_language>This canModifyData. I overloaded variable for meanings. need is: * canModifyDescription * canModifyMergeType * canModifyAgreements * canModifyAccess 3 true if projectControl.isOwner() is true. is true if projectControl.isOwnerAnyRef() is true, is want for addPanel</technical_language>

Target:
protected void onLoad() { enableForm(false); super.onLoad(); Util.PROJECT_SVC.projectDetail(projectName, new GerritCallback<ProjectDetail>() { public void onSuccess(final ProjectDetail result) { enableForm(true); display(result); } }); }
Source:
<code>public void assignUpstream(StateSystem ss) { backend = new InMemoryBackend(ss.getStartTime()); <START> transState = new TransientState(this.getBackend()); <END> realStateSystem = ss; ssAssignedLatch.countDown(); }</code><technical_language>mentioned in other file, fields remain private final, do this here. 'backend' refers usual backend of state system insert state intervals. I leave this a NullBackend, this class's constructor does. cache implemented a InMemoryBackend a new separate field (especially if want more one, eventually). insert in backend intervals "manually". workarounds specific partial backend stay in here. that, transState remain normal transState set StateSystem's constructor</technical_language>

Target:
public void assignUpstream(StateSystem ss) { setBackend(new InMemoryBackend(ss.getStartTime())); setTransientState(new TransientState(getBackend())); realStateSystem = ss; ssAssignedLatch.countDown(); }
Source:
<code>public NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(int userId) { enforceAccessPermission(); HashMap<Network, NetworkCapabilities> result = new HashMap<Network, NetworkCapabilities>(); NetworkAgentInfo nai = getDefaultNetwork(); NetworkCapabilities nc = getNetworkCapabilitiesInternal(nai); if (nc != null) { result.put(nai.network, nc); } synchronized (mVpns) { if (!mLockdownEnabled) { Vpn vpn = mVpns.get(userId); if (vpn != null) { Network[] networks = vpn.getUnderlyingNetworks(); if (networks != null) { for (Network network : networks) { nai = getNetworkAgentInfoForNetwork(network); nc = getNetworkCapabilitiesInternal(nai); if (nc != null) { <START> nc.setUids(null); <END> result.put(network, nc); } } } } } } NetworkCapabilities[] out = new NetworkCapabilities[result.size()]; out = result.values().toArray(out); return out; }</code><technical_language>this getNetworkCapabilitiesInternal instead</technical_language>

Target:
public NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(int userId) { enforceAccessPermission(); HashMap<Network, NetworkCapabilities> result = new HashMap<Network, NetworkCapabilities>(); NetworkAgentInfo nai = getDefaultNetwork(); NetworkCapabilities nc = getNetworkCapabilitiesInternal(nai); if (nc != null) { result.put(nai.network, nc); } synchronized (mVpns) { if (!mLockdownEnabled) { Vpn vpn = mVpns.get(userId); if (vpn != null) { Network[] networks = vpn.getUnderlyingNetworks(); if (networks != null) { for (Network network : networks) { nai = getNetworkAgentInfoForNetwork(network); nc = getNetworkCapabilitiesInternal(nai); if (nc != null) { result.put(network, nc); } } } } } } NetworkCapabilities[] out = new NetworkCapabilities[result.size()]; out = result.values().toArray(out); return out; }
Source:
<code>protected boolean consumeNextMessage() { Message rawMessage = null; try { boolean hasNext = mMessageReader.hasNext(); if (!hasNext) { return false; } rawMessage = mMessageReader.read(); } catch (ConsumerTimeoutException e) { LOG.trace("Consumer timed out", e); } if (rawMessage != null) { try { mMessageWriter.adjustOffset(rawMessage); } catch (IOException e) { throw new RuntimeException("Failed to adjust offset.", e); } ParsedMessage parsedMessage = null; try { Message transformedMessage = mMessageTransformer.transform(rawMessage); parsedMessage = mMessageParser.parse(transformedMessage); final double DECAY = 0.999; mUnparsableMessages *= DECAY; } catch (Throwable e) { <START> mMetricCollector.increment("consumer.message_errors.count", "topic:" + rawMessage.getTopic()); <END> mUnparsableMessages++; final double MAX_UNPARSABLE_MESSAGES = 1000.; if (mUnparsableMessages > MAX_UNPARSABLE_MESSAGES) { throw new RuntimeException("Failed to parse message " + rawMessage, e); } LOG.warn("Failed to parse message {}", rawMessage, e); } if (parsedMessage != null) { try { mMessageWriter.write(parsedMessage); mMetricCollector.metric("consumer.message_size_bytes", rawMessage.getPayload().length, "topic:" + rawMessage.getTopic()); mMetricCollector.increment("consumer.throughput_bytes", rawMessage.getPayload().length, "topic:" + rawMessage.getTopic()); } catch (Exception e) { throw new RuntimeException("Failed to write message " + parsedMessage, e); } } } return true; }</code><technical_language>'topic:' explicit argument 'increment' call instead of concat string</technical_language>

Target:
protected boolean consumeNextMessage() { Message rawMessage = null; try { boolean hasNext = mMessageReader.hasNext(); if (!hasNext) { return false; } rawMessage = mMessageReader.read(); } catch (ConsumerTimeoutException e) { LOG.trace("Consumer timed out", e); } if (rawMessage != null) { try { mMessageWriter.adjustOffset(rawMessage); } catch (IOException e) { throw new RuntimeException("Failed to adjust offset.", e); } ParsedMessage parsedMessage = null; try { Message transformedMessage = mMessageTransformer.transform(rawMessage); parsedMessage = mMessageParser.parse(transformedMessage); final double DECAY = 0.999; mUnparsableMessages *= DECAY; } catch (Throwable e) { mMetricCollector.increment("consumer.message_errors.count", rawMessage.getTopic()); mUnparsableMessages++; final double MAX_UNPARSABLE_MESSAGES = 1000.; if (mUnparsableMessages > MAX_UNPARSABLE_MESSAGES) { throw new RuntimeException("Failed to parse message " + rawMessage, e); } LOG.warn("Failed to parse message {}", rawMessage, e); } if (parsedMessage != null) { try { mMessageWriter.write(parsedMessage); mMetricCollector.metric("consumer.message_size_bytes", rawMessage.getPayload().length, rawMessage.getTopic()); mMetricCollector.increment("consumer.throughput_bytes", rawMessage.getPayload().length, rawMessage.getTopic()); } catch (Exception e) { throw new RuntimeException("Failed to write message " + parsedMessage, e); } } } return true; }
Source:
<code>protected boolean checkComplete() { if (super.checkComplete()) { if (full_query_context != null && (context.query().getCacheMode() == CacheMode.NORMAL || context.query().getCacheMode() == CacheMode.WRITEONLY)) { if (full_query_context.cacheable()) { <START> full_query_caching.set(true); <END> context.tsdb().getQueryThreadPool().submit(new Runnable() { @Override public void run() { try { cache.cache(slices, keys, expirations, sub_results, null) .addBoth(new Callback<Void, Void>() { @Override public Void call(Void arg) throws Exception { for (final QueryResult result : sub_results) { if (result != null) { try { result.close(); } catch (Exception e) { LOG.warn("Failed t oclose result: " + result, e); } } } try { full_query_context.close(); } catch (Exception e) { LOG.warn("Failed to close full query context", e); } return null; } }); } catch (Throwable t) { LOG.error("Failed to cache the data", t); } } }, context); } else { if (LOG.isDebugEnabled()) { LOG.debug("Will not cache full query as it's marked as not cacheable."); } for (final QueryResult result : sub_results) { if (result != null) { try { result.close(); } catch (Exception e) { LOG.warn("Failed t oclose result: " + result, e); } } } } } return true; } return false; }</code><technical_language>consumes this new field</technical_language>

Target:
protected boolean checkComplete() { if (super.checkComplete()) { if (full_query_context != null && (context.query().getCacheMode() == CacheMode.NORMAL || context.query().getCacheMode() == CacheMode.WRITEONLY)) { if (full_query_context.cacheable()) { context.tsdb().getQueryThreadPool().submit(new Runnable() { @Override public void run() { try { cache.cache(slices, keys, expirations, sub_results, null) .addBoth(new Callback<Void, Void>() { @Override public Void call(Void arg) throws Exception { for (final QueryResult result : sub_results) { if (result != null) { try { result.close(); } catch (Exception e) { LOG.warn("Failed t oclose result: " + result, e); } } } try { full_query_context.close(); } catch (Exception e) { LOG.warn("Failed to close full query context", e); } return null; } }); } catch (Throwable t) { LOG.error("Failed to cache the data", t); } } }, context); } else { if (LOG.isDebugEnabled()) { LOG.debug("Will not cache full query as it's marked as not cacheable."); } for (final QueryResult result : sub_results) { if (result != null) { try { result.close(); } catch (Exception e) { LOG.warn("Failed t oclose result: " + result, e); } } } } } return true; } return false; }
Source:
<code>protected void setUp() throws Exception { Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl() { @Override public Resource createResource(URI uri) { return new XMIResourceImpl(uri) { @Override protected boolean useUUIDs() { <START> System.out.println("useUUIDs"); <END> return false; } }; } }); copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, LIBRARY_PROJECT, PATH, Lists.newArrayList(SEMANTIC_MODEL_LIB, AIRD_LIB_1)); genericSetUp(Collections.singletonList(toURI(LIBRARY_PROJECT + "/" + SEMANTIC_MODEL_LIB, ResourceURIType.RESOURCE_PLATFORM_URI)), Collections.<URI> emptyList(), true, toURI(LIBRARY_PROJECT + "/" + AIRD_LIB_1, ResourceURIType.RESOURCE_PLATFORM_URI)); sessionLibrary = session; copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, CONSUMER_PROJECT, PATH, Lists.newArrayList(SEMANTIC_MODEL_CONSUMER, AIRD_CONSUMER_1)); genericSetUp(Collections.singletonList(toURI(CONSUMER_PROJECT + "/" + SEMANTIC_MODEL_CONSUMER, ResourceURIType.RESOURCE_PLATFORM_URI)), Collections.<URI> emptyList(), true, toURI(CONSUMER_PROJECT + "/" + AIRD_CONSUMER_1, ResourceURIType.RESOURCE_PLATFORM_URI)); }</code><technical_language>Avoid sysout needed in code..</technical_language>

Target:
protected void setUp() throws Exception { Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl() { @Override public Resource createResource(URI uri) { return new XMIResourceImpl(uri) { @Override protected boolean useUUIDs() { return false; } }; } }); copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, LIBRARY_PROJECT, PATH, Lists.newArrayList(SEMANTIC_MODEL_LIB, AIRD_LIB_1)); genericSetUp(Collections.singletonList(toURI(LIBRARY_PROJECT + "/" + SEMANTIC_MODEL_LIB, ResourceURIType.RESOURCE_PLATFORM_URI)), Collections.<URI> emptyList(), true, toURI(LIBRARY_PROJECT + "/" + AIRD_LIB_1, ResourceURIType.RESOURCE_PLATFORM_URI)); sessionLibrary = session; copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, CONSUMER_PROJECT, PATH, Lists.newArrayList(SEMANTIC_MODEL_CONSUMER, AIRD_CONSUMER_1)); genericSetUp(Collections.singletonList(toURI(CONSUMER_PROJECT + "/" + SEMANTIC_MODEL_CONSUMER, ResourceURIType.RESOURCE_PLATFORM_URI)), Collections.<URI> emptyList(), true, toURI(CONSUMER_PROJECT + "/" + AIRD_CONSUMER_1, ResourceURIType.RESOURCE_PLATFORM_URI)); }
Source:
<code>public void testInitializationWithUriAndConf_shouldGiveFsStatusWithNotUsedMemory() throws IOException, URISyntaxException { <START> assertThat(new GoogleHadoopFS(initUri, loadConfig()).getFsStatus().getUsed()).isEqualTo(0); <END> }</code><technical_language>fs for initialization extract GoogleHadoopFS local variable here, below</technical_language>

Target:
public void testInitializationWithUriAndConf_shouldGiveFsStatusWithNotUsedMemory() throws IOException, URISyntaxException { Configuration config = GoogleHadoopFileSystemIntegrationHelper.getTestConfig(); GoogleHadoopFS ghfs = new GoogleHadoopFS(initUri, config); assertThat(ghfs.getFsStatus().getUsed()).isEqualTo(0); }
Source:
<code>public int hashCode() { <START> int result = text.hashCode(); <END> result = 31 * result + read.hashCode(); result = 31 * result + spamPrediction.hashCode(); return result; }</code><technical_language>for consistency other classes, Objects.hash()</technical_language>

Target:
public int hashCode() { int result = Objects.hash(text, read, spamPrediction); return result; }
Source:
<code>public void changeTheme() { if (game == null) return; IBoard board = game.getBoard(); if (board.inSpace()) return; Set<String> themes = tileManager.getThemes(); if (themes.remove("")) themes.add("(No Theme)"); themes.add("(Original Theme)"); setShouldIgnoreKeys(true); selectedTheme = (String)JOptionPane.showInputDialog( null, "Choose the desired theme:", "Theme Selection", JOptionPane.PLAIN_MESSAGE, null, themes.toArray(), selectedTheme); setShouldIgnoreKeys(false); if (selectedTheme == null) { return; <START> } final List<Coords> allCoords = allBoardHexes(); if (allCoords == null) { return; } if (selectedTheme.equals("(Original Theme)")) { for (Coords c: allCoords) { IHex hex = board.getHex(c); hex.resetTheme(); board.setHex(c, hex); } } else { for (Coords c: allCoords) { <END> IHex hex = board.getHex(c); hex.setTheme(selectedTheme.equals("(No Theme)")? "":selectedTheme); board.setHex(c, hex); } } }</code><technical_language>change instead of fixing allBoardHexes() erroneous null return replacing Collections.emptyList() (the return of ArrayList swapped List issue)</technical_language>

Target:
public void changeTheme() { if (game == null) return; IBoard board = game.getBoard(); if (board.inSpace()) return; Set<String> themes = tileManager.getThemes(); if (themes.remove("")) themes.add("(No Theme)"); themes.add("(Original Theme)"); setShouldIgnoreKeys(true); selectedTheme = (String)JOptionPane.showInputDialog( null, "Choose the desired theme:", "Theme Selection", JOptionPane.PLAIN_MESSAGE, null, themes.toArray(), selectedTheme); setShouldIgnoreKeys(false); if (selectedTheme == null) { return; } if (selectedTheme.equals("(Original Theme)")) { for (Coords c: allBoardHexes()) { IHex hex = board.getHex(c); hex.resetTheme(); board.setHex(c, hex); } } else { for (Coords c: allBoardHexes()) { IHex hex = board.getHex(c); hex.setTheme(selectedTheme.equals("(No Theme)")? "":selectedTheme); board.setHex(c, hex); } } }
Source:
<code>public static PGType get(DataType<?> type) { <START> switch (type.id()) { <END> case ArrayType.ID: { DataType<?> innerType = ((ArrayType<?>) type).innerType(); if (innerType.id() == ArrayType.ID) { return JsonType.INSTANCE; } else if (innerType.id() == ObjectType.ID) { return PGArray.JSON_ARRAY; } PGType pgType = CRATE_TO_PG_TYPES.get(type); if (pgType == null) { throw new IllegalArgumentException( String.format(Locale.ENGLISH, "No type mapping from '%s' to pg_type", type.getName())); } return pgType; } case ObjectType.ID: { return JsonType.INSTANCE; } case RowType.ID: return new RecordType(Lists2.map(((RowType) type).fieldTypes(), PGTypes::get)); default: { PGType pgType = CRATE_TO_PG_TYPES.get(type); if (pgType == null) { throw new IllegalArgumentException( String.format(Locale.ENGLISH, "No type mapping from '%s' to pg_type", type.getName())); } return pgType; } } }</code><technical_language>Do need handle array of row type separately, a special handling for [RowType](<LINK_0></technical_language>

Target:
public static PGType get(DataType<?> type) { switch (type.id()) { case ArrayType.ID: { DataType<?> innerType = ((ArrayType<?>) type).innerType(); if (innerType.id() == ArrayType.ID) { return JsonType.INSTANCE; } else if (innerType.id() == ObjectType.ID) { return PGArray.JSON_ARRAY; } else if (innerType.id() == RowType.ID) { return new PGArray(PGArray.EMPTY_RECORD_ARRAY.oid(), get(innerType)); } PGType pgType = CRATE_TO_PG_TYPES.get(type); if (pgType == null) { throw new IllegalArgumentException( String.format(Locale.ENGLISH, "No type mapping from '%s' to pg_type", type.getName())); } return pgType; } case ObjectType.ID: { return JsonType.INSTANCE; } case RowType.ID: return new RecordType(Lists2.map(((RowType) type).fieldTypes(), PGTypes::get)); default: { PGType pgType = CRATE_TO_PG_TYPES.get(type); if (pgType == null) { throw new IllegalArgumentException( String.format(Locale.ENGLISH, "No type mapping from '%s' to pg_type", type.getName())); } return pgType; } } }
Source:
<code>public LookupBean( @JsonProperty("name") String name, @Deprecated @JsonProperty("factory") LookupExtractorFactory factory, @JsonProperty("container") LookupExtractorFactoryContainer container ) { <START> Preconditions.checkArgument(factory == null || container == null, "only one of factory or container should exist"); <END> Preconditions.checkArgument(factory != null || container != null, "one of factory or container must exist"); this.name = name; this.container = container != null ? container : new LookupExtractorFactoryContainer(null, factory); }</code><technical_language>If factory is null container is null, this check pass. Suggested a single factory == null ^ container == null check instead of lines</technical_language>

Target:
public LookupBean( @JsonProperty("name") String name, @Deprecated @JsonProperty("factory") LookupExtractorFactory factory, @JsonProperty("container") LookupExtractorFactoryContainer container ) { Preconditions.checkArgument(factory != null || container != null, "either one of factory or container must exist"); this.name = name; this.container = container != null ? container : new LookupExtractorFactoryContainer(null, factory); this.factory = factory != null ? factory : container.getLookupExtractorFactory(); }
Source:
<code>public void readHeader( PageCache pageCache ) throws IOException { GBPTree.readHeader( pageCache, indexFile, settings.headerReader( NativeSchemaIndexHeaderReader::readFailureMessage ) ); <START> if ( settings.getFailureMessage() != null ) <END> { throw new IOException( settings.getFailureMessage() ); } this.layout = new SpatialLayout( crs, settings.curve() ); }</code><technical_language>I a null check signal failure. a isFailed method instead, a markAsFailed(String) helper well</technical_language>

Target:
public void readHeader( PageCache pageCache ) throws IOException { GBPTree.readHeader( pageCache, indexFile, settings.headerReader( NativeSchemaIndexHeaderReader::readFailureMessage ) ); if ( settings.isFailed() ) { throw new IOException( settings.getFailureMessage() ); } this.layout = new SpatialLayout( crs, settings.curve() ); }
Source:
<code>public int compareValueTo(Row val1, Row val2) { for (int i = 0; i < fieldTypes.size(); i++) { DataType dataType = fieldTypes.get(i); <START> int cmp = dataType.compareValueTo(val1.get(i), val2.get(i)); <END> if (cmp != 0) { return cmp; } } return 0; }</code><technical_language>sure, check Row#numColumns of val1 val2</technical_language>

Target:
public int compareValueTo(Row val1, Row val2) { assert val1.numColumns() == val2.numColumns() : "Rows to compare must have the same number of columns and types. val1=" + val1 + ", val2=" + val2; for (int i = 0; i < fieldTypes.size(); i++) { DataType dataType = fieldTypes.get(i); int cmp = dataType.compareValueTo(val1.get(i), val2.get(i)); if (cmp != 0) { return cmp; } } return 0; }
Source:
<code>protected String getDebuggeeClassName() { return <START> "org.apache.harmony.jpda.tests.jdwp.InterfaceType.InvokeMethodDebuggee"; <END> }</code><technical_language>Prefer reflection avoid static string: return InvokeMethodDebuggee.class.getName() I planning update API (before switching Jack) providing Class<?> instead of String time work this far</technical_language>

Target:
protected String getDebuggeeClassName() { return InvokeMethodDebuggee.class.getName(); }
Source:
<code>public boolean onBackPressed() { if (mVideoPlayer != null && mVideoPlayer.isFullscreen) { mVideoPlayer.isFullscreen = false; mVideoPlayer.toggleOrientation(); return true; } if (DEBUG) Log.d(TAG, "onBackPressed() called"); if (stack.size() <= 1) { hideMainVideoPlayer(); stopService(); <START> unbind(); <END> return false; } stack.pop(); StackItem peek = stack.peek(); PlayQueue peekQueue = stack.peek().getPlayQueue(); if(peekQueue != null && !peekQueue.getClass().equals(SinglePlayQueue.class)) { int index = -1; for (int i=0; i < peekQueue.getStreams().size(); i++) { PlayQueueItem item = peekQueue.getItem(i); if(item.getUrl().equals(stack.peek().getUrl())) { index = i; break; } } if(index != -1) peekQueue.setIndex(index); } autoPlayEnabled = false; hideMainVideoPlayer(); selectAndLoadVideo(peek.getServiceId(), peek.getUrl(), !TextUtils.isEmpty(peek.getTitle()) ? peek.getTitle() : "", peek.getPlayQueue()); return true; }</code><technical_language>unbind called twice: in stopService</technical_language>

Target:
public boolean onBackPressed() { if (playerService != null && player != null && player.isInFullscreen()) { getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); if(!globalScreenOrientationLocked()) player.onFullScreenButtonClicked(); player.getPlayer().setPlayWhenReady(false); return true; } if (DEBUG) Log.d(TAG, "onBackPressed() called"); if (stack.size() <= 1) { if (player != null && player.videoPlayerSelected()) { stopService(); } getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); return false; } stack.pop(); StackItem peek = stack.peek(); selectStreamFromHistory(peek); hideMainPlayer(); setAutoplay(false); selectAndLoadVideo(peek.getServiceId(), peek.getUrl(), !TextUtils.isEmpty(peek.getTitle()) ? peek.getTitle() : "", peek.getPlayQueue()); fromBackStack = true; return true; }
Source:
<code>private void updateAllClustersMacPool() { final Guid newMacPoolId = getParameters().getStoragePool().getMacPoolId(); <START> final boolean shouldSetNewMacPoolOnAllClusters = newMacPoolId != null; <END> if (shouldSetNewMacPoolOnAllClusters) { List<Cluster> clusters = clusterDao.getAllForStoragePool(getStoragePoolId()); for (Cluster cluster : clusters) { moveMacs.migrateMacsToAnotherMacPoolIfNeeded(cluster, newMacPoolId, getContext()); cluster.setMacPoolId(newMacPoolId); clusterDao.update(cluster); } } }</code><technical_language>check 'macPoolId' changed? (Previously checked in 'MoveMacs.updateClusterAndMoveMacs', cases db is updated for reason)</technical_language>

Target:
private void updateAllClustersMacPool() { final Guid newMacPoolId = getParameters().getStoragePool().getMacPoolId(); final boolean shouldSetNewMacPoolOnAllClusters = newMacPoolId != null; if (shouldSetNewMacPoolOnAllClusters) { List<Cluster> clusters = clusterDao.getAllForStoragePool(getStoragePoolId()); for (Cluster cluster : clusters) { boolean macPoolChanged = !newMacPoolId.equals(cluster.getMacPoolId()); if (macPoolChanged) { moveMacs.migrateMacsToAnotherMacPool(cluster, newMacPoolId, getContext()); cluster.setMacPoolId(newMacPoolId); clusterDao.update(cluster); } } } }
Source:
<code>public void after() { for (String id: dtosToDelete) { submissionDao.delete(id); } if (request != null) { requestDao.delete(request.getId()); } if (researchProject != null) { researchProjectDao.delete(researchProject.getId()); } if (researchProject2 != null) { researchProjectDao.delete(researchProject2.getId()); } if (accessRequirement != null) { accessRequirementDAO.delete(accessRequirement.getId().toString()); <START> } <END> if (node != null) { nodeDao.delete(node.getId()); node = null; } if (user1 != null) { userGroupDAO.delete(user1.getId()); } if (user2 != null) { userGroupDAO.delete(user2.getId()); } }</code><technical_language>clean accessRequirement2</technical_language>

Target:
public void after() { for (String id: dtosToDelete) { submissionDao.delete(id); } if (request != null) { requestDao.delete(request.getId()); } if (researchProject != null) { researchProjectDao.delete(researchProject.getId()); } if (researchProject2 != null) { researchProjectDao.delete(researchProject2.getId()); } if (accessRequirement != null) { accessRequirementDAO.delete(accessRequirement.getId().toString()); } if (accessRequirement2 != null) { accessRequirementDAO.delete(accessRequirement2.getId().toString()); } if (node != null) { nodeDao.delete(node.getId()); node = null; } if (user1 != null) { userGroupDAO.delete(user1.getId()); } if (user2 != null) { userGroupDAO.delete(user2.getId()); } }
Source:
<code>private static Class[] getClasses(String packageName) throws ClassNotFoundException, IOException { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); assert classLoader != null; String path = packageName.replace('.', '/'); Enumeration<URL> resources = classLoader.getResources(path); List<File> dirs = new ArrayList<>(); while (resources.hasMoreElements()) { URL resource = resources.nextElement(); dirs.add(new File(resource.getFile())); } ArrayList<Class> classes = new ArrayList<>(); for (File directory : dirs) { classes.addAll(findClasses(directory, packageName)); } <START> return classes.toArray(new Class[classes.size()]); <END> }</code><technical_language>remember 0-size arrays toArray(). PMD enforce this</technical_language>

Target:
private static Class[] getClasses(String packageName) throws ClassNotFoundException, IOException { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); assert classLoader != null; String path = packageName.replace('.', '/'); Enumeration<URL> resources = classLoader.getResources(path); List<File> dirs = new ArrayList<>(); while (resources.hasMoreElements()) { URL resource = resources.nextElement(); dirs.add(new File(resource.getFile())); } ArrayList<Class> classes = new ArrayList<>(); for (File directory : dirs) { classes.addAll(findClasses(directory, packageName)); } return classes.toArray(new Class[0]); }
Source:
<code><START> private boolean isCloseable(Type type) { <END> return type.isSubtypeOf(JAVA_IO_AUTO_CLOSEABLE) || type.isSubtypeOf(JAVA_IO_CLOSEABLE); }</code><technical_language>need remove of static modifiers. Some of valid (this notably)</technical_language>

Target:
private static boolean isCloseable(Type type) { return type.isSubtypeOf(JAVA_IO_AUTO_CLOSEABLE) || type.isSubtypeOf(JAVA_IO_CLOSEABLE); }
Source:
<code><START> public void testNullHeaderReferenceIndex() { <END> SAMRecord sam = new SAMRecordSetBuilder().addFrag("test", 0, 1, false, false, "3S9M", null, 2); final SAMFileHeader header = sam.getHeader(); sam.setHeader(null); sam.setReferenceIndex(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); Assert.assertTrue(sam.getReferenceIndex().equals(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX)); Assert.assertTrue(sam.getReferenceName().equals(SAMRecord.NO_ALIGNMENT_REFERENCE_NAME)); sam = new SAMRecordSetBuilder().addFrag("test", 0, 1, false, false, "3S9M", null, 2); sam.setHeader(null); sam.setReferenceName(SAMRecord.NO_ALIGNMENT_REFERENCE_NAME); Assert.assertTrue(sam.getReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); sam = new SAMRecord(null); Assert.assertTrue(sam.getReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); sam = new SAMRecord(null); final String unresolvableRefName = "unresolvable"; sam.setReferenceName(unresolvableRefName); sam.setHeader(header); Assert.assertTrue(sam.getReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); }</code><technical_language>testNullHeaderReferenceName testNullHeaderReferenceIndex decomposed -- testing reference name index-related functionality in equal amounts. Recommend merging separating testing of reference name index-related methods</technical_language>

Target:
public void testNullHeaderReferenceIndex() { SAMRecord sam = createTestRecordHelper(); final SAMFileHeader samHeader = sam.getHeader(); int originalRefIndex = sam.getReferenceIndex(); Assert.assertTrue(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX != originalRefIndex); sam.setHeader(null); Assert.assertTrue(null == sam.mReferenceIndex); sam.setHeader(samHeader); Assert.assertTrue(sam.getReferenceIndex().equals(originalRefIndex)); sam.setHeader(null); sam.setReferenceIndex(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); Assert.assertTrue(sam.getReferenceIndex().equals(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX)); Assert.assertTrue(sam.getReferenceName().equals(SAMRecord.NO_ALIGNMENT_REFERENCE_NAME)); sam = new SAMRecord(null); Assert.assertTrue(null == sam.mReferenceIndex); Assert.assertTrue(sam.getReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); final String unresolvableRefName = "unresolvable"; sam.setReferenceName(unresolvableRefName); sam.setHeader(samHeader); Assert.assertTrue(null == sam.mReferenceIndex); Assert.assertTrue(sam.getReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); }
Source:
<code>private static void setAnnotationNode(FieldNode fn, CompactFieldNode cfn) { List<CompactAnnotationNode> annotations = new LinkedList<CompactAnnotationNode>(); for (Object visibleAnnotation : fn.visibleAnnotations) { CompactAnnotationNode node = new CompactAnnotationNode(); Map<String, Object> annotationMap = new HashMap<String, Object>(); if (visibleAnnotation instanceof AnnotationNode) { AnnotationNode annotation = (AnnotationNode) visibleAnnotation; if (annotation.desc.contains("InputPortFieldAnnotation") || annotation.desc.contains("OutputPortFieldAnnotation")) { List<Object> annotationValues = annotation.values; if (annotationValues != null) { int index = 0; while (index < annotationValues.size()) { <START> annotationMap.put((String) annotationValues.get(index++), annotationValues.get(index++)); <END> } node.setAnnotations(annotationMap); annotations.add(node); } } } cfn.setVisibleAnnotations(annotations); } }</code><technical_language>I suggest extracting index++ String name = index++; String val = index++;</technical_language>

Target:
private static void setAnnotationNode(FieldNode fn, CompactFieldNode cfn) { List<CompactAnnotationNode> annotations = new LinkedList<CompactAnnotationNode>(); for (Object visibleAnnotation : fn.visibleAnnotations) { CompactAnnotationNode node = new CompactAnnotationNode(); Map<String, Object> annotationMap = new HashMap<String, Object>(); if (visibleAnnotation instanceof AnnotationNode) { AnnotationNode annotation = (AnnotationNode) visibleAnnotation; if (annotation.desc.contains("InputPortFieldAnnotation") || annotation.desc.contains("OutputPortFieldAnnotation")) { List<Object> annotationValues = annotation.values; if (annotationValues != null) { int index = 0; while (index <= annotationValues.size() - 2) { String key = (String)annotationValues.get(index++); Object value = annotationValues.get(index++); annotationMap.put(key, value); } node.setAnnotations(annotationMap); annotations.add(node); } } } cfn.setVisibleAnnotations(annotations); } }
Source:
<code>protected void onNewIntent(Intent intent) { if (intent!=null) { Log.d(TAG, "Intent: " + intent.getIntExtra("extraBufferId", -1) + " " + intent.getDataString()); int requestedBuffer = intent.getIntExtra("extraBufferId", -1); <START> if (requestedBuffer == -99) { <END> openedDrawer = Gravity.START; } else if (requestedBuffer != -1) { openedBuffer = requestedBuffer; } loadBufferAndDrawerState(); } }</code><technical_language>Add another extra instead of a integer constant</technical_language>

Target:
protected void onNewIntent(Intent intent) { if (intent!=null) { Log.d(TAG, "Intent: " + intent.getIntExtra("extraBufferId", -1) + " " + intent.getDataString()); int requestOpenBuffer = intent.getIntExtra("extraBufferId", -1); boolean requestOpenDrawer = intent.getBooleanExtra("extraDrawer", false); if (requestOpenBuffer != -1) { openedBuffer = requestOpenBuffer; } if (requestOpenDrawer) { openedDrawer = Gravity.START; } loadBufferAndDrawerState(); } }
Source:
<code>public synchronized KeyValueStore getKeyValueStore(String name) { KeyValueStoreProvider provider = providers.get(name); if (provider == null) { KeyValueStoreDescriptor descriptor = getDescriptor(XP_CONFIG, name); if (descriptor == null) { descriptor = getDescriptor(XP_CONFIG, DEFAULT_STORE_ID); if (descriptor == null) { return defaultStore; } } try { <START> provider = descriptor.klass.newInstance(); <END> provider.initialize(descriptor); } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } providers.put(name, provider); } return provider; }</code><technical_language>add a getDeclaredConstructor</technical_language>

Target:
public synchronized KeyValueStore getKeyValueStore(String name) { KeyValueStoreProvider provider = providers.get(name); if (provider == null) { KeyValueStoreDescriptor descriptor = getDescriptor(XP_CONFIG, name); if (descriptor == null) { descriptor = getDescriptor(XP_CONFIG, DEFAULT_STORE_ID); if (descriptor == null) { return defaultStore; } } try { provider = descriptor.klass.getDeclaredConstructor().newInstance(); provider.initialize(descriptor); } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } providers.put(name, provider); } return provider; }
Source:
<code>private String sizeSuffix(double size) { if (hasFlag(F_VARIABLE_SIZE)) { if (hasFlag(MiscType.F_DRONE_CARRIER_CONTROL) || hasFlag(MiscType.F_ATAC) || hasFlag(MiscType.F_DTAC)) { return String.format(" (%d %s)", (int) size, size > 1 ? Messages.getString("MiscType.drones") : Messages.getString("MiscType.drone")); } else if (hasFlag(MiscType.F_MASH)) { return String.format(" (%d %s)", (int) size, size > 1 ? Messages.getString("MiscType.theaters") : Messages.getString("MiscType.theater")); } else if (hasFlag(MiscType.F_LADDER)) { <START> return String.format(" (%d m"); <END> } } return ""; }</code><technical_language>Missing format argument</technical_language>

Target:
private String sizeSuffix(double size) { if (hasFlag(F_VARIABLE_SIZE)) { if (hasFlag(MiscType.F_DRONE_CARRIER_CONTROL) || hasFlag(MiscType.F_ATAC) || hasFlag(MiscType.F_DTAC)) { return String.format(" (%d %s)", (int) size, size > 1 ? Messages.getString("MiscType.drones") : Messages.getString("MiscType.drone")); } else if (hasFlag(MiscType.F_MASH)) { return String.format(" (%d %s)", (int) size, size > 1 ? Messages.getString("MiscType.theaters") : Messages.getString("MiscType.theater")); } else if (hasFlag(MiscType.F_LADDER)) { return String.format(" (%d m)", (int) size); } } return ""; }
Source:
<code>public static boolean usesAuthentication(Entity entity) { String keyfileContents = entity.config().get(MongoDBAuthenticationMixins.MONGODB_KEYFILE_CONTENTS); String keyfileUrl = entity.config().get(MongoDBAuthenticationMixins.MONGODB_KEYFILE_URL); if (!(Strings.isEmpty(keyfileContents) || Strings.isEmpty(keyfileUrl))) { throw new IllegalStateException("keyfile contents and keyfile location cannot both be set"); } <START> if (Strings.isEmpty(keyfileContents) && Strings.isEmpty(keyfileUrl)) { <END> return false; } return true; }</code><technical_language>return negation of if condition. return Strings.isNonBlank(contents) || Strings.isNonBlank(url)</technical_language>

Target:
public static boolean usesAuthentication(Entity entity) { String keyfileContents = entity.config().get(MongoDBAuthenticationMixins.MONGODB_KEYFILE_CONTENTS); String keyfileUrl = entity.config().get(MongoDBAuthenticationMixins.MONGODB_KEYFILE_URL); return Strings.isNonBlank(keyfileContents) || Strings.isNonBlank(keyfileUrl); }
Source:
<code>public void testAncestorGroups() throws Exception { DocumentModel groupABCD = getGroup("ABCD"); userManager.createGroup(groupABCD); DocumentModel groupAB = getGroup("AB"); groupAB.setPropertyValue("group:subGroups", (Serializable) Collections.singletonList("ABCD")); userManager.createGroup(groupAB); DocumentModel groupCD = getGroup("CD"); groupCD.setPropertyValue("group:subGroups", (Serializable) Collections.singletonList("ABCD")); userManager.createGroup(groupCD); DocumentModel groupA = getGroup("A"); groupA.setPropertyValue("group:subGroups", (Serializable) Collections.singletonList("AB")); userManager.createGroup(groupA); DocumentModel groupB = getGroup("B"); groupB.setPropertyValue("group:subGroups", (Serializable) Collections.singletonList("AB")); userManager.createGroup(groupB); DocumentModel groupC = getGroup("C"); groupC.setPropertyValue("group:subGroups", (Serializable) Collections.singletonList("CD")); userManager.createGroup(groupC); DocumentModel groupD = getGroup("D"); groupD.setPropertyValue("group:subGroups", (Serializable) Collections.singletonList("CD")); userManager.createGroup(groupD); <START> assertEquals(Arrays.asList("AB", "A", "B", "CD", "C", "D"), userManager.getAncestorGroups("ABCD")); <END> }</code><technical_language>order guarantee. a Set for comparison, sort lists</technical_language>

Target:
public void testAncestorGroups() throws Exception { DocumentModel groupABCD = getGroup("ABCD"); userManager.createGroup(groupABCD); DocumentModel groupAB = getGroup("AB"); groupAB.setPropertyValue("group:subGroups", (Serializable) Collections.singletonList("ABCD")); userManager.createGroup(groupAB); DocumentModel groupCD = getGroup("CD"); groupCD.setPropertyValue("group:subGroups", (Serializable) Collections.singletonList("ABCD")); userManager.createGroup(groupCD); DocumentModel groupA = getGroup("A"); groupA.setPropertyValue("group:subGroups", (Serializable) Collections.singletonList("AB")); userManager.createGroup(groupA); DocumentModel groupB = getGroup("B"); groupB.setPropertyValue("group:subGroups", (Serializable) Collections.singletonList("AB")); userManager.createGroup(groupB); DocumentModel groupC = getGroup("C"); groupC.setPropertyValue("group:subGroups", (Serializable) Collections.singletonList("CD")); userManager.createGroup(groupC); DocumentModel groupD = getGroup("D"); groupD.setPropertyValue("group:subGroups", (Serializable) Collections.singletonList("CD")); userManager.createGroup(groupD); assertTrue(CollectionUtils.isEqualCollection(Arrays.asList("AB", "A", "B", "CD", "C", "D"), userManager.getAncestorGroups("ABCD"))); }
Source:
<code>public void processValidCitationTest() throws GrobidServiceException { String response = grobidService.processCitation("Derwing, T. M., Rossiter, M. J., & Munro, " + "M. J. (2002). Teaching native speakers to listen to foreign-accented speech. " + "Journal of Multilingual and Multicultural Development, 23(4), 245-259.", 1); assertNotNull(response); <START> assertTrue(response.charAt(0) == '@'); <END> }</code><technical_language>Please verify entry is correctly parsed</technical_language>

Target:
public void processValidCitationTest() throws IOException { String response = grobidService.processCitation("Derwing, T. M., Rossiter, M. J., & Munro, " + "M. J. (2002). Teaching native speakers to listen to foreign-accented speech. " + "Journal of Multilingual and Multicultural Development, 23(4), 245-259.", GrobidService.ConsolidateCitations.WITH_METADATA); String[] responseRows = response.split("\n"); assertNotNull(response); assertEquals('@', response.charAt(0)); assertTrue(responseRows[1].contains("author") && responseRows[1].contains("Derwing and M Rossiter")); assertTrue(responseRows[2].contains("title") && responseRows[2].contains("Teaching native speakers")); assertTrue(responseRows[3].contains("journal") && responseRows[3].contains("Journal of Multilingual and Multicultural")); assertTrue(responseRows[4].contains("year") && responseRows[4].contains("2002")); assertTrue(responseRows[5].contains("pages") && responseRows[5].contains("245--259")); assertTrue(responseRows[6].contains("volume") && responseRows[6].contains("23")); assertTrue(responseRows[7].contains("number") && responseRows[7].contains("4")); }
Source:
<code>private boolean storageDomainStatusIsValid() { if (getStorageDomainStatus() == StorageDomainStatus.Active) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_ALREADY_ACTIVE); <START> } <END> if (isInternalExecution()) { return checkStorageDomainStatus(StorageDomainStatus.InActive, StorageDomainStatus.Unknown, StorageDomainStatus.Locked, StorageDomainStatus.Maintenance); } return checkStorageDomainStatus(StorageDomainStatus.InActive, StorageDomainStatus.Unknown, StorageDomainStatus.Maintenance); }</code><technical_language>I suggest change current message - currently is "ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL" = ${action} ${type}. relevant Storage Domain is inaccessible.\n\ is wrong - I suggest change : ${action} ${type}. relevant Storage Domain is in status $Status.\n\ message readable adding code "solve" for statuses</technical_language>

Target:
private boolean storageDomainStatusIsValid() { boolean returnValue; if (isInternalExecution()) { returnValue = checkStorageDomainStatus(StorageDomainStatus.InActive, StorageDomainStatus.Unknown, StorageDomainStatus.Locked, StorageDomainStatus.Maintenance); } else { returnValue = checkStorageDomainStatus(StorageDomainStatus.InActive, StorageDomainStatus.Unknown, StorageDomainStatus.Maintenance); } return returnValue; }
Source:
<code>private void validateName(DigitalExchange digitalExchange) { if (getDigitalExchanges().stream() .filter(de -> digitalExchange.getName().equals(de.getName())) <START> .findAny().isPresent()) { <END> BeanPropertyBindingResult errors = new BeanPropertyBindingResult(digitalExchange, DIGITAL_EXCHANGE_LABEL); errors.reject(ERRCODE_DIGITAL_EXCHANGE_NAME_TAKEN, new Object[]{digitalExchange.getName()}, "digitalExchange.name.taken"); throw new ValidationConflictException(errors); } }</code><technical_language>simplified to: if (getDigitalExchanges().stream() .anyMatch(de -> digitalExchange.getName().equals(de.getName()))) {</technical_language>

Target:
private void validateName(DigitalExchange digitalExchange) { if (getDigitalExchanges().stream() .anyMatch(de -> digitalExchange.getName().equals(de.getName()))) { BeanPropertyBindingResult errors = new BeanPropertyBindingResult(digitalExchange, DIGITAL_EXCHANGE_LABEL); errors.reject(ERRCODE_DIGITAL_EXCHANGE_NAME_TAKEN, new Object[]{digitalExchange.getName()}, "digitalExchange.name.taken"); throw new ValidationConflictException(errors); } }
Source:
<code>public void setUp() { <START> if (kvs == null) { <END> kvs = CassandraKeyValueService.create( CassandraKeyValueServiceConfigManager.createSimpleManager(CassandraContainer.KVS_CONFIG), CassandraContainer.LEADER_CONFIG, Mockito.mock(Logger.class)); } kvs.createTable(TEST_TABLE, AtlasDbConstants.GENERIC_TABLE_METADATA); kvs.truncateTable(TEST_TABLE); TracingQueryRunner queryRunner = new TracingQueryRunner( Mockito.mock(Logger.class), new TracingPrefsConfig()); SingleRowColumnPager singleRowPager = new SingleRowColumnPager(kvs.clientPool, queryRunner); cellPager = new CellPager(singleRowPager, kvs.clientPool, queryRunner, pageSizingStrategy); }</code><technical_language>sense do this in a @BeforeClass method instead</technical_language>

Target:
public void setUp() { kvs.createTable(TEST_TABLE, AtlasDbConstants.GENERIC_TABLE_METADATA); kvs.truncateTable(TEST_TABLE); TracingQueryRunner queryRunner = new TracingQueryRunner( Mockito.mock(Logger.class), new TracingPrefsConfig()); SingleRowColumnPager singleRowPager = new SingleRowColumnPager(kvs.clientPool, queryRunner); cellPager = new CellPager(singleRowPager, kvs.clientPool, queryRunner, pageSizingStrategy); }
Source:
<code>void scheduleMessage() { final String messageId = UUID.randomUUID().toString(); final String contents = "Some-contents"; final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, messageId, 0); int enqueDelayInSec = 2; <START> StepVerifier.create(sender.scheduleMessage(message, Instant.now().plusSeconds(enqueDelayInSec)) <END> .delaySubscription(Duration.ofSeconds(enqueDelayInSec + 1)) .thenMany(receiver.receive().take(1))) .assertNext(receivedMessage -> { Assertions.assertArrayEquals(contents.getBytes(), receivedMessage.getBody()); Assertions.assertTrue(receivedMessage.getProperties().containsKey(MESSAGE_TRACKING_ID)); Assertions.assertEquals(messageId, receivedMessage.getProperties().get(MESSAGE_TRACKING_ID)); }) .verifyComplete(); }</code><technical_language>variable creations Instant.now.plus.. Duration.ofSeconds(enqeueDe...) a part of "Arrange" section. Act part is usually, "I set things, invoke it."</technical_language>

Target:
void scheduleMessage() { final String messageId = UUID.randomUUID().toString(); final String contents = "Some-contents"; final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, messageId, 0); final Instant scheduledEnqueueTime = Instant.now().plusSeconds(2); sender.scheduleMessage(message, scheduledEnqueueTime) .delaySubscription(Duration.ofSeconds(3)) .block(); StepVerifier.create(receiver.receive().take(1)) .assertNext(receivedMessage -> { Assertions.assertArrayEquals(contents.getBytes(), receivedMessage.getBody()); Assertions.assertTrue(receivedMessage.getProperties().containsKey(MESSAGE_TRACKING_ID)); Assertions.assertEquals(messageId, receivedMessage.getProperties().get(MESSAGE_TRACKING_ID)); }) .verifyComplete(); }
Source:
<code>public void completeFromAddress() { <START> String addressStreet = address != null ? address.get("street") : null; <END> if (addressStreet != null) { if (this.street == null) { this.street = new HashMap<>(); } setOrReplace(addressStreet, this.street, "street"); } String addressCity = address != null ? address.get("city") : null; if (addressCity != null) { if (this.city == null) { this.city = new HashMap<>(); } setOrReplace(addressCity, this.city, "city"); } String addressSuburb = address != null ? address.get("suburb") : null; if (addressSuburb != null) { if (this.suburb == null) { this.suburb = new HashMap<>(); } setOrReplace(addressSuburb, this.suburb, "suburb"); } String addressNeighbourhood = address != null ? address.get("neighbourhood") : null; if (addressNeighbourhood != null) { if (this.neighbourhood == null) { this.neighbourhood = new HashMap<>(); } setOrReplace(addressNeighbourhood, this.neighbourhood, "neighbourhood"); } String addressPostCode = address != null ? address.get("postcode") : null; if (addressPostCode != null && !addressPostCode.equals(this.postcode)) { if (log.isDebugEnabled()) { log.debug("Replacing postcode "+this.postcode+" with "+ addressPostCode+ " for osmId #" + osmId); } this.postcode = addressPostCode; } }</code><technical_language>Check address == null of function return early</technical_language>

Target:
public void completeFromAddress() { if (address == null) return; String addressStreet = address.get("street"); if (addressStreet != null) { this.street = nullToEmptyMap(this.street); setOrReplace(addressStreet, this.street, "street"); } String addressCity = address.get("city"); if (addressCity != null) { this.city = nullToEmptyMap(this.city); setOrReplace(addressCity, this.city, "city"); } String addressDistrict = address.get("suburb"); if (addressDistrict != null) { this.district = nullToEmptyMap(this.district); setOrReplace(addressDistrict, this.district, "suburb"); } String addressLocality = address.get("neighbourhood"); if (addressLocality != null) { this.locality = nullToEmptyMap(this.locality); setOrReplace(addressLocality, this.locality, "neighbourhood"); } String addressPostCode = address.get("postcode"); if (addressPostCode != null && !addressPostCode.equals(this.postcode)) { if (log.isDebugEnabled()) { log.debug("Replacing postcode "+this.postcode+" with "+ addressPostCode+ " for osmId #" + osmId); } this.postcode = addressPostCode; } }