auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void doubleClick() { waitForEnabled(); <START> Assert.isTrue(selectionCount() == 1, <END> MessageFormat.format("Double click on list cannot be done as selection count is not 1.")); log.debug(MessageFormat.format("Double-clicking on {0}", this)); notifySelect(true); notifyPostSelectDoubleClick(); }</code><technical_language>I thought this method double-click current selection, empty multiple (SWT.MULTI case)? I Linux: If selection is empty double-click empty space, get Selection (but get DefaultSelection). If multiple selection Shift+double-click selected item, get normal events (just stateMasks of Shift). creaseMouseEvent() List bounds, click in middle of List. more if calculated middle y-coordinate of selected list item, based getSelectionIndex, getTopIndex getItemHeight. if time ;)</technical_language>

Target:
public void doubleClick() { waitForEnabled(); log.debug(MessageFormat.format("Double-clicking on {0}", this)); notifySelect(true); notifyPostSelectDoubleClick(); }
Source:
<code>public void expectMessages(List<String> messages) { receivedRequests.clear(); expectedMessages = messages; messages.forEach(m -> listener .register( post(urlEqualTo(path)) <START> .willReturn(aResponse().withStatus(returnedStatusCode).withFixedDelay(delay).withHeader("Location", "http://localhost:1234")))); <END> }</code><technical_language>is Location header required here</technical_language>

Target:
public void expectMessages(List<String> messages) { receivedRequests.clear(); expectedMessages = messages; messages.forEach(m -> listener .register( post(urlEqualTo(path)) .willReturn(aResponse().withStatus(returnedStatusCode).withFixedDelay(delay)))); }
Source:
<code>public MotionController(PIDSensor sensor) { this.sensor = sensor; output = null; timer = new Timer(); <START> task = new MotionControllerTask(); <END> enable = true; absoluteTolerance = Util.EPSILON; capOutput = false; continuous = false; inputMin = 0.0; inputMax = 0.0; outputMin = 0.0; outputMax = 0.0; reset(); justReset = true; mcException = null; }</code><technical_language>ScheduledThreadPoolExecutor Timer multiple worker threads, case multiple MotionControllers running concurrently</technical_language>

Target:
public MotionController(PIDSensor sensor) { this.sensor = sensor; output = null; timer = new Timer(); task = new MotionControllerTask(); enable = true; absoluteTolerance = Double.MIN_VALUE; capOutput = false; continuous = false; inputMin = 0.0; inputMax = 0.0; outputMin = 0.0; outputMax = 0.0; reset(); justReset = true; sensorException = null; }
Source:
<code><START> public void does_nothing_when_user_can_already_edit_profile() { <END> OrganizationDto organization = db.organizations().insert(); QProfileDto profile = db.qualityProfiles().insert(organization, p -> p.setLanguage(XOO)); UserDto user = db.users().insertUser(); db.organizations().addMember(organization, user); db.qualityProfiles().addUser(profile, user); assertThat(db.getDbClient().qProfileEditUsersDao().exists(db.getSession(), profile, user)).isTrue(); userSession.logIn().addPermission(OrganizationPermission.ADMINISTER_QUALITY_PROFILES, organization); ws.newRequest() .setParam(PARAM_QUALITY_PROFILE, profile.getName()) .setParam(PARAM_LANGUAGE, XOO) .setParam(PARAM_LOGIN, user.getLogin()) .setParam(PARAM_ORGANIZATION, organization.getKey()) .execute(); assertThat(db.getDbClient().qProfileEditUsersDao().exists(db.getSession(), profile, user)).isTrue(); }</code><technical_language>I understand test is done? count elements in db check element</technical_language>

Target:
public void does_nothing_when_user_can_already_edit_profile() { OrganizationDto organization = db.organizations().insert(); QProfileDto profile = db.qualityProfiles().insert(organization, p -> p.setLanguage(XOO)); UserDto user = db.users().insertUser(); db.organizations().addMember(organization, user); db.qualityProfiles().addUserPermission(profile, user); assertThat(db.getDbClient().qProfileEditUsersDao().exists(db.getSession(), profile, user)).isTrue(); userSession.logIn().addPermission(OrganizationPermission.ADMINISTER_QUALITY_PROFILES, organization); ws.newRequest() .setParam(PARAM_QUALITY_PROFILE, profile.getName()) .setParam(PARAM_LANGUAGE, XOO) .setParam(PARAM_LOGIN, user.getLogin()) .setParam(PARAM_ORGANIZATION, organization.getKey()) .execute(); assertThat(db.getDbClient().qProfileEditUsersDao().exists(db.getSession(), profile, user)).isTrue(); }
Source:
<code>protected Map<String, String> evaluateAnnotationPlaceholders( NamespaceResolutionContext namespaceCtx) { Map<String, String> evaluatedAnnotations = new HashMap<>(); for (String labelName : namespaceAnnotations.keySet()) { <START> String evaluatedLabelValue = <END> namespaceAnnotations .get(labelName) .replace(USERNAME_PLACEHOLDER, namespaceCtx.getUserName()); evaluatedAnnotations.put(labelName, evaluatedLabelValue); } return evaluatedAnnotations; }</code><technical_language>evaluatedAnnotationValue evaluatedValue</technical_language>

Target:
protected Map<String, String> evaluateAnnotationPlaceholders( NamespaceResolutionContext namespaceCtx) { Map<String, String> evaluatedAnnotations = new HashMap<>(); for (String annotationName : namespaceAnnotations.keySet()) { String evaluatedAnnotationValue = namespaceAnnotations .get(annotationName) .replace(USERNAME_PLACEHOLDER, namespaceCtx.getUserName()); evaluatedAnnotations.put(annotationName, evaluatedAnnotationValue); } return evaluatedAnnotations; }
Source:
<code>private boolean checkFreeSpace() { if (!hasFreeSpace(getStorageDomain())) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DISK_SPACE_LOW); <START> return false; <END> } return true; }</code><technical_language>failCanDoAction</technical_language>

Target:
private boolean checkFreeSpace() { if (!hasFreeSpace(getStorageDomain())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_DISK_SPACE_LOW); } return true; }
Source:
<code>public static Map<String, Map<String, Object>> getTopologyLag(StormTopology userTopology, Map<String,Object> config) { <START> Boolean disableLagMonitoring = ObjectReader.getBoolean(config.get(DaemonConfig.UI_DISABLE_SPOUT_LAG_MONITORING), false); <END> return disableLagMonitoring ? Collections.EMPTY_MAP : TopologySpoutLag.lag(userTopology, config); }</code><technical_language>Nit: Consider adding default defaults.yaml instead of here. obvious users default is</technical_language>

