auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private boolean handleMultiDrag(final MotionEvent event) { if (event.getPointerCount() != 2) return false; if(initPointerDistance != -1){ float firstPointerMoveX = event.getX(0) - initFirstPointerX; float firstPointerMoveY = event.getY(0) - initFirstPointerY; float secPointerMoveX = event.getX(1) - initSecPointerX; float secPointerMoveY = event.getY(1) - initSecPointerY; int scaledTouchSlop = ViewConfiguration.get(PopupVideoPlayer.this).getScaledTouchSlop(); if(firstPointerMoveX > scaledTouchSlop ||firstPointerMoveY > scaledTouchSlop || <START> secPointerMoveX > scaledTouchSlop || secPointerMoveY > scaledTouchSlop){ <END> double newWidth = popupWidth; float currentXDiff = event.getX(0) - event.getX(1); float currentYDiff = event.getY(0) - event.getY(1); double currentPointerDistance = Math.sqrt(currentXDiff * currentXDiff + currentYDiff * currentYDiff); double scale = 1 + (currentPointerDistance - initPointerDistance)/ initPointerDistance; newWidth = (popupWidth * scale); if(currentPointerDistance > initPointerDistance){ popupLayoutParams.x -= (newWidth - popupWidth)/2; } else{ popupLayoutParams.x += (popupWidth - newWidth)/2; } initPointerDistance = currentPointerDistance; checkPopupPositionBounds(); updateScreenSize(); final int width = (int) Math.min(screenWidth, newWidth); updatePopupSize(width, -1); return true; } } return false; }</code><technical_language>suggestion secPointerMoveX > scaledTouchSlop || secPointerMoveY > scaledTouchSlop) {</technical_language>

Target:
private boolean handleMultiDrag(final MotionEvent event) { if (initPointerDistance != -1 && event.getPointerCount() == 2) { double firstPointerMove = Math.hypot(event.getX(0) - initFirstPointerX, event.getY(0) - initFirstPointerY); double secPointerMove = Math.hypot(event.getX(1) - initSecPointerX, event.getY(1) - initSecPointerY); int minimumMove = ViewConfiguration.get(PopupVideoPlayer.this).getScaledTouchSlop(); if (Math.max(firstPointerMove, secPointerMove) > minimumMove) { double currentPointerDistance = Math.hypot(event.getX(0) - event.getX(1), event.getY(0) - event.getY(1)); double newWidth = (popupWidth * currentPointerDistance / initPointerDistance); initPointerDistance = currentPointerDistance; popupLayoutParams.x += (popupWidth - newWidth) / 2; checkPopupPositionBounds(); updateScreenSize(); updatePopupSize((int) Math.min(screenWidth, newWidth), -1); return true; } } return false; }
Source:
<code>public StashNotifier( String stashServerBaseUrl, String stashUserName, String stashUserPassword, boolean ignoreUnverifiedSSLPeer) { this.stashServerBaseUrl = stashServerBaseUrl; this.stashUserName = stashUserName; this.stashUserPassword = stashUserPassword; this.ignoreUnverifiedSSLPeer = ignoreUnverifiedSSLPeer; <START> jenkins = Jenkins.getInstance(); <END> httpClientfactory = new ConcreteHttpClientFactory(); notifierService = new ConfigurableStashNotifierService( stashServerBaseUrl, new JsonBuildEntityFactory(), new BasicStashRequestConfigurator(stashUserName, stashUserPassword)); }</code><technical_language>stashnotifier fails a NullPointerException access jenkins in line 134. explanation I is Jenkins.getInstance() returns null is called construction time of this plugin. I idea case, though. exception I in Jenkins console output ERROR: Publisher org.jenkinsci.plugins.stashNotifier.StashNotifier aborted due exception java.lang.NullPointerException org.jenkinsci.plugins.stashNotifier.StashNotifier.perform(StashNotifier.java:134) hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36) hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:810) hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:785) hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:946) hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:732) hudson.model.Run.execute(Run.java:1582) hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477) hudson.model.ResourceController.execute(ResourceController.java:88) hudson.model.Executor.run(Executor.java:236) Finished: FAILURE</technical_language>

Target:
public StashNotifier( String stashServerBaseUrl, String stashUserName, String stashUserPassword, boolean ignoreUnverifiedSSLPeer) { this.stashServerBaseUrl = stashServerBaseUrl; this.stashUserName = stashUserName; this.stashUserPassword = stashUserPassword; this.ignoreUnverifiedSSLPeer = ignoreUnverifiedSSLPeer; httpClientfactory = new ConcreteHttpClientFactory(); notifierService = new ConfigurableStashNotifierService( stashServerBaseUrl, new JsonBuildEntityFactory(), new BasicStashRequestConfigurator(stashUserName, stashUserPassword)); }
Source:
<code>@Override public void load(Request request, int networkPolicy, Callback callback) { try { ContentResolver contentResolver = context.getContentResolver(); int exifOrientation = getExifOrientation(contentResolver, request.uri); String mimeType = contentResolver.getType(request.uri); boolean isVideo = mimeType != null && mimeType.startsWith("video/"); if (request.hasSize()) { PicassoKind picassoKind = getPicassoKind(request.targetWidth, request.targetHeight); if (!isVideo && picassoKind == FULL) { Source source = Okio.source(getInputStream(request)); callback.onSuccess(new Result(null, source, DISK, exifOrientation)); } long id = parseId(request.uri); BitmapFactory.Options options = createBitmapOptions(request); options.inJustDecodeBounds = true; calculateInSampleSize(request.targetWidth, request.targetHeight, picassoKind.width, picassoKind.height, options, request); Bitmap bitmap; if (isVideo) { int kind = (picassoKind == FULL) ? Video.Thumbnails.MINI_KIND : picassoKind.androidKind; bitmap = Video.Thumbnails.getThumbnail(contentResolver, id, kind, options); } else { bitmap = Images.Thumbnails.getThumbnail(contentResolver, id, picassoKind.androidKind, options); } if (bitmap != null) { callback.onSuccess(new Result(bitmap, null, DISK, exifOrientation)); } } <START> Source source = Okio.source(getInputStream(request)); <END> callback.onSuccess(new Result(null, source, DISK, exifOrientation)); } catch (Exception e) { callback.onError(e); } }</code><technical_language>needs a return this line</technical_language>