Target:
public static Map<String, Map<String, Object>> getTopologyLag(StormTopology userTopology, Map<String,Object> config) { Boolean disableLagMonitoring = (Boolean)(config.get(DaemonConfig.UI_DISABLE_SPOUT_LAG_MONITORING)); return disableLagMonitoring ? Collections.EMPTY_MAP : TopologySpoutLag.lag(userTopology, config); }
Source:
<code>private boolean classExists(JavaSourceFacet javaSourceFacet) { JavaSource<?> source = buildJavaSource(javaSourceFacet); if (source == null) { return false; } boolean classAlreadyExists; try { JavaResource parsedJavaResource = javaSourceFacet.getJavaResource(source); classAlreadyExists = parsedJavaResource.exists(); } <START> catch (FileNotFoundException ex) <END> { classAlreadyExists = false; } return classAlreadyExists; }</code><technical_language>ResourceException thrown well. a multicatch in</technical_language>

Target:
private boolean classExists(JavaSourceFacet javaSourceFacet) { JavaSource<?> source = buildJavaSource(javaSourceFacet); if (source == null) { return false; } boolean classAlreadyExists; try { JavaResource parsedJavaResource = javaSourceFacet.getJavaResource(source); classAlreadyExists = parsedJavaResource.exists(); } catch (FileNotFoundException | ResourceException ex) { classAlreadyExists = false; } return classAlreadyExists; }
Source:
<code>public static Collection<Object[]> getSolutionFilesAsParameters() { List<Object[]> testParams = new ArrayList<>(); if (MOVE_THREAD_COUNTS_VALUE != null) { <START> String[] moveThreadCounts = MOVE_THREAD_COUNTS_VALUE.split("[,]"); <END> Set<String> uniqueMoveThreadCounts = new LinkedHashSet<>(); for (String moveThreadCount : moveThreadCounts) { boolean added = uniqueMoveThreadCounts.add(moveThreadCount); if (added) { testParams.add(new Object[]{moveThreadCount}); } } } else { testParams.add(new Object[]{DEFAULT_MOVE_THREAD_COUNT}); } return testParams; }</code><technical_language>[ ] obsolete is char</technical_language>

Target:
public static Collection<Object[]> getSolutionFilesAsParameters() { List<Object[]> testParams = new ArrayList<>(); if (MOVE_THREAD_COUNTS_STRING != null) { String[] moveThreadCounts = MOVE_THREAD_COUNTS_STRING.split(","); for (String moveThreadCount : moveThreadCounts) { testParams.add(new Object[]{moveThreadCount}); } } else { testParams.add(new Object[]{SolverConfig.MOVE_THREAD_COUNT_NONE}); } return testParams; }
Source:
<code>private boolean hasHeader(HttpServletResponse response, String headerName) { <START> return response.containsHeader(headerName); <END> }</code><technical_language>Thanks for cleanup, necessary for this PR this is change this class, leave this file out for now</technical_language>

Target:
private boolean hasHeader(HttpServletResponse response, String headerName) { return response.getHeader(headerName) != null; }
Source:
<code>static <T> Iterator<T> of(T... elements) { Objects.requireNonNull(elements, "elements is null"); <START> if (elements.length == 0) return Iterator.empty(); <END> return new AbstractIterator<T>() { int index = 0; @Override public boolean hasNext() { return index < elements.length; } @Override public T getNext() { return elements[index++]; } }; }</code><technical_language>please brackets java if (elements.length == 0) { return Iterator.empty(); }</technical_language>

Target:
static <T> Iterator<T> of(T... elements) { Objects.requireNonNull(elements, "elements is null"); if (elements.length == 0) { return Iterator.empty(); } else { return new AbstractIterator<T>() { int index = 0; @Override public boolean hasNext() { return index < elements.length; } @Override public T getNext() { return elements[index++]; } }; } }
Source:
<code>public List<UnhealthySubscription> listUnhealthyForOwner(@PathParam("ownerSourceName") String ownerSourceName, @PathParam("ownerId") String id) { OwnerSource ownerSource = ownerSources.getByName(ownerSourceName) .orElseThrow(() -> new OwnerSourceNotFound(ownerSourceName)); <START> if (!ownerSource.exists(id)) { <END> throw new OwnerSource.OwnerNotFound(ownerSourceName, id); } OwnerId ownerId = new OwnerId(ownerSource.name(), id); return subscriptionService.listUnhealthyForOwner(ownerId); }</code><technical_language>So..is owner name exist</technical_language>

Target:
public List<UnhealthySubscription> listUnhealthyForOwner(@PathParam("ownerSourceName") String ownerSourceName, @PathParam("ownerId") String id) { OwnerId ownerId = resolveOwnerId(ownerSourceName, id); return subscriptionService.listUnhealthyForOwner(ownerId); }
Source:
<code>ColumnChunkPageReader(BytesInputDecompressor decompressor, List<DataPage> compressedPages, DictionaryPage compressedDictionaryPage, OffsetIndex offsetIndex, long rowCount) { this.decompressor = decompressor; <START> this.compressedPages = new ArrayList<DataPage>(compressedPages); <END> this.compressedDictionaryPage = compressedDictionaryPage; long count = 0; for (DataPage p : compressedPages) { count += p.getValueCount(); } this.valueCount = count; this.offsetIndex = offsetIndex; this.rowCount = rowCount; }</code><technical_language>creating a new List of existing list</technical_language>

Target:
ColumnChunkPageReader(BytesInputDecompressor decompressor, List<DataPage> compressedPages, DictionaryPage compressedDictionaryPage, OffsetIndex offsetIndex, long rowCount) { this.decompressor = decompressor; this.compressedPages = new ArrayDeque<DataPage>(compressedPages); this.compressedDictionaryPage = compressedDictionaryPage; long count = 0; for (DataPage p : compressedPages) { count += p.getValueCount(); } this.valueCount = count; this.offsetIndex = offsetIndex; this.rowCount = rowCount; }
Source:
<code>private int createMostActiveBranchesMenuItems(Menu menu, Repository[] repositories) { int itemCount = 0; try { List<Map<String, Ref>> activeBranches = new ArrayList<>(); for (Repository repository : repositories) { Map<String, Ref> branchRefMapping = getMostActiveBranches( repository, MAX_NUM_MENU_ENTRIES); activeBranches.add(branchRefMapping); } Set<String> activeBranchIntersection = getBranchNameIntersection(activeBranches); for (String branchName : activeBranchIntersection) { itemCount++; createMenuItemMultiple(menu, repositories, branchName); } if (itemCount >= MAX_NUM_MENU_ENTRIES) { return itemCount; } List<Map<String, Ref>> localBranchMapping = new ArrayList<>(); <START> for (Repository repository : repositories) { <END> Map<String, Ref> localBranches = repository.getRefDatabase() .getRefs(Constants.R_HEADS); localBranchMapping.add(localBranches); } Set<String> localBranchNameIntersection = getBranchNameIntersection( localBranchMapping); localBranchNameIntersection.removeAll(activeBranchIntersection); if (itemCount > 0 && !localBranchNameIntersection.isEmpty()) createSeparator(menu); for (String localBranchName : localBranchNameIntersection) { itemCount++; if (itemCount > MAX_NUM_MENU_ENTRIES) { break; } createMenuItemMultiple(menu, repositories, localBranchName); } } catch (IOException e) { Activator.handleError(e.getMessage(), e, true); } return itemCount; }</code><technical_language>Indentation is wrong on</technical_language>

Target:
private int createMostActiveBranchesMenuItems(Menu menu, Repository[] repositories) { int itemCount = 0; try { List<Map<String, Ref>> activeBranches = new ArrayList<>(); for (Repository repository : repositories) { Map<String, Ref> branchRefMapping = getMostActiveBranches( repository, MAX_NUM_MENU_ENTRIES); activeBranches.add(branchRefMapping); } Set<String> activeBranchIntersection = getBranchNameIntersection(activeBranches); for (String branchName : activeBranchIntersection) { itemCount++; createMenuItemMultiple(menu, repositories, branchName); } if (itemCount >= MAX_NUM_MENU_ENTRIES) { return itemCount; } List<Map<String, Ref>> localBranchMapping = new ArrayList<>(); for (Repository repository : repositories) { Map<String, Ref> localBranches = repository.getRefDatabase() .getRefs(Constants.R_HEADS); localBranchMapping.add(localBranches); } Set<String> localBranchNameIntersection = getBranchNameIntersection( localBranchMapping); localBranchNameIntersection.removeAll(activeBranchIntersection); if (itemCount > 0 && !localBranchNameIntersection.isEmpty()) { createSeparator(menu); } for (String localBranchName : localBranchNameIntersection) { itemCount++; if (itemCount > MAX_NUM_MENU_ENTRIES) { break; } createMenuItemMultiple(menu, repositories, localBranchName); } } catch (IOException e) { Activator.handleError(e.getMessage(), e, true); } return itemCount; }
Source:
<code>public SWTBotButton buttonWithId(String key, Object value) { Matcher matcher = allOf(widgetOfType(Button.class), withId(key, value), withStyle(SWT.PUSH, "SWT.PUSH")); return new SWTBotButton((Button) widget(matcher), matcher); <START> } <END></code><technical_language>consistent, buttonWithId(key, value, index)</technical_language>

Target:
public SWTBotButton buttonWithId(String key, Object value) { return buttonWithId(key, value, 0); }
Source:
<code>public void addStatement(RemoteStatement statement) { <START> statements.add( statement ); <END> }</code><technical_language>is a add a addStatement? remove one. Btw, return this chain calls</technical_language>

Target:
public RemoteStatements addStatement(RemoteStatement statement) { statements.add( statement ); return this; }
Source:
<code>private static int getLineNoOfPreviousNode(final DetailAST node) { int start = 0; final DetailAST previous = node.getPreviousSibling(); <START> if (null != previous) { <END> start = previous.getLineNo(); } return start; }</code><technical_language>@dskalenko move null right hand side</technical_language>

Target:
private static int getLineNoOfPreviousNode(final DetailAST node) { int start = 0; final DetailAST previous = node.getPreviousSibling(); if (previous != null) { start = previous.getLineNo(); } return start; }
Source:
<code>public void shouldConvertFailureToFailedCompletableFuture() { CompletableFuture<Object> future = failure().toCompletableFuture(); assertThat(future.isDone()); assertThat(future.isCompletedExceptionally()); assertThatThrownBy(future::get) .isExactlyInstanceOf(ExecutionException.class) <START> .hasCauseExactlyInstanceOf(NonFatalException.class) <END> .hasRootCauseExactlyInstanceOf(RuntimeException.class); }</code><technical_language>Yes, unbox a NonFatalException in default toCompletableFuture impl. Unboxing is perfectly ok is public API allows a call-site construct a NonFatalException of a Try. Please find suggested impl above..</technical_language>

Target:
public void shouldConvertFailureToFailedCompletableFuture() { final CompletableFuture<Object> future = failure().toCompletableFuture(); assertThat(future.isDone()); assertThat(future.isCompletedExceptionally()); assertThatThrownBy(future::get) .isExactlyInstanceOf(ExecutionException.class) .hasCauseExactlyInstanceOf(RuntimeException.class); }
Source:
<code>private void updateValueMetadata(Record<Data> record, Data dataValue) { try { <START> Object valueMetadata = metadataInitializer.createFromData(dataValue); <END> Metadata existing = record.getMetadata(); if (existing != null) { existing.set(false, valueMetadata); } } catch (Exception e) { rethrow(e); } }</code><technical_language>Is more performant if parser works top of binary String values</technical_language>