Target:
@Override public void load(Request request, int networkPolicy, Callback callback) { boolean signaledCallback = false; try { ContentResolver contentResolver = context.getContentResolver(); int exifOrientation = getExifOrientation(contentResolver, request.uri); String mimeType = contentResolver.getType(request.uri); boolean isVideo = mimeType != null && mimeType.startsWith("video/"); if (request.hasSize()) { PicassoKind picassoKind = getPicassoKind(request.targetWidth, request.targetHeight); if (!isVideo && picassoKind == FULL) { Source source = Okio.source(getInputStream(request)); signaledCallback = true; callback.onSuccess(new Result(null, source, DISK, exifOrientation)); return; } long id = parseId(request.uri); BitmapFactory.Options options = createBitmapOptions(request); options.inJustDecodeBounds = true; calculateInSampleSize(request.targetWidth, request.targetHeight, picassoKind.width, picassoKind.height, options, request); Bitmap bitmap; if (isVideo) { int kind = (picassoKind == FULL) ? Video.Thumbnails.MINI_KIND : picassoKind.androidKind; bitmap = Video.Thumbnails.getThumbnail(contentResolver, id, kind, options); } else { bitmap = Images.Thumbnails.getThumbnail(contentResolver, id, picassoKind.androidKind, options); } if (bitmap != null) { signaledCallback = true; callback.onSuccess(new Result(bitmap, null, DISK, exifOrientation)); return; } } Source source = Okio.source(getInputStream(request)); signaledCallback = true; callback.onSuccess(new Result(null, source, DISK, exifOrientation)); } catch (Exception e) { if (!signaledCallback) { callback.onError(e); } } }
Source:
<code>public String toString() { <START> return "Body [position=" + position + ", height=" + height + ", width=" + width + ", orientation=" + orientation + ", type=" + type + "]"; <END> }</code><technical_language>please String.format xD</technical_language>

Target:
public String toString() { return String.format("Body [position=%s, height=%s, width=%s, orientation=%s, type=%s]", position, height, width, orientation, type); }
Source:
<code>public void test() { assertThat(PHPLexicalGrammar.FUNCTION_CALL_PARAMETER_LIST) .matches("()") .matches("($p)") .matches("(& $p)") .matches("(...$p)") .matches("(yield $a)") .matches("($p1, & $p2, ...$p3, yield $p4)") <START> .notMatches("('title', 'body','comments',)") <END> .notMatches("(,)") .notMatches("('function','bar',,)") .notMatches("(,'function','bar')"); }</code><technical_language>this [rfc](<LINK_0> this code "matches" opposite!!</technical_language>

Target:
public void test() { assertThat(PHPLexicalGrammar.FUNCTION_CALL_PARAMETER_LIST) .matches("()") .matches("($p)") .matches("(& $p)") .matches("(...$p)") .matches("(yield $a)") .matches("($p1, & $p2, ...$p3, yield $p4)") .matches("('title', 'body','comments',)") .notMatches("(,)") .notMatches("('function','bar',,)") .notMatches("(,'function','bar')"); }
Source:
<code><START> public ABITrace( URL ABIFile ) throws IOException <END> { byte[] bytes = null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); InputStream is = ABIFile.openStream(); BufferedInputStream bis = new BufferedInputStream(is); int b; while ((b = bis.read()) >= 0) { baos.write(b); } bis.close(); is.close(); baos.close(); bytes = baos.toByteArray(); initData(bytes); }</code><technical_language>This method similar. nice extract common part a separate method shared both</technical_language>

Target:
public ABITrace( URL ABIFile ) throws IOException { InputStream is = ABIFile.openStream(); BufferedInputStream bis = new BufferedInputStream(is); ABITraceInit(bis); is.close(); }
Source:
<code>public void handleRequest(JCoServerContext jCoServerContext, JCoFunction jCoFunction) throws AbapException, AbapClassException { if (log.isDebugEnabled()) { log.debug("New BAPI function call received"); } String xml = jCoFunction.toXML(); <START> ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes()); <END> MessageContext msgContext = null; try { msgContext = endpoint.createMessageContext(); msgContext.setIncomingTransportName(SAPConstants.SAP_BAPI_PROTOCOL_NAME); if (log.isDebugEnabled()) { log.debug("Creating SOAP envelope from the BAPI function call"); } SOAPEnvelope envelope = TransportUtils.createSOAPMessage(msgContext, bais, SAPConstants.SAP_CONTENT_TYPE); msgContext.setEnvelope(envelope); } catch (Exception e) { log.error("Error while processing the BAPI call through the Axis engine", e); } finally { try { bais.close(); } catch (IOException e) { log.error("Error while closing the stream", e); } } workerPool.execute(new BAPIWorker(msgContext)); }</code><technical_language>perform this in BAPIWorker thread? BAPIWorker process xml String representation of request</technical_language>

Target:
public void handleRequest(JCoServerContext jCoServerContext, JCoFunction jCoFunction) throws AbapException, AbapClassException { if (log.isDebugEnabled()) { log.debug("New BAPI function call received"); } String xml = jCoFunction.toXML(); workerPool.execute(new BAPIWorker(xml)); }
Source:
<code>protected static String renameDiskAlias(OriginType originType, String alias) { <START> Matcher vmwareMatcher; <END> if (originType == OriginType.VMWARE) { vmwareMatcher = VMWARE_DISK_NAME_PATTERN.matcher(alias); } else { vmwareMatcher = DISK_NAME_PATTERN.matcher(alias); } if (vmwareMatcher.matches()) { return vmwareMatcher.group(1); } return alias; }</code><technical_language>please rename diskNameMatcher</technical_language>

Target:
protected static String renameDiskAlias(OriginType originType, String alias) { Matcher matcher; if (originType == OriginType.VMWARE) { matcher = VMWARE_DISK_NAME_PATTERN.matcher(alias); } else { matcher = DISK_NAME_PATTERN.matcher(alias); } if (matcher.matches()) { return matcher.group(1); } return alias; }
Source:
<code>public Map<String, String> getDataForResourceId(final String nodeId, final String resourceIdString) { return m_transactionOperations.execute(new TransactionCallback<Map<String, String>>() { @Override public Map<String, String> doInTransaction(TransactionStatus transactionStatus) { Map<String, String> data = new HashMap<>(); ResourceId resourceId = ResourceId.fromString(resourceIdString); String nodeIdentifier = Optional.ofNullable(nodeId).orElse(determineNodeIdByResourceId(resourceId)); data.put("nodeId", nodeIdentifier); data.put("nodeLabel", m_nodeDao.getLabelForId(Integer.valueOf(nodeIdentifier))); <START> List<OnmsResource> resourceList = m_resourceDao.getResourceById(ResourceId.get("node", nodeIdentifier)).getChildResources(); <END> for (OnmsResource onmsResource : resourceList) { if (resourceId.equals(onmsResource.getId())) { data.put("resourceLabel", onmsResource.getLabel()); data.put("resourceTypeLabel", onmsResource.getResourceType().getLabel()); break; } } return data; } }); }</code><technical_language>opt for calling ResourceDao#getResourceForNode instead</technical_language>