Target:
private void updateValueMetadata(Record<Data> record, Data dataValue) { try { Object valueMetadata = metadataInitializer.createFromData(dataValue); if (valueMetadata != null) { Metadata existing = record.getMetadata(); if (existing == null) { existing = new Metadata(); record.setMetadata(existing); } existing.setValueMetadata(valueMetadata); } } catch (Exception e) { rethrow(e); } }
Source:
<code>public void scanHttpResponseReceive(HttpMessage msg, int id, Source source) { List<HttpCookie> cookies = msg.getResponseHeader().getHttpCookies(msg.getRequestHeader().getHostName()); String host = msg.getRequestHeader().getHostName(); Set<String> ignoreList = CookieUtils.getCookieIgnoreList(getModel()); List<HttpCookie> looselyScopedCookies = new LinkedList<HttpCookie>(); for (HttpCookie cookie : cookies) { if (isLooselyScopedCookie(cookie, host)) { <START> if (!ignoreList.contains(cookie.getName())) { <END> looselyScopedCookies.add(cookie); } } } if (looselyScopedCookies.size() > 0) { raiseAlert(msg, id, host, looselyScopedCookies); } }</code><technical_language>This done in if calling isLooselyScopedCookie, avoids work if cookie is ignored</technical_language>

Target:
public void scanHttpResponseReceive(HttpMessage msg, int id, Source source) { List<HttpCookie> cookies = msg.getResponseHeader().getHttpCookies(msg.getRequestHeader().getHostName()); String host = msg.getRequestHeader().getHostName(); Set<String> ignoreList = CookieUtils.getCookieIgnoreList(getModel()); List<HttpCookie> looselyScopedCookies = new LinkedList<HttpCookie>(); for (HttpCookie cookie : cookies) { if (!ignoreList.contains(cookie.getName()) && isLooselyScopedCookie(cookie, host)) { looselyScopedCookies.add(cookie); } } if (looselyScopedCookies.size() > 0) { raiseAlert(msg, id, host, looselyScopedCookies); } }
Source:
<code>void coordinateByMate() { final List<SAMRecord> newFirstOfPairOrFragment = new ArrayList<>(); final List<SAMRecord> newSecondOfPair = new ArrayList<>(); <START> <END> for (int i = 0; i < firstOfPairOrFragment.size(); i++) { final SAMRecord first = firstOfPairOrFragment.get(i); newFirstOfPairOrFragment.add(i, first); newSecondOfPair.add(null); for (int k = 0; k < secondOfPair.size(); k++) { final SAMRecord second = secondOfPair.get(k); if (arePair(first, second)) { newSecondOfPair.set(i, second); secondOfPair.set(k, null); break; } } } for (int i = 0; i < secondOfPair.size(); i++) { if (secondOfPair.get(i) != null) { newFirstOfPairOrFragment.add(i, null); newSecondOfPair.add(i, secondOfPair.get(i)); } } firstOfPairOrFragment.clear(); firstOfPairOrFragment.addAll(newFirstOfPairOrFragment); secondOfPair.clear(); secondOfPair.addAll(newSecondOfPair); renumberHitIndex(); }</code><technical_language>this file preferred ++i i++</technical_language>

Target:
void coordinateByMate() { final List<SAMRecord> newFirstOfPairOrFragment = new ArrayList<>(); final List<SAMRecord> newSecondOfPair = new ArrayList<>(); for (int i = 0; i < firstOfPairOrFragment.size(); ++i) { final SAMRecord first = firstOfPairOrFragment.get(i); newFirstOfPairOrFragment.add(i, first); newSecondOfPair.add(null); for (int k = 0; k < secondOfPair.size(); ++k) { final SAMRecord second = secondOfPair.get(k); if (arePair(first, second)) { newSecondOfPair.set(i, second); secondOfPair.set(k, null); break; } } } for (int i = 0; i < secondOfPair.size(); ++i) { if (secondOfPair.get(i) != null) { newFirstOfPairOrFragment.add(i, null); newSecondOfPair.add(i, secondOfPair.get(i)); } } firstOfPairOrFragment.clear(); firstOfPairOrFragment.addAll(newFirstOfPairOrFragment); secondOfPair.clear(); secondOfPair.addAll(newSecondOfPair); renumberHitIndex(); }
Source:
<code><START> public static HaplotypeBAMWriter createBamWriter(final AssemblyBasedCallerArgumentCollection args, final SAMFileHeader header) { <END> return args.bamOutputPath != null ? HaplotypeBAMWriter.create(args.bamWriterType, new File(args.bamOutputPath), header) : null; }</code><technical_language>Instead of returning null bamout path is defined, Optional. like: java public static Optional<HaplotypeBAMWriter> createBamWriter(final AssemblyBasedCallerArgumentCollection args, final SAMFileHeader header) { return args.bamOutputPath != null ? Optional.of(HaplotypeBAMWriter.create(args.bamWriterType, new File(args.bamOutputPath), header)) : Optional.empty(); } This signals reader variable is empty sometimes</technical_language>

Target:
public static Optional<HaplotypeBAMWriter> createBamWriter(final AssemblyBasedCallerArgumentCollection args, final SAMFileHeader header) { return args.bamOutputPath != null ? Optional.of(HaplotypeBAMWriter.create(args.bamWriterType, new File(args.bamOutputPath), header)) : Optional.empty(); }
Source:
<code>public void fillTimeValueForDatePickerTest(String timeId, Calendar newValue) { WebElement dateInputElement = browser.driver.findElement(By.id(timeId)); click(dateInputElement); dateInputElement.clear(); <START> dateInputElement.sendKeys(new SimpleDateFormat("EE").format(newValue.getTime()) + ", " <END> + newValue.get(Calendar.DATE) + " " + new SimpleDateFormat("MMM").format(newValue.getTime()) + ", " + newValue.get(Calendar.YEAR)); List<WebElement> elements = browser.driver.findElements(By.className("ui-datepicker-current-day")); for (WebElement element : elements) { click(element); } }</code><technical_language>of TimeHelper.formatDateForSessionForm here</technical_language>

Target:
public void fillTimeValueForDatePickerTest(String timeId, Calendar newValue) { WebElement dateInputElement = browser.driver.findElement(By.id(timeId)); click(dateInputElement); dateInputElement.clear(); dateInputElement.sendKeys(TimeHelper.formatDateForSessionsForm(newValue.getTime())); List<WebElement> elements = browser.driver.findElements(By.className("ui-datepicker-current-day")); for (WebElement element : elements) { click(element); } }
Source:
<code>public void testGetQueryResultWithoutSessionId() throws Exception { String sessionId = generateNewSessionAndGetId(); URI queryIdURI = sendNewQueryResquest(sessionId, "select * from lineitem"); URI queryResultURI = new URI(queryIdURI + "/result"); boolean isBadRequest = false; try { GetQueryResultDataResponse response = restClient.target(queryResultURI) .request() .get(new GenericType<>(GetQueryResultDataResponse.class)); } catch (BadRequestException e) { <START> isBadRequest = true; <END> } catch (Exception e) { } assertTrue(isBadRequest); }</code><technical_language>expected exception of junit? test codes simpler. Please refer test cases in TestCatalogAdminClientExceptions</technical_language>

Target:
public void testGetQueryResultWithoutSessionId() throws Exception { String sessionId = generateNewSessionAndGetId(); URI queryIdURI = sendNewQueryResquest(sessionId, "select * from lineitem"); URI queryResultURI = new URI(queryIdURI + "/result"); GetQueryResultDataResponse response = restClient.target(queryResultURI) .request() .get(new GenericType<>(GetQueryResultDataResponse.class)); }
Source:
<code>private List<Workflow> createBioWorkflowsAndVersionsFromDockstoreYml(List<YamlWorkflow> yamlWorkflows, String repository, String gitReference, GitHubSourceCodeRepo gitHubSourceCodeRepo, User user, final SourceFile dockstoreYml) { try { List<Workflow> updatedWorkflows = new ArrayList<>(); final Path gitRefPath = Path.of(gitReference); for (YamlWorkflow wf : yamlWorkflows) { final List<String> filters = wf.getFilter(); Boolean isFiltered = !filters.isEmpty(); for (String filter : filters) { <START> final PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher("glob:**/" + filter); <END> if (pathMatcher.matches(gitRefPath)) { isFiltered = false; break; } } if (isFiltered) { continue; } String subclass = wf.getSubclass(); String workflowName = wf.getName(); Workflow workflow = createOrGetWorkflow(BioWorkflow.class, repository, user, workflowName, subclass, gitHubSourceCodeRepo); workflow = addDockstoreYmlVersionToWorkflow(repository, gitReference, dockstoreYml, gitHubSourceCodeRepo, workflow); updatedWorkflows.add(workflow); } return updatedWorkflows; } catch (ClassCastException ex) { throw new CustomWebApplicationException("Could not parse workflow array from YML.", LAMBDA_FAILURE); } }</code><technical_language>worked this library (looks a good choice though) this **/ if specifies develop a filter match a branch called feature/develop? Alternatively, hubflow compatible? For example if specifies feature/foo a filter, this work match potato/feature/foo</technical_language>

Target:
private List<Workflow> createBioWorkflowsAndVersionsFromDockstoreYml(List<YamlWorkflow> yamlWorkflows, String repository, String gitReference, GitHubSourceCodeRepo gitHubSourceCodeRepo, User user, final SourceFile dockstoreYml) { try { List<Workflow> updatedWorkflows = new ArrayList<>(); final Path gitRefPath = Path.of(gitReference); for (YamlWorkflow wf : yamlWorkflows) { if (!DockstoreYamlHelper.filterGitReference(gitRefPath, wf.getFilters())) { continue; } String subclass = wf.getSubclass(); String workflowName = wf.getName(); Workflow workflow = createOrGetWorkflow(BioWorkflow.class, repository, user, workflowName, subclass, gitHubSourceCodeRepo); workflow = addDockstoreYmlVersionToWorkflow(repository, gitReference, dockstoreYml, gitHubSourceCodeRepo, workflow); updatedWorkflows.add(workflow); } return updatedWorkflows; } catch (ClassCastException ex) { throw new CustomWebApplicationException("Could not parse workflow array from YML.", LAMBDA_FAILURE); } }
Source:
<code>public static Bitmap centerCrop(Bitmap inputBitmap, int newWidth, int newHeight) { if (inputBitmap == null || inputBitmap.isRecycled()) { return null; } float sourceWidth = inputBitmap.getWidth(); float sourceHeight = inputBitmap.getHeight(); float xScale = newWidth / sourceWidth; float yScale = newHeight / sourceHeight; float newXScale; float newYScale; if (yScale > xScale) { <START> newXScale = (1.0f / yScale) * xScale; <END> newYScale = 1.0f; } else { newXScale = 1.0f; newYScale = (1.0f / xScale) * yScale; } float scaledWidth = newXScale * sourceWidth; float scaledHeight = newYScale * sourceHeight; int left = (int) ((sourceWidth - scaledWidth) / 2); int top = (int) ((sourceHeight - scaledHeight) / 2); int width = (int) scaledWidth; int height = (int) scaledHeight; return Bitmap.createBitmap(inputBitmap, left, top, width, height); }</code><technical_language>suggestion newXScale = xScale / yScale;</technical_language>

Target:
public static Bitmap centerCrop(Bitmap inputBitmap, int newWidth, int newHeight) { if (inputBitmap == null || inputBitmap.isRecycled()) { return null; } float sourceWidth = inputBitmap.getWidth(); float sourceHeight = inputBitmap.getHeight(); float xScale = newWidth / sourceWidth; float yScale = newHeight / sourceHeight; float newXScale; float newYScale; if (yScale > xScale) { newXScale = xScale / yScale; newYScale = 1.0f; } else { newXScale = 1.0f; newYScale = yScale / xScale; } float scaledWidth = newXScale * sourceWidth; float scaledHeight = newYScale * sourceHeight; int left = (int) ((sourceWidth - scaledWidth) / 2); int top = (int) ((sourceHeight - scaledHeight) / 2); int width = (int) scaledWidth; int height = (int) scaledHeight; return Bitmap.createBitmap(inputBitmap, left, top, width, height); }
Source:
<code>public ACL getACL(@Nonnull AbstractItem item) { <START> if(item instanceof WorkflowMultiBranchProject) { <END> GithubRequireOrganizationMembershipACL githubACL = (GithubRequireOrganizationMembershipACL) getRootACL(); return githubACL.cloneForProject(item); } else { return getRootACL(); } }</code><technical_language>Multibranch workflow specific type</technical_language>