Target:
public Map<String, String> getDataForResourceId(final String nodeId, final String resourceIdString) { return m_transactionOperations.execute(new TransactionCallback<Map<String, String>>() { @Override public Map<String, String> doInTransaction(TransactionStatus transactionStatus) { Map<String, String> data = new HashMap<>(); ResourceId resourceId = ResourceId.fromString(resourceIdString); OnmsNode node; OnmsResource resource; if(nodeId == null){ resource = determineResourceByResourceId(resourceId); node = ResourceTypeUtils.getNodeFromResource(resource); } else { node = m_nodeDao.get(nodeId); resource = m_resourceDao.getResourceForNode(node); } data.put("nodeId", node.getNodeId()); data.put("nodeLabel", node.getLabel()); for (OnmsResource onmsResource : resource.getChildResources()) { if (resourceId.equals(onmsResource.getId())) { data.put("resourceLabel", onmsResource.getLabel()); data.put("resourceTypeLabel", onmsResource.getResourceType().getLabel()); break; } } return data; } }); }
Source:
<code>private void processError( ContentReviewItem item, Long status, String error, Integer errorCode ) { if( status == null ) { IllegalArgumentException ex = new IllegalArgumentException( "Status is null; you must supply a valid status to update when calling processError()" ); <START> log.warn( ex ); <END> throw ex; } else { item.setStatus( status ); } if( error != null ) { item.setLastError(error); } if( errorCode != null ) { item.setErrorCode( errorCode ); } dao.update( item ); releaseLock( item ); if( status.equals( ContentReviewItem.SUBMISSION_ERROR_NO_RETRY_CODE ) || status.equals( ContentReviewItem.REPORT_ERROR_NO_RETRY_CODE ) || status.equals( ContentReviewItem.SUBMISSION_ERROR_RETRY_EXCEEDED ) ) { try { ContentResource resource = contentHostingService.getResource( item.getContentId() ); boolean itemUpdated = updateItemAccess( resource.getId() ); if (!itemUpdated) { log.error( "Could not update cr item access status" ); } } catch( PermissionException | IdUnusedException | TypeException ex ) { log.error( "Error updating cr item access status; item id = " + item.getContentId(), ex ); } } }</code><technical_language>this result in double logging of error if caller Exception log somewhere</technical_language>

Target:
private void processError( ContentReviewItem item, Long status, String error, Integer errorCode ) { try { if( status == null ) { IllegalArgumentException ex = new IllegalArgumentException( "Status is null; you must supply a valid status to update when calling processError()" ); throw ex; } else { item.setStatus( status ); } if( error != null ) { item.setLastError(error); } if( errorCode != null ) { item.setErrorCode( errorCode ); } dao.update( item ); if( isDeadState( status ) ) { try { ContentResource resource = contentHostingService.getResource( item.getContentId() ); boolean itemUpdated = updateItemAccess( resource.getId() ); if (!itemUpdated) { log.error( "Could not update cr item access status" ); } } catch( PermissionException | IdUnusedException | TypeException ex ) { log.error( "Error updating cr item access status; item id = " + item.getContentId(), ex ); } } } finally { releaseLock( item ); } }
Source:
<code>private void checkAttributeAccessItem(final List<AttributeAccessItem> attributeAccessItemList, final List<AttributeAccessItemDto> attributeAccessItemDtoList) { assertEquals(attributeAccessItemList.size(), attributeAccessItemDtoList.size()); <START> for (final AttributeAccessItem attributeAccessItem : attributeAccessItemList) { <END> assertEquals(attributeAccessItem.getAccessMode(), attributeAccessItem.getAccessMode()); assertEquals(attributeAccessItem.getAccessSelectors(), attributeAccessItem.getAccessSelectors()); assertEquals(attributeAccessItem.getAttributeId(), attributeAccessItem.getAttributeId()); } }</code><technical_language>This block compares AttributeAccessItem objects themselves. compare AttributeAccessItemDto objects indexes of attributeAccessItemDtoList</technical_language>

Target:
private void checkAttributeAccessItem(final List<AttributeAccessItem> attributeAccessItemList, final List<AttributeAccessItemDto> attributeAccessItemDtoList) { assertEquals(attributeAccessItemList.size(), attributeAccessItemDtoList.size()); final Iterator<AttributeAccessItem> attributeAccessItemIterator = attributeAccessItemList.iterator(); final Iterator<AttributeAccessItemDto> attributeAccessItemDtoIterator = attributeAccessItemDtoList.iterator(); while (attributeAccessItemIterator.hasNext() && attributeAccessItemDtoIterator.hasNext()) { final AttributeAccessItem attributeAccessItem = attributeAccessItemIterator.next(); final AttributeAccessItemDto attributeAccessItemDto = attributeAccessItemDtoIterator.next(); assertEquals(attributeAccessItem.getAccessMode().name(), attributeAccessItemDto.getAccessMode().name()); assertEquals(attributeAccessItem.getAccessSelectors().getAccessSelector(), attributeAccessItemDto.getAccessSelectors().getAccessSelector()); assertEquals(attributeAccessItem.getAttributeId(), attributeAccessItemDto.getAttributeId()); } }
Source:
<code>public boolean accept(Type type, Class<?> clazz) { if (clazz == null) { return false; } <START> if (GeneratedMessageV3.class.isAssignableFrom(clazz)) { <END> return true; } return false; }</code><technical_language>pls. simplify 'return GeneratedMessageV3.class.isAssignableFrom(clazz);'</technical_language>

Target:
public boolean accept(Type type, Class<?> clazz) { if (clazz == null) { return false; } return GeneratedMessageV3.class.isAssignableFrom(clazz); }
Source:
<code>public void testGetRegions() throws IOException { final Kiji mKiji = getKiji(); mKiji.createTable( <START> "user", KijiTableLayouts.getTableLayout(KijiTableLayouts.FULL_FEATURED), 3); <END> final KijiTable mTable = mKiji.openTable("user"); List<KijiRegion> regions = mTable.getRegions(); assertEquals(3, regions.size()); for (KijiRegion region : regions) { assertTrue(region.getLocations().size() > 0); } }</code><technical_language>3 a constant</technical_language>

Target:
public void testGetRegions() throws IOException { final int numRegions = 3; final Kiji mKiji = getKiji(); mKiji.createTable( "user", KijiTableLayouts.getTableLayout(KijiTableLayouts.FULL_FEATURED), numRegions); final KijiTable mTable = mKiji.openTable("user"); List<KijiRegion> regions = mTable.getRegions(); assertEquals(numRegions, regions.size()); for (KijiRegion region : regions) { assertTrue(region.getLocations().size() > 0); } }
Source:
<code>DirProperty readPropertyFromPath(Path path, BasicFileAttributes mainAtts) throws IOException { if (Files.exists(path) && Files.isRegularFile(path) && Files.isReadable(path)) { return new DirProperty( <START> new String(Files.readAllBytes(path)), <END> mainAtts.lastModifiedTime(), path.toAbsolutePath(), directory.relativize(path).getNameCount() ); } return null; }</code><technical_language>I want encoding explicitly here</technical_language>

Target:
DirProperty readPropertyFromPath(Path path, BasicFileAttributes mainAtts) throws IOException { if (Files.exists(path) && Files.isRegularFile(path) && Files.isReadable(path)) { return new DirProperty( new String(Files.readAllBytes(path), StandardCharsets.UTF_8), mainAtts.lastModifiedTime(), path.toAbsolutePath(), this.directory ); } throw new IOException("Cannot read property from '"+path.toString()+"'."); }
Source:
<code>public void testSetBaseDirectory() throws IOException { GeoServerResourceLoader loader = new GeoServerResourceLoader(); assertNull(loader.getBaseDirectory()); assertEquals(ResourceStore.EMPTY, loader.getResourceStore()); <START> TemporaryFolder tempFolder = new TemporaryFolder(); <END> tempFolder.create(); File tempDir = tempFolder.getRoot(); loader.setBaseDirectory(tempDir); assertEquals(tempDir, loader.getBaseDirectory()); assertTrue(loader.getResourceStore() instanceof FileSystemResourceStore); ResourceStore mockStore = EasyMock.createMock(ResourceStore.class); loader = new GeoServerResourceLoader(mockStore); assertNull(loader.getBaseDirectory()); assertEquals(mockStore, loader.getResourceStore()); loader.setBaseDirectory(tempDir); assertEquals(tempDir, loader.getBaseDirectory()); assertEquals(mockStore, loader.getResourceStore()); }</code><technical_language>TemporaryFolder needs set a field a @Rule cleaned test end, not? <LINK_0></technical_language>

Target:
public void testSetBaseDirectory() throws IOException { GeoServerResourceLoader loader = new GeoServerResourceLoader(); assertNull(loader.getBaseDirectory()); assertEquals(ResourceStore.EMPTY, loader.getResourceStore()); tempFolder.create(); File tempDir = tempFolder.getRoot(); loader.setBaseDirectory(tempDir); assertEquals(tempDir, loader.getBaseDirectory()); assertTrue(loader.getResourceStore() instanceof FileSystemResourceStore); ResourceStore mockStore = EasyMock.createMock(ResourceStore.class); loader = new GeoServerResourceLoader(mockStore); assertNull(loader.getBaseDirectory()); assertEquals(mockStore, loader.getResourceStore()); loader.setBaseDirectory(tempDir); assertEquals(tempDir, loader.getBaseDirectory()); assertEquals(mockStore, loader.getResourceStore()); }
Source:
<code>public void close() throws IOException { <START> if (pool != null) { <END> pool.shutdown(); } if (restClient != null) { restClient.close(); } }</code><technical_language>nan</technical_language>

Target:
public void close() throws IOException { pool.shutdown(); restClient.close(); }
Source:
<code>public void testGetServicesByName() throws Exception { final String name = "servicesByName"; Ignite g = randomGrid(); g.services().deployMultiple(name, new DummyService(), nodeCount() * 2, 3); AtomicInteger cnt = new AtomicInteger(0); for (int i = 0; i < nodeCount(); i++) { Collection<DummyService> svcs = grid(i).services().services(name); if (svcs != null) cnt.addAndGet(svcs.size()); } <START> assertTrue(GridTestUtils.waitForCondition(() -> cnt.get() == nodeCount() * 2, 10000)); <END> }</code><technical_language>Semantic is broken here. 'cnt' is calculated changed. So, if condition met is sense wait 10 sec more less</technical_language>

Target:
public void testGetServicesByName() { final String name = "servicesByName"; Ignite g = randomGrid(); g.services().deployMultiple(name, new DummyService(), nodeCount() * 2, 3); assertTrue(GridTestUtils.waitUntil(() -> { int cnt = IntStream.range(0, nodeCount()).parallel().map(i -> grid(i).services().services(name).size()).sum(); return cnt == nodeCount() * 2; }, 1000)); }
Source:
<code>public void verifyArticleName(String targetText) { Assertion.assertStringContains(targetText, getArticleName()); <START> PageObjectLogging.log("verifyArticleName", <END> "verifying the article shows " + targetText, true); }</code><technical_language>wrong formatting - parameter in new line</technical_language>

Target:
public void verifyArticleName(String targetText) { Assertion.assertStringContains(targetText, getArticleName()); PageObjectLogging.log( "verifyArticleName", "The article shows " + targetText, true ); }
Source:
<code>public void checkFindReferencesFeature() { projectExplorer.openItemByPath(PROJECT_NAME + "/towers.go"); editor.waitActive(); editor.goToPosition(12, 1); menu.runCommand(ASSISTANT, FIND_REFERENCES); findReferencesConsoleTab.waitExpectedTextInLsPanel(REFERENCES_NOTJHING_TO_SHOW_TEXT); editor.goToPosition(19, 5); menu.runCommand(ASSISTANT, FIND_REFERENCES); try { findReferencesConsoleTab.waitAllReferencesWithText( <START> "/desktop-go-simple/towers.go\n" + "From:23:71 To:23:76"); <END> findReferencesConsoleTab.doubleClickOnReference("From:23:71 To:23:76"); } catch (TimeoutException ex) { fail( "Need to delete 'try/catch' and change values of the parameters, because the known issue <LINK_0> is resolved"); } editor.typeTextIntoEditor(ARROW_LEFT.toString()); editor.waitSpecifiedValueForLineAndChar(24, 72); editor.waitTextElementsActiveLine("count"); editor.goToPosition(19, 5); menu.runCommand(ASSISTANT, FIND_REFERENCES); try { findReferencesConsoleTab.waitAllReferencesWithText(REFERENCES_EXPECTED_TEXT); } catch (TimeoutException ex) { fail("Known permanent failure <LINK_0>", ex); } }</code><technical_language>concatenation middle of row weird</technical_language>