Target:
public ACL getACL(@Nonnull AbstractItem item) { if(item instanceof MultiBranchProject) { GithubRequireOrganizationMembershipACL githubACL = (GithubRequireOrganizationMembershipACL) getRootACL(); return githubACL.cloneForProject(item); } else { return getRootACL(); } }
Source:
<code>public MethodsGroupBuilder methods(List<String> methodNames) { requireNonNull(methodNames, "methodNames is null"); checkArgument(!methodNames.isEmpty(), "methods list is empty"); List<MethodAndNativeContainerTypes> matchingMethods = asList(clazz.getMethods()).stream() .filter(method -> methodNames.contains(method.getName())) .map(method -> new MethodAndNativeContainerTypes(method, nCopies(signature.getArgumentTypes().size(), Optional.empty()))) .collect(toImmutableList()); List<String> matchingMethodNames = matchingMethods.stream() .map(methodAndNativeContainerTypes -> methodAndNativeContainerTypes.getMethod().getName()) .collect(toImmutableList()); for (String methodName : methodNames) { checkState(matchingMethodNames.contains(methodName), "method %s was not found in %s", methodName, clazz); } <START> this.methodAndNativeContainerTypes = matchingMethods; <END> return this; }</code><technical_language>I propose: * Change this this.methodAndNativeContainerTypes.addAll(matchingMethods) * methodWithExplicitJavaTypes add new methods (instead of modifying existing ones). * is done, sense methods methods delegate methodWithExplicitJavaTypes method. In general, strange setExplicitNativeContainerTypes exists MethodAndNativeContainerTypes</technical_language>

Target:
public MethodsGroupBuilder methods(List<String> methodNames) { requireNonNull(methodNames, "methodNames is null"); checkArgument(!methodNames.isEmpty(), "methods list is empty"); methodNames.forEach(methodName -> this.methodWithExplicitJavaTypes(methodName, nCopies(signature.getArgumentTypes().size(), Optional.empty()))); return this; }
Source:
<code>public ApiConstants.BootMode getBootMode() { if (StringUtils.isNotBlank(bootMode)) { try { String mode = bootMode.trim().toUpperCase(); return ApiConstants.BootMode.valueOf(mode); } catch (IllegalArgumentException e) { String errMesg = "Invalid bootMode " + bootMode + "Specified for vm " + getName() <START> + " Valid values are: LEGACY,SECURE "; <END> s_logger.warn(errMesg); throw new InvalidParameterValueException(errMesg); } } return null; }</code><technical_language>enum for valid values</technical_language>

Target:
public ApiConstants.BootMode getBootMode() { if (StringUtils.isNotBlank(bootMode)) { try { String mode = bootMode.trim().toUpperCase(); return ApiConstants.BootMode.valueOf(mode); } catch (IllegalArgumentException e) { String errMesg = "Invalid bootMode " + bootMode + "Specified for vm " + getName() + " Valid values are: "+ Arrays.toString(ApiConstants.BootMode.values()); s_logger.warn(errMesg); throw new InvalidParameterValueException(errMesg); } } return null; }
Source:
<code>public void init() { Collection<String> serviceIdList = conf.getTrimmedStringCollection(OZONE_OM_SERVICE_IDS_KEY); if (serviceIdList.size() == 0) { omServiceAdd = SecurityUtil.buildTokenService(OmUtils. getOmAddressForClients(conf)); } else { <START> Collection<String> serviceIds = <END> conf.getTrimmedStringCollection(OZONE_OM_SERVICE_IDS_KEY); if (serviceIds.size() > 1) { throw new IllegalArgumentException("Multiple serviceIds are " + "configured. " + serviceIds.toArray().toString()); } else { String serviceId = serviceIds.iterator().next(); Collection<String> omNodeIds = OmUtils.getOMNodeIds(conf, serviceId); if (omNodeIds.size() == 0) { throw new IllegalArgumentException(OZONE_OM_NODES_KEY + "." + serviceId + " is not defined"); } omServiceAdd = new Text(OzoneS3Util.buildServiceNameForToken(conf, serviceId, omNodeIds)); omserviceID = serviceId; } } }</code><technical_language>reuse serviceIdList avoid unnecessary call</technical_language>

Target:
public void init() { Collection<String> serviceIdList = conf.getTrimmedStringCollection(OZONE_OM_SERVICE_IDS_KEY); if (serviceIdList.size() == 0) { omServiceAddr = SecurityUtil.buildTokenService(OmUtils. getOmAddressForClients(conf)); } else { if (serviceIdList.size() > 1) { throw new IllegalArgumentException("Multiple serviceIds are " + "configured. " + Arrays.toString(serviceIdList.toArray())); } else { String serviceId = serviceIdList.iterator().next(); Collection<String> omNodeIds = OmUtils.getOMNodeIds(conf, serviceId); if (omNodeIds.size() == 0) { throw new IllegalArgumentException(OZONE_OM_NODES_KEY + "." + serviceId + " is not defined"); } omServiceAddr = new Text(OzoneS3Util.buildServiceNameForToken(conf, serviceId, omNodeIds)); omserviceID = serviceId; } } }
Source:
<code>public void testSerializeDeserialize() throws IOException { <START> ObjectMapper objectMapper = new ObjectMapper(); <END> final OrderType type = OrderType.ASK; final BigDecimal originalAmount = new BigDecimal("100.501"); final BigDecimal averagePrice = new BigDecimal("255.00"); final BigDecimal cumulativeAmount = new BigDecimal("0.00"); final CurrencyPair currencyPair = CurrencyPair.BTC_USD; final BigDecimal limitPrice = new BigDecimal("250.34"); final BigDecimal fee = new BigDecimal("22.2"); final Date timestamp = new Date(); final String id = "id"; final Order.OrderStatus status = Order.OrderStatus.FILLED; final LimitOrder original = new LimitOrder( type, originalAmount, currencyPair, id, timestamp, limitPrice, averagePrice, cumulativeAmount, fee, status); original.addOrderFlag(TestFlags.TEST1); original.addOrderFlag(TestFlags.TEST3); LimitOrder jsonCopy = ObjectMapperHelper.viaJSON(original); assertThat(jsonCopy).isEqualToIgnoringGivenFields(original, "cumulativeAmount"); assertTrue(jsonCopy.getCumulativeAmount().compareTo(original.getCumulativeAmount()) == 0); }</code><technical_language>this is in method</technical_language>