Target:
public void checkFindReferencesFeature() { projectExplorer.openItemByPath(PROJECT_NAME + "/towers.go"); editor.waitActive(); editor.goToPosition(12, 1); menu.runCommand(ASSISTANT, FIND_REFERENCES); findReferencesConsoleTab.waitExpectedTextInLsPanel(REFERENCES_NOTJHING_TO_SHOW_TEXT); editor.goToPosition(19, 5); menu.runCommand(ASSISTANT, FIND_REFERENCES); try { findReferencesConsoleTab.waitAllReferencesWithText( "/desktop-go-simple/towers.go\nFrom:23:71 To:23:76"); findReferencesConsoleTab.doubleClickOnReference("From:23:71 To:23:76"); } catch (TimeoutException ex) { fail( "Need to delete 'try/catch' and change values of the parameters, because the known issue <LINK_0> is resolved"); } editor.typeTextIntoEditor(ARROW_LEFT.toString()); editor.waitSpecifiedValueForLineAndChar(24, 72); editor.waitTextElementsActiveLine("count"); editor.goToPosition(19, 5); menu.runCommand(ASSISTANT, FIND_REFERENCES); try { findReferencesConsoleTab.waitAllReferencesWithText(REFERENCES_EXPECTED_TEXT); } catch (TimeoutException ex) { fail("Known permanent failure <LINK_0>", ex); } }
Source:
<code>public AdvertisedSocketAddress[] resolveSrvRecord( String url ) throws NamingException { Attributes attrs = (_idc == null ? getIdc() : _idc).getAttributes( url, SRV_RECORDS ); NamingEnumeration<?> records = attrs.get( SRV_ATTR ).getAll(); List<AdvertisedSocketAddress> addresses = new ArrayList<>(); while ( records.hasMore() ) { SrvRecord record = SrvRecord.parse( (String) records.next() ); addresses.add( new AdvertisedSocketAddress( record.host, record.port ) ); } <START> return addresses.toArray( new AdvertisedSocketAddress[addresses.size()] ); <END> }</code><technical_language>This ultimately transformed a Set? this method returning array</technical_language>

Target:
public Stream<SrvRecord> resolveSrvRecord( String url ) throws NamingException { Attributes attrs = _idc.orElseGet( this::setIdc ).getAttributes( url, SRV_RECORDS ); return enumerationAsStream( (NamingEnumeration<String>) attrs.get( SRV_ATTR ).getAll() ).map( SrvRecord::parse ); }
Source:
<code>private void generateDoGetMethod(Parameter mainParameter, JavaTypeReference mainTypeReference) { String parameterName = javaNames.getJavaMemberStyleName(mainParameter.getName()); javaBuffer.addLine("default public %s doGet() {", mainTypeReference.getText()); <START> javaBuffer.addLine(mainTypeReference.getText() + " " + parameterName + " = get();"); <END> javaBuffer.addLine("follow(%s);", parameterName); javaBuffer.addLine("return %s;", parameterName); javaBuffer.addLine("}"); }</code><technical_language>Try avoid string concatenation, printf-like instead, do in rest of code: javaBuffer.addLine( "%s %s = get();", mainTypeReference.getText(), parameterName );</technical_language>

Target:
private void generateDoGetMethod(Parameter mainParameter, JavaTypeReference mainTypeReference) { String parameterName = javaNames.getJavaMemberStyleName(mainParameter.getName()); javaBuffer.addLine("default public %s doGet() {", mainTypeReference.getText()); javaBuffer.addLine("%s %s = get();", mainTypeReference.getText(), parameterName); javaBuffer.addLine("follow(%s);", parameterName); javaBuffer.addLine("return %s;", parameterName); javaBuffer.addLine("}"); }
Source:
<code>public ValidationResult isVirtIoScsiValid(VM vm) { <START> if (diskVmElement != null && DiskInterface.VirtIO_SCSI != diskVmElement.getDiskInterface()) { <END> return ValidationResult.VALID; } if (disk.getSgio() != null && DiskStorageType.IMAGE == disk.getDiskStorageType()) { return new ValidationResult(EngineMessage.SCSI_GENERIC_IO_IS_NOT_SUPPORTED_FOR_IMAGE_DISK); } if (vm == null) { return ValidationResult.VALID; } if (!isVirtioScsiControllerAttached(vm)) { return new ValidationResult(EngineMessage.CANNOT_PERFORM_ACTION_VIRTIO_SCSI_IS_DISABLED); } return isDiskInterfaceSupported(vm); }</code><technical_language>is VM null perhaps? move condition line 63 up</technical_language>

Target:
public ValidationResult isVirtIoScsiValid(VM vm) { if (vm == null) { return ValidationResult.VALID; } if (diskVmElement != null && DiskInterface.VirtIO_SCSI != diskVmElement.getDiskInterface()) { return ValidationResult.VALID; } if (disk.getSgio() != null && DiskStorageType.IMAGE == disk.getDiskStorageType()) { return new ValidationResult(EngineMessage.SCSI_GENERIC_IO_IS_NOT_SUPPORTED_FOR_IMAGE_DISK); } if (!isVirtioScsiControllerAttached(vm)) { return new ValidationResult(EngineMessage.CANNOT_PERFORM_ACTION_VIRTIO_SCSI_IS_DISABLED); } return isDiskInterfaceSupported(vm); }
Source:
<code>public BigDecimal getBuyPrice(IEssentials ess, ItemStack itemStack) { BigDecimal result; String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); <START> result = config.getBigDecimal("buy." + itemname + "." + itemStack.getDurability(), BigDecimal.ONE.negate()); <END> if (result.signum() < 0) { final ConfigurationSection itemNameMatch = config.getConfigurationSection("buy." + itemname); if (itemNameMatch != null && itemNameMatch.getKeys(false).size() == 1) { result = config.getBigDecimal("buy." + itemname + ".0", BigDecimal.ONE.negate()); } } if (result.signum() < 0) { result = config.getBigDecimal("buy." + itemname + ".*", BigDecimal.ONE.negate()); } if (result.signum() < 0) { result = config.getBigDecimal("buy." + itemname, BigDecimal.ONE.negate()); } if (result.signum() < 0) { return getPrice(ess, itemStack); } return result; }</code><technical_language>nit: separate declaration initial assignment - reason separate it</technical_language>

Target:
public BigDecimal getBuyPrice(IEssentials ess, ItemStack itemStack) { BigDecimal result = getPrice(ess, itemStack, "buy"); if (result.signum() < 0) { return getWorthPrice(ess, itemStack); } return result; }
Source:
<code>public String toString() { StringBuilder sb = new StringBuilder("AwareNetworkRequestInformation: "); sb.append("state=").append(state).append(", role=").append(role).append( ", uid=").append(uid).append(", interfaceName=").append(interfaceName).append( ", pubSubId=").append(pubSubId).append(", peerDiscoveryMac=").append( peerDiscoveryMac == null ? "" : String.valueOf(HexEncoding.encode(peerDiscoveryMac))).append( <START> ", pmk=").append(pmk).append(", <END> ndpId=").append(ndpId).append( ", peerDataMac=").append( peerDataMac == null ? "" : String.valueOf(HexEncoding.encode(peerDataMac))); return sb.toString(); }</code><technical_language>leave this out, conditional VDBG</technical_language>

Target:
public String toString() { StringBuilder sb = new StringBuilder("AwareNetworkRequestInformation: "); sb.append("state=").append(state).append(", role=").append(role).append( ", uid=").append(uid).append(", interfaceName=").append(interfaceName).append( ", pubSubId=").append(pubSubId).append(", peerDiscoveryMac=").append( peerDiscoveryMac == null ? "" : String.valueOf(HexEncoding.encode(peerDiscoveryMac))).append( ", ndpId=").append(ndpId).append(", peerDataMac=").append( peerDataMac == null ? "" : String.valueOf(HexEncoding.encode(peerDataMac))); return sb.toString(); }
Source:
<code>public void canCreateLock() { String rgName = generateRandomResourceName("rgloc", 15); String lockName = generateRandomResourceName("lock", 15); ResourceGroup resourceGroup = resourceClient.resourceGroups().define(rgName) .withRegion(Region.US_WEST) .create(); ManagementLock lock = resourceClient.managementLocks().define(lockName) .withLockedResourceGroup(resourceGroup) .withLevel(LockLevel.CAN_NOT_DELETE) .create(); Assertions.assertNotNull(lock); Assertions.assertEquals(resourceGroup.id(), lock.lockedResourceId()); <START> <END> try { resourceClient.resourceGroups().deleteByName(rgName); } catch (ManagementException ex) { Assertions.assertEquals("ScopeLocked", ex.getValue().getCode()); } resourceClient.managementLocks().deleteById(lock.id()); resourceClient.resourceGroups().deleteByName(rgName); }</code><technical_language>add update? I finding code get resourceId lockId in LockImpl, needed for update</technical_language>

Target:
public void canCreateLock() { String rgName = generateRandomResourceName("rgloc", 15); String lockName = generateRandomResourceName("lock", 15); ResourceGroup resourceGroup = resourceClient.resourceGroups().define(rgName) .withRegion(Region.US_WEST) .create(); ManagementLock lock = resourceClient.managementLocks().define(lockName) .withLockedResourceGroup(resourceGroup) .withLevel(LockLevel.CAN_NOT_DELETE) .create(); Assertions.assertNotNull(lock); Assertions.assertEquals(resourceGroup.id(), lock.lockedResourceId()); boolean failed = false; try { resourceClient.resourceGroups().deleteByName(rgName); } catch (ManagementException ex) { failed = true; Assertions.assertEquals("ScopeLocked", ex.getValue().getCode()); } Assertions.assertTrue(failed); resourceClient.managementLocks().deleteById(lock.id()); resourceClient.resourceGroups().deleteByName(rgName); }
Source:
<code>public boolean matchesSafely(final Response item) { try { final String head = item.head().iterator().next(); final String[] parts = head.split(" "); return this.expected.matches(Integer.parseInt(parts[1])); <START> } catch (final IOException exception) { <END> throw new IllegalStateException(exception); } }</code><technical_language>@erimerturk rename this ex</technical_language>

Target:
public boolean matchesSafely(final Response item) { try { final String head = item.head().iterator().next(); final String[] parts = head.split(" "); return this.matcher.matches(Integer.parseInt(parts[1])); } catch (final IOException ex) { throw new IllegalStateException(ex); } }
Source:
<code>public void checkLaunchingCodeServer() throws Exception { ide.open(testWorkspace); String expectedTextOnCodeServerPage = "GWT Code Server\n" + "Drag these two bookmarklets to your browser's bookmark bar:\n" + "Dev Mode On Dev Mode Off\n" + "Visit a web page that uses one of these modules:\n" + "GWT\n" + "Click \"Dev Mode On\" to start development mode."; projectExplorer.waitItem(projectName); toastLoader.waitAppeareanceAndClosing(); projectExplorer.selectItem(projectName); projectExplorer.invokeCommandWithContextMenu(COMMON, projectName, BUILD_COMMAND); consoles.waitExpectedTextIntoConsole(BUILD_SUCCESS, 600); projectExplorer.invokeCommandWithContextMenu(COMMON, projectName, RUN_GWT_COMMAND); consoles.waitExpectedTextIntoConsole("The code server is ready", APPLICATION_START_TIMEOUT_SEC); String url = workspaceServiceClient <START> .getServerFromDevMachineBySymbolicName(testWorkspace.getId(), "9876/tcp") <END> .getUrl(); ide.driver().get(url); new WebDriverWait(ide.driver(), REDRAW_UI_ELEMENTS_TIMEOUT_SEC) .until( ExpectedConditions.textToBePresentInElementLocated( By.tagName("body"), expectedTextOnCodeServerPage)); }</code><technical_language>this symbolic name change? AFAIK a policy create servers for exposed ports if user provided server. So, I suggest adding server workspace config instead</technical_language>