Target:
public void testSerializeDeserialize() throws IOException { final OrderType type = OrderType.ASK; final BigDecimal originalAmount = new BigDecimal("100.501"); final BigDecimal averagePrice = new BigDecimal("255.00"); final BigDecimal cumulativeAmount = new BigDecimal("0.00"); final CurrencyPair currencyPair = CurrencyPair.BTC_USD; final BigDecimal limitPrice = new BigDecimal("250.34"); final BigDecimal fee = new BigDecimal("22.2"); final Date timestamp = new Date(); final String id = "id"; final Order.OrderStatus status = Order.OrderStatus.FILLED; final LimitOrder original = new LimitOrder( type, originalAmount, currencyPair, id, timestamp, limitPrice, averagePrice, cumulativeAmount, fee, status); original.addOrderFlag(TestFlags.TEST1); original.addOrderFlag(TestFlags.TEST3); LimitOrder jsonCopy = ObjectMapperHelper.viaJSON(original); assertThat(jsonCopy).isEqualToIgnoringGivenFields(original, "cumulativeAmount"); assertTrue(jsonCopy.getCumulativeAmount().compareTo(original.getCumulativeAmount()) == 0); }
Source:
<code>public boolean equals(Object o) { if (this == o) return true; if (o == null) return false; <START> if (getClass() != o.getClass()) <END> return false; TestAutoSerializerObject1 test = (TestAutoSerializerObject1) o; return Objects.equals(data1, test.data1) && Objects.equals(data2, test.data2) && Objects.equals(numData3, test.numData3); }</code><technical_language>merge this if statement returning value</technical_language>

Target:
public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TestAutoSerializerObject1 test = (TestAutoSerializerObject1) o; return Objects.equals(data1, test.data1) && Objects.equals(data2, test.data2) && Objects.equals(numData, test.numData); }
Source:
<code><START> @Override public void init(ServiceContext ctx) throws Exception { <END> }</code><technical_language>throws Exception is redundant</technical_language>

Target:
@Override public void init(ServiceContext ctx) { }
Source:
<code>public boolean onSpawnEntityInWorld(World world, Entity entity, IBlockSource source, ItemStack stack) { <START> ((Projectile) entity).setShooter((ProjectileSource) source.getBlockTileEntity()); <END> return world.spawnEntityInWorld(entity); }</code><technical_language>check entity is instance of Projectile. (example: Modded entities be) java TileEntity tileEntity = source.getBlockTileEntity(); if (entity instanceof Projectile && tileEntity instanceof ProjectileSource) { ((Projectile) entity).setShooter((ProjectileSource) tileEntity); } return world.spawnEntityInWorld(entity);</technical_language>

Target:
public boolean onSpawnEntityInWorld(World world, Entity entity, IBlockSource source, ItemStack stack) { TileEntity tileEntity = source.getBlockTileEntity(); if (entity instanceof Projectile && tileEntity instanceof ProjectileSource) { ((Projectile) entity).setShooter((ProjectileSource) tileEntity); } return world.spawnEntityInWorld(entity); }
Source:
<code>protected void execute() { try { int resetCode = starter.launch() .cmds(Arrays.asList(gitPath, "reset", "--hard", baseCommit)) .stdout(logStream) .join(); if (resetCode != 0) { info("Got non-zero exit code resetting to base commit " + baseCommit + ": " + resetCode); } starter.launch() .stdout(logStream) .cmds(Arrays.asList(gitPath, "clean", "-fd", "-f")) .join(); starter.launch() .stdout(logStream) .cmds(Arrays.asList(gitPath, "submodule", "update", "--init", "--recursive")) .join(); <START> List<String> params = new ArrayList<String>(Arrays.asList("--nobranch", "--diff", diffID)); <END> if (!createCommit) { params.add("--nocommit"); } ArcanistClient arc = new ArcanistClient( arcPath, "patch", conduitToken, params.toArray(new String[params.size()])); int result = arc.callConduit(starter.launch(), logStream); if (result == 0) { this.result = Result.SUCCESS; } else { this.result = Result.FAILURE; } } catch (IOException e) { e.printStackTrace(logStream); this.result = Result.FAILURE; } catch (InterruptedException e) { e.printStackTrace(logStream); this.result = Result.FAILURE; } }</code><technical_language>arcPatchParams more specific</technical_language>

Target:
protected void execute() { try { int exitCode = starter.launch() .cmds(Arrays.asList(gitPath, "reset", "--hard", baseCommit)) .stdout(logStream) .join(); if (exitCode != 0) { info("Got non-zero exit code resetting to base commit " + baseCommit + ": " + exitCode); } starter.launch() .stdout(logStream) .cmds(Arrays.asList(gitPath, "clean", "-fd", "-f")) .join(); starter.launch() .stdout(logStream) .cmds(Arrays.asList(gitPath, "submodule", "update", "--init", "--recursive")) .join(); List<String> arcPatchParams = new ArrayList<String>(Arrays.asList("--nobranch", "--diff", diffID)); if (!createCommit) { arcPatchParams.add("--nocommit"); } ArcanistClient arc = new ArcanistClient( arcPath, "patch", conduitToken, arcPatchParams.toArray(new String[arcPatchParams.size()])); exitCode = arc.callConduit(starter.launch(), logStream); this.result = exitCode == 0 ? Result.SUCCESS : Result.FAILURE; } catch (IOException e) { e.printStackTrace(logStream); this.result = Result.FAILURE; } catch (InterruptedException e) { e.printStackTrace(logStream); this.result = Result.FAILURE; } }
Source:
<code>public void refreshAll() { pruneStaleJobs(); Object[] listenersArray = listeners.getListeners(); <START> for (Object element : listenersArray) { <END> ((IJobProgressManagerListener)element).refreshAll(); } }</code><technical_language>inline listeners.getListeners()</technical_language>

Target:
public void refreshAll() { pruneStaleJobs(); for (Object element : listeners.getListeners()) { ((IJobProgressManagerListener)element).refreshAll(); } }
Source:
<code>private void initModerator() { <START> moderatorService.isModerator().thenAccept(isModerator -> { <END> if (!isModerator || getPlayer().getSocialStatus().equals(SocialStatus.SELF)) { return; } showModeratorOptions(true); }); }</code><technical_language>lets unit test cases kickGameItem set correct visibility</technical_language>