Target:
public void checkLaunchingCodeServer() throws Exception { ide.open(testWorkspace); String expectedTextOnCodeServerPage = "GWT Code Server\n" + "Drag these two bookmarklets to your browser's bookmark bar:\n" + "Dev Mode On Dev Mode Off\n" + "Visit a web page that uses one of these modules:\n" + "GWT\n" + "Click \"Dev Mode On\" to start development mode."; projectExplorer.waitItem(projectName); toastLoader.waitAppeareanceAndClosing(); projectExplorer.selectItem(projectName); projectExplorer.invokeCommandWithContextMenu(COMMON, projectName, BUILD_COMMAND); consoles.waitExpectedTextIntoConsole(BUILD_SUCCESS, 600); projectExplorer.invokeCommandWithContextMenu(COMMON, projectName, RUN_GWT_COMMAND); consoles.waitExpectedTextIntoConsole("The code server is ready", APPLICATION_START_TIMEOUT_SEC); String url = workspaceServiceClient .getServerFromDevMachineBySymbolicName(testWorkspace.getId(), GWT_CODESERVER_NAME) .getUrl(); ide.driver().get(url); new WebDriverWait(ide.driver(), REDRAW_UI_ELEMENTS_TIMEOUT_SEC) .until( ExpectedConditions.textToBePresentInElementLocated( By.tagName("body"), expectedTextOnCodeServerPage)); }
Source:
<code>public JComponent render(AnalyzerResultFuture<? extends AnalyzerResult> renderable) { final JXBusyLabel busyLabel = new JXBusyLabel(); busyLabel.setBusy(true); final DCPanel resultPanel = new DCPanel(); resultPanel.add(busyLabel); resultPanel.updateUI(); renderable.addListener(new AnalyzerResultFuture.Listener<AnalyzerResult>() { @Override public void onSuccess(AnalyzerResult result) { Renderer<? super AnalyzerResult, ? extends JComponent> renderer = _rendererFactory.getRenderer(result, SwingRenderingFormat.class); if (renderer != null) { JComponent jComponent = renderer.render(result); resultPanel.add(jComponent); } else { <START> logger.error("No renderer found for: " + result); <END> } resultPanel.remove(busyLabel); resultPanel.updateUI(); } @Override public void onError(RuntimeException error) { logger.error("Error occured while retrieving AnalyzerResult from AnalyzerResultFuture" + error); } }); return resultPanel; }</code><technical_language>I guess user this ... see? I guess behaviour ResultWindow find a renderer</technical_language>

Target:
public JComponent render(AnalyzerResultFuture<? extends AnalyzerResult> renderable) { final LoadingIcon loadingIcon = new LoadingIcon(); final DCPanel resultPanel = new DCPanel(); resultPanel.add(loadingIcon); resultPanel.updateUI(); renderable.addListener(new AnalyzerResultFuture.Listener<AnalyzerResult>() { @Override public void onSuccess(AnalyzerResult result) { try { Renderer<? super AnalyzerResult, ? extends JComponent> renderer = _rendererFactory.getRenderer(result, SwingRenderingFormat.class); if (renderer != null) { logger.debug("renderer.render({})", result); final JComponent component = renderer.render(result); resultPanel.add(component); } else { final String message = "No renderer found for result type " + result.getClass().getName(); logger.error(message); throw new IllegalStateException(message); } } finally { resultPanel.remove(loadingIcon); resultPanel.updateUI(); } } @Override public void onError(RuntimeException error) { WidgetUtils.showErrorMessage("Unable to fetch result", error); } }); return resultPanel; }
Source:
<code>private void discardWithTableHints() { <START> if (readIf("WITH")) { <END> read(OPEN_PAREN); if (!readIf(CLOSE_PAREN)) { do { discardTableHint(); } while (readIfMore(true)); } } }</code><technical_language>readIf(WITH) instead, is a keyword token type</technical_language>

Target:
private void discardWithTableHints() { if (readIf(WITH)) { read(OPEN_PAREN); do { discardTableHint(); } while (readIfMore(true)); } }
Source:
<code><START> private final SuggestionMenu setupSuggestion() { <END> SuggestionMenu suggestion = new SuggestionMenu(MAX_SUGGESTIONS).setActionHandler(this::menuItemHandler); suggestion.loadSuggestions(keywords); return suggestion; }</code><technical_language>This method is private, final -- overridden anyway</technical_language>

Target:
private SuggestionsMenu setupSuggestion() { SuggestionsMenu suggestion = new SuggestionsMenu(MAX_SUGGESTIONS).setActionHandler(this::menuItemHandler); suggestion.loadSuggestions(keywords); return suggestion; }
Source:
<code>public Entity getMouseOverEntity() { <START> return Minecraft.getMinecraft().objectMouseOver.entityHit; <END> }</code><technical_language>here, in theory objectMouseOver null, Vanilla null check time, do</technical_language>

Target:
public Entity getMouseOverEntity() { RayTraceResult r = Minecraft.getMinecraft().objectMouseOver; if (r == null) return null; return r.entityHit; }
Source:
<code>public void setSaveOffline(boolean saved) { <START> if (pages.size() == 0) { <END> emptyListSavePagesState = saved; return; } for (ReadingListPage page : pages) { page.savedOrSaving(saved); ReadingListPageDao.instance().upsert(page); } }</code><technical_language>isEmpty()</technical_language>

Target:
public void setSaveOffline(boolean saved) { if (pages.isEmpty()) { emptyListSavePagesState = saved; return; } for (ReadingListPage page : pages) { page.savedOrSaving(saved); ReadingListPageDao.instance().upsert(page); } }
Source:
<code>private boolean isActionFilter(FilterSet filterSet) { boolean result = true; if (filterSet.getActionFilterOrder() == null) { result = false; } <START> return result; <END> }</code><technical_language>return filterSet.getActionFilterOrder() != null</technical_language>

Target:
private boolean isActionFilter(FilterSet filterSet) { return filterSet.getActionFilterOrder() != null; }
Source:
<code>private Entity getDataPointAssignment(DatastoreService ds, long deviceId, long surveyAssignmentId, long surveyId) { try { Query.Filter f1 = new FilterPredicate("deviceId", FilterOperator.EQUAL, deviceId); Query.Filter f2 = new FilterPredicate("surveyAssignmentId", FilterOperator.EQUAL, surveyAssignmentId); Query.Filter f3 = new FilterPredicate("surveyId", FilterOperator.EQUAL, surveyId); Query q = new Query("DataPointAssignment"); q.setFilter(Query.CompositeFilterOperator.and(f1, f2, f3)); PreparedQuery pq = ds.prepare(q); return pq.asSingleEntity(); } catch (Exception e) { <START> throw new Error("Error DataPointAssignment duplicated! deviceId: " + deviceId + " surveyAssignmentId: " + surveyAssignmentId + " surveyId: " + surveyId); <END> } }</code><technical_language>_broken data_ in Datastore, instead of aborting, log problem continue rest</technical_language>