Target:
private void initModerator() { moderatorService.isModerator().thenAccept(isModeratorProperty::set); }
Source:
<code>private static List<Type> getInputTypes(Type valueType, int arity) { ImmutableList.Builder<Type> builder = ImmutableList.<Type>builder().add(valueType); if (arity > 1) { builder.add(BIGINT); } if (arity > 2) { builder.add(DOUBLE); } <START> return builder.build(); <END> }</code><technical_language>I this instead for simplicity switch (arity) { case 1: return ImmutableList.of(valueType); case 2: // weight return ImmutableList.of(valueType, BIGINT); case 3: // weight accuracy return ImmutableList.of(valueType, BIGINT, DOUBLE); default: throw ... }</technical_language>

Target:
private static List<Type> getInputTypes(Type valueType, int arity) { switch (arity) { case 1: return ImmutableList.of(valueType); case 2: return ImmutableList.of(valueType, BIGINT); case 3: return ImmutableList.of(valueType, BIGINT, DOUBLE); default: throw new IllegalArgumentException(format("Unsupported number of arguments: %s", arity)); } }
Source:
<code>private int maybeUpdateLastAckedSequence(TopicPartition topicPartition, int sequence) { if (sequence > lastAckedSequence(topicPartition).orElse(NO_LAST_ACKED_SEQUENCE_NUMBER)) { topicPartitionBookkeeper.getPartition(topicPartition).lastAckedSequence = sequence; return sequence; } <START> return NO_LAST_ACKED_SEQUENCE_NUMBER; <END> }</code><technical_language>This right. lastAckedSequence(topicPartition) exist</technical_language>

Target:
private int maybeUpdateLastAckedSequence(TopicPartition topicPartition, int sequence) { int lastAckedSequence = lastAckedSequence(topicPartition).orElse(NO_LAST_ACKED_SEQUENCE_NUMBER); if (sequence > lastAckedSequence) { topicPartitionBookkeeper.getPartition(topicPartition).lastAckedSequence = sequence; return sequence; } return lastAckedSequence; }
Source:
<code>public void deleteGroup(String username, String group) { <START> throw new RuntimeException("Deleting a group is not supporting in LDAP"); <END> }</code><technical_language>UnsupportedOperationException instead of a generic RuntimeException</technical_language>

Target:
public void deleteGroup(String username, String group) { throw new UnsupportedOperationException("Deleting a group is not supporting in LDAP"); }
Source:
<code>public static <T extends ToolInstallation> T addTool(Jenkins jenkins, Class<T> type) { final ConfigurablePageObject page = ensureConfigPage(jenkins); final String name = type.getAnnotation(ToolInstallationPageObject.class).name(); final Control expandButton = page.control(by.button(name + " installations...")); try { expandButton.click(); <START> } catch (Exception e) { <END> } final Control button = page.control(by.button("Add " + name)); String pathPrefix = button.resolve().getAttribute("path").replaceAll("repeatable-add", "tool"); String path = page.createPageArea(pathPrefix, button::click); return page.newInstance(type, jenkins, path); }</code><technical_language>more specific exception type is safe ignore here</technical_language>

Target:
public static <T extends ToolInstallation> T addTool(Jenkins jenkins, Class<T> type) { final ConfigurablePageObject page = ensureConfigPage(jenkins); final String name = type.getAnnotation(ToolInstallationPageObject.class).name(); final Control expandButton = page.control(by.button(name + " installations...")); try { expandButton.click(); } catch (NoSuchElementException e) { } final Control button = page.control(by.button("Add " + name)); String pathPrefix = button.resolve().getAttribute("path").replaceAll("repeatable-add", "tool"); String path = page.createPageArea(pathPrefix, button::click); return page.newInstance(type, jenkins, path); }
Source:
<code>private void removeFormFromAssignments(DatastoreService ds, Long surveyId, boolean doit) { final List<Entity> toBeSaved = new ArrayList<>(); final Query query = new Query("SurveyAssignment").setFilter(new Query.FilterPredicate("surveyIds", FilterOperator.EQUAL, surveyId)); final PreparedQuery pquery = ds.prepare(query); for (Entity ass : pquery.asIterable(FetchOptions.Builder.withChunkSize(500))) { List<Long> forms = (List<Long>) ass.getProperty("surveyIds"); if (forms == null) { System.out.println("Assignment with no forms:" + ass); } else { forms.remove(surveyId); ass.setProperty("surveyIds", forms); toBeSaved.add(ass); } } if (doit) { System.out.println("Removing from " + toBeSaved.size() + " assignments."); <START> ds.put(toBeSaved); <END> } else { System.out.println("Found in " + toBeSaved.size() + " assignments."); } }</code><technical_language>I a batchUpdate() function in utilities</technical_language>

Target:
private void removeFormFromAssignments(DatastoreService ds, Long surveyId, boolean doit) { final List<Entity> toBeSaved = new ArrayList<>(); final Query query = new Query("SurveyAssignment").setFilter(new Query.FilterPredicate("surveyIds", FilterOperator.EQUAL, surveyId)); final PreparedQuery pquery = ds.prepare(query); for (Entity ass : pquery.asIterable(FetchOptions.Builder.withChunkSize(500))) { List<Long> forms = (List<Long>) ass.getProperty("surveyIds"); if (forms == null) { System.out.println("Assignment with no forms:" + ass); } else { forms.remove(surveyId); ass.setProperty("surveyIds", forms); toBeSaved.add(ass); } } if (doit) { System.out.println("Removing from " + toBeSaved.size() + " assignments."); DataUtils.batchSaveEntities(ds,toBeSaved); } else { System.out.println("Found in " + toBeSaved.size() + " assignments."); } }
Source:
<code>private static void assertPartitionsHaveCorrectSize( List<RowsColumnRangeBatchRequest> partitions, int expectedSize) { for (int i = 0; i < partitions.size(); i++) { int actualPartitionSize = RowsColumnRangeBatchRequests.getAllRowsInOrder(partitions.get(i)) .size(); if (i < partitions.size() - 1) { assertThat(actualPartitionSize).isEqualTo(expectedSize); } else { <START> assertThat(actualPartitionSize <= expectedSize).isTrue(); <END> } } }</code><technical_language>isLessThanOrEqualTo</technical_language>

Target:
private static void assertPartitionsHaveCorrectSize( List<RowsColumnRangeBatchRequest> partitions, int expectedSize) { for (int i = 0; i < partitions.size(); i++) { int actualPartitionSize = RowsColumnRangeBatchRequests.getAllRowsInOrder(partitions.get(i)) .size(); if (i < partitions.size() - 1) { assertThat(actualPartitionSize).isEqualTo(expectedSize); } else { assertThat(actualPartitionSize).isLessThanOrEqualTo(expectedSize); } } }