Target:
private Entity getDataPointAssignment(DatastoreService ds, long deviceId, long surveyAssignmentId, long surveyId) { Query.Filter f1 = new FilterPredicate("deviceId", FilterOperator.EQUAL, deviceId); Query.Filter f2 = new FilterPredicate("surveyAssignmentId", FilterOperator.EQUAL, surveyAssignmentId); Query.Filter f3 = new FilterPredicate("surveyId", FilterOperator.EQUAL, surveyId); Query q = new Query("DataPointAssignment"); q.setFilter(Query.CompositeFilterOperator.and(f1, f2, f3)); PreparedQuery pq = ds.prepare(q); return pq.asSingleEntity(); }
Source:
<code>public CommandResult execute(CommandInvocation commandInvocation) throws IOException { if (help || arguments == null || arguments.isEmpty()) { commandInvocation.getShell().out().println(commandInvocation.getHelpInfo("rm")); return CommandResult.SUCCESS; } for (Resource r : arguments) { <START> Resource currentWorkingDirectory = commandInvocation.getAeshContext().getCurrentWorkingDirectory(); <END> Shell shell = commandInvocation.getShell(); Resource resource = r.resolve(currentWorkingDirectory).get(0); if (dir) { rmDir(resource, commandInvocation); } else { rmFile(resource, commandInvocation); } } return CommandResult.SUCCESS; }</code><technical_language>move this line out of loop</technical_language>

Target:
public CommandResult execute(CommandInvocation commandInvocation) throws IOException, InterruptedException { if (help || arguments == null || arguments.isEmpty()) { commandInvocation.getShell().out().println(commandInvocation.getHelpInfo("rm")); return CommandResult.SUCCESS; } Resource currentWorkingDirectory = commandInvocation.getAeshContext().getCurrentWorkingDirectory(); for (Resource r : arguments) { Shell shell = commandInvocation.getShell(); Resource resource = r.resolve(currentWorkingDirectory).get(0); if (dir) { rmDir(resource, commandInvocation); } else { rmFile(resource, commandInvocation); } } return CommandResult.SUCCESS; }
Source:
<code>public boolean accept(String dimVal) { if (dimVal == null) { return false; } final String input = caseSensitive ? dimVal : dimVal.toLowerCase(); <START> return input.contains(target); <END> }</code><technical_language>improving this code anyway, I switch [StringUtils.containsIngoreCase](<LINK_0>, java.lang.String%29) instead of toLowerCase+contains, lowercasing a string is for non-ascii characters</technical_language>

Target:
public boolean accept(String dimVal) { if (dimVal == null || value == null) { return false; } if (caseSensitive) { return dimVal.contains(value); } return org.apache.commons.lang.StringUtils.containsIgnoreCase(dimVal, value); }
Source:
<code>public void testMoreOptionsDiscardImage() { onDrawingSurfaceView() .perform(touchAt(DrawingSurfaceLocationProvider.MIDDLE)); onDrawingSurfaceView() .checkPixelColor(Color.BLACK, BitmapLocationProvider.MIDDLE); onTopBarView() <START> .onMoreOptionsClicked(); <END> onView(withText(R.string.menu_discard_image)) .perform(click()); onDrawingSurfaceView() .checkPixelColor(Color.TRANSPARENT, BitmapLocationProvider.MIDDLE); }</code><technical_language>please rename performOpenMoreOptions</technical_language>

Target:
public void testMoreOptionsDiscardImage() { onDrawingSurfaceView() .perform(touchAt(DrawingSurfaceLocationProvider.MIDDLE)); onDrawingSurfaceView() .checkPixelColor(Color.BLACK, BitmapLocationProvider.MIDDLE); onTopBarView() .performOpenMoreOptions(); onView(withText(R.string.menu_discard_image)) .perform(click()); onDrawingSurfaceView() .checkPixelColor(Color.TRANSPARENT, BitmapLocationProvider.MIDDLE); }
Source:
<code>protected void initVm() { if (!isInitVmRequired()) { return; } fetchVmDisksFromDb(); updateVmDevicesOnRun(); updateGraphicsAndDisplayInfos(); getVm().setRunAndPause(getParameters().getRunAndPause() == null ? getVm().isRunAndPause() : getParameters().getRunAndPause()); getVm().setConsoleUserId(null); updateVmInit(); if (!StringUtils.isEmpty(getParameters().getFloppyPath()) && isPayloadExists(VmDeviceType.FLOPPY)) { vmPayload = null; } updateVmGuestAgentVersion(); if (!getVm().isUsingCpuPassthrough() && getVm().getCpuName() == null) { if (getVm().getCustomCpuName() != null) { <START> getVm().setCpuName(getVm().getCustomCpuName()); <END> } else { getVm().setCpuName(getCluster().getCpuVerb()); } } if (getVm().getEmulatedMachine() == null) { getVm().setEmulatedMachine(getEffectiveEmulatedMachine()); } }</code><technical_language>sense refactor CpuName get/setCpuVerb CustomCpuVerb</technical_language>

Target:
protected void initVm() { if (!isInitVmRequired()) { return; } fetchVmDisksFromDb(); updateVmDevicesOnRun(); updateGraphicsAndDisplayInfos(); getVm().setRunAndPause(getParameters().getRunAndPause() == null ? getVm().isRunAndPause() : getParameters().getRunAndPause()); getVm().setConsoleUserId(null); updateVmInit(); if (!StringUtils.isEmpty(getParameters().getFloppyPath()) && isPayloadExists(VmDeviceType.FLOPPY)) { vmPayload = null; } updateVmGuestAgentVersion(); if (!getVm().isUsingCpuPassthrough() && getVm().getCpuName() == null) { if (getVm().getCustomCpuName() != null) { getVm().setCpuName(getVm().getCustomCpuName()); } else { if (getCluster().getCompatibilityVersion().equals(getVm().getCompatibilityVersion())) { getVm().setCpuName(getCluster().getCpuVerb()); } else { getVm().setCpuName(getCpuFlagsManagerHandler().getCpuId( getVm().getClusterCpuName(), getVm().getCompatibilityVersion())); } } } if (getVm().getEmulatedMachine() == null) { getVm().setEmulatedMachine(getEffectiveEmulatedMachine()); } }
Source:
<code>public static Algorithm getAlgorithmNamed(BasicFBType basicFBType, String name) { <START> for(Algorithm alg : basicFBType.getAlgorithm()) { if(alg.getName().equals(name)) { return alg; } } return null; <END> }</code><technical_language>return basicFBType.getAlgorithm().filter(alg -> alg.getName().equals(name)).FindFirst().OrElse(null); fit in line (assuming stream is correct)</technical_language>

Target:
public static Algorithm getAlgorithmNamed(BasicFBType basicFBType, String name) { return basicFBType.getAlgorithm().stream().filter(alg -> alg.getName().equals(name)).findFirst().orElse(null); }