auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public EventProducer(TransportProvider transportProvider, CheckpointProvider checkpointProvider, Properties config, boolean customCheckpointing, Consumer<EventProducer> onUnrecoverableError) { Validate.notNull(transportProvider, "null transport provider"); Validate.notNull(checkpointProvider, "null checkpoint provider"); Validate.notNull(config, "null config"); _checkpointRWLock = new ReentrantReadWriteLock( true); _transportProvider = transportProvider; _checkpointProvider = checkpointProvider; _checkpointPolicy = customCheckpointing ? CheckpointPolicy.CUSTOM : CheckpointPolicy.DATASTREAM; _safeCheckpoints = new ConcurrentHashMap<>(); _onUnrecoverableError = onUnrecoverableError; _checkpointHandler = new CheckpointHandler(config); <START> _producerId = UUID.randomUUID().toString(); <END> _logger = LoggerFactory.getLogger(String.format("%s:%s", MODULE, _producerId)); _logger.info(String.format("Created event producer with customCheckpointing=%s, sendCallback=%s", customCheckpointing, onUnrecoverableError != null)); }</code><technical_language>Do sense a increasing counter a producer Id GUID? need this change if is harder, a thought</technical_language>

Target:
public EventProducer(TransportProvider transportProvider, CheckpointProvider checkpointProvider, Properties config, boolean customCheckpointing, Consumer<EventProducer> onUnrecoverableError) { Validate.notNull(transportProvider, "null transport provider"); Validate.notNull(checkpointProvider, "null checkpoint provider"); Validate.notNull(config, "null config"); _checkpointRWLock = new ReentrantReadWriteLock( true); _transportProvider = transportProvider; _checkpointProvider = checkpointProvider; _checkpointPolicy = customCheckpointing ? CheckpointPolicy.CUSTOM : CheckpointPolicy.DATASTREAM; _safeCheckpoints = new ConcurrentHashMap<>(); _onUnrecoverableError = onUnrecoverableError; _checkpointHandler = new CheckpointHandler(config); _producerId = PRODUCER_ID_SEED.getAndIncrement(); _logger = LoggerFactory.getLogger(String.format("%s:%s", MODULE, _producerId)); _logger.info(String .format("Created event producer with customCheckpointing=%s, sendCallback=%s", customCheckpointing, onUnrecoverableError != null)); }
Source:
<code>private String filterCommentContent(Type type, String comment) { <START> if (type == Type.JSDOC) { <END> for (Pattern p : JSDOC_REPLACEMENTS_WITH_KEEP) { Matcher m = p.matcher(comment); if (m.find() && m.group("keep") != null && m.group("keep").trim().length() > 0) { comment = m.replaceAll("${block}${keep}"); } else { comment = m.replaceAll(""); } } for (Pattern p : JSDOC_REPLACEMENTS_NO_KEEP) { Matcher m = p.matcher(comment); boolean hasAMatch = m.find(); if (hasAMatch) { if (m.group("eol") != null && m.group("eol").trim().length() == 0) { comment = m.replaceAll(""); } else { comment = p.matcher(comment).replaceAll("${block}"); } } } } else { for (Pattern p : COMMENT_REPLACEMENTS) { comment = p.matcher(comment).replaceAll(""); } } return isWhitespaceOnly(comment) ? "" : comment; }</code><technical_language>+1, I more verbose straight Java code, unnecessarily complex regexps</technical_language>

Target:
private String filterCommentContent(Type type, String comment) { if (type == Type.JSDOC) { for (Pattern p : JSDOC_REPLACEMENTS_WITH_KEEP) { Matcher m = p.matcher(comment); if (m.find() && m.group("keep") != null && m.group("keep").trim().length() > 0) { comment = m.replaceAll("${block}${keep}"); } else { comment = m.replaceAll(""); } } for (Pattern p : JSDOC_REPLACEMENTS_NO_KEEP) { Matcher m = p.matcher(comment); if (m.find()) { if (m.group("eol") != null && m.group("eol").trim().length() == 0) { comment = m.replaceAll(""); } else { comment = p.matcher(comment).replaceAll("${block}"); } } } } else { for (Pattern p : COMMENT_REPLACEMENTS) { comment = p.matcher(comment).replaceAll(""); } } return isWhitespaceOnly(comment) ? "" : comment; }
Source:
<code>public DefaultArtifactVersion apply(final Release release) { final Release.Smart rel = new Release.Smart(release); try { final String tag = rel.tag(); return new DefaultArtifactVersion(tag); } catch (final IOException exception) { Logger.error(this, "IOException caused from rel.tag()"); <START> return null; <END> } }</code><technical_language>@JimDeanSpivey brr... wtf? <LINK_0> NULL</technical_language>

Target:
public DefaultArtifactVersion apply(final Release release) { final Release.Smart rel = new Release.Smart(release); try { final String tag = rel.tag(); return new DefaultArtifactVersion(tag); } catch (final IOException exception) { Logger.error(this, "IOException caused from rel.tag()"); throw new RuntimeException(exception); } }
Source:
<code>public void touch(PyObject[] args, String[] kws) { ArgParser ap = JythonUtils.createArgParser(args, kws); Preconditions.checkNotNull(ap); int x = ap.getInt(0); int y = ap.getInt(1); TouchPressType type = TouchPressType.fromIdentifier(ap.getString(2)); <START> if (type == null) type = TouchPressType.DOWN_AND_UP; <END> impl.touch(x, y, type); }</code><technical_language>Yuck, masking typos. I guess needs stay this way, add a warning message 'invalid touch type, default instead'</technical_language>

Target:
public void touch(PyObject[] args, String[] kws) { ArgParser ap = JythonUtils.createArgParser(args, kws); Preconditions.checkNotNull(ap); int x = ap.getInt(0); int y = ap.getInt(1); TouchPressType type = TouchPressType.fromIdentifier(ap.getString(2)); if (type == null) { LOG.warning(String.format("Invalid TouchPressType specified (%s) default used instead", ap.getString(2))); type = TouchPressType.DOWN_AND_UP; } impl.touch(x, y, type); }
Source:
<code>public AsyncStorageModeValidator( @Named("che.infra.kubernetes.pvc.strategy") String pvcStrategy, @Named("che.infra.kubernetes.namespace.allow_user_defined") boolean allowUserDefinedNamespaces, @Nullable @Named("che.infra.kubernetes.namespace.default") String defaultNamespaceName, @Named("che.limits.user.workspaces.run.count") int runtimesPerUser) { this.pvcStrategy = pvcStrategy; this.allowUserDefinedNamespaces = allowUserDefinedNamespaces; this.runtimesPerUser = runtimesPerUser; this.isPvcStrategyNotValid = !COMMON_STRATEGY.equals(pvcStrategy); <START> this.runtimesPerUserLimited = runtimesPerUser > 1; <END> this.isNamespaceStrategyNotValid = isNullOrEmpty(defaultNamespaceName) || !defaultNamespaceName.contains("<username>"); }</code><technical_language>| configured | condition | runtimesPerUserLimited | | ---------------|-------------|----------------------------------| | runtimes unlimited | -1 > 1 | false | | 1 limit for runtimes | 1 > 1 | false | | 2 limit for runtimes | 2 > 1 | true | | 100 limit for runtimes | 100 > 1 | true | ^ is right? If - I suppose singleRuntimeAllowed well, runtimesPerUser == 1 condition</technical_language>

Target:
public AsyncStorageModeValidator( @Named("che.infra.kubernetes.pvc.strategy") String pvcStrategy, @Named("che.infra.kubernetes.namespace.allow_user_defined") boolean allowUserDefinedNamespaces, @Nullable @Named("che.infra.kubernetes.namespace.default") String defaultNamespaceName, @Named("che.limits.user.workspaces.run.count") int runtimesPerUser) { this.pvcStrategy = pvcStrategy; this.allowUserDefinedNamespaces = allowUserDefinedNamespaces; this.runtimesPerUser = runtimesPerUser; this.isPvcStrategyNotValid = !COMMON_STRATEGY.equals(pvcStrategy); this.singleRuntimeAllowed = runtimesPerUser == 1; this.isNamespaceStrategyNotValid = isNullOrEmpty(defaultNamespaceName) || !defaultNamespaceName.contains("<username>"); }
Source:
<code>public void comment(CommentNode node) { <START> String code = node.getCode(); <END> if (!Syntax.isSightlyComment(code) && !isException(code)) { createViolation(node.getStartLinePosition(), RULE_MESSAGE); } }</code><technical_language>delete whitespaces chars here</technical_language>

Target:
public void comment(CommentNode node) { String code = StringUtils.deleteWhitespace(node.getCode()); if (!Syntax.isSightlyComment(code) && !isException(code)) { createViolation(node.getStartLinePosition(), RULE_MESSAGE); } }
Source:
<code>protected AsyncTaskResult<KeyPair> doInBackground(Void... voids) { AsyncTaskResult<KeyPair> retval = null; <START> while(resolving){ <END> if(!paused) { for (PemToKeyPairConverter converter : converters) { KeyPair keyPair = converter.convert(new String(pemFile)); if (keyPair != null) { retval = new AsyncTaskResult<KeyPair>(keyPair); resolving = false; break; } } if (retval == null) { if(this.passwordFinder != null) this.errorMessage = AppConfig.getInstance().getString(R.string.ssh_key_invalid_passphrase); this.paused = true; publishProgress(new AsyncTaskResult<KeyPair>(new IOException("No converter available to parse selected PEM"))); } } } return retval; }</code><technical_language>resolving variable, simply while(true) do</technical_language>

Target:
protected KeyPair doInBackground(Void... voids) { while(true) { if (isCancelled()) return null; if (paused) continue; for (PemToKeyPairConverter converter : converters) { KeyPair keyPair = converter.convert(new String(pemFile)); if (keyPair != null) { paused = false; return keyPair; } } if (this.passwordFinder != null) { this.errorMessage = AppConfig.getInstance().getString(R.string.ssh_key_invalid_passphrase); } paused = true; publishProgress(new IOException("No converter available to parse selected PEM")); } }
Source:
<code>public void setOverlap(Expression overlap) { if(overlap == null) { return; } <START> OverlapBehavior overlapBehavior = OverlapBehavior.valueOf(overlap.toString()); <END> setOverlapBehavior(overlapBehavior); }</code><technical_language>This assumes expression is a literal, specification this evaluate of literals. fix this overlap.evaulate( null, String.class ) - work for literal, env function etc..</technical_language>

Target:
public void setOverlap(Expression overlap) { if(overlap == null) { return; } OverlapBehavior overlapBehavior = OverlapBehavior .valueOf(overlap.evaluate(null, String.class)); setOverlapBehavior(overlapBehavior); }
Source:
<code>public void propertyValidation() { <START> String PROPERTIES_NO_EXECUTABLE_NAME = "applicationName = testApp \n" + "streamName = fakeStream \n" <END> + "AWSCredentialsProvider = DefaultAWSCredentialsProviderChain\n" + "processingLanguage = malbolge"; ClassLoader classLoader = Mockito.mock(ClassLoader.class); Mockito.doReturn(new ByteArrayInputStream(PROPERTIES_NO_EXECUTABLE_NAME.getBytes())).when(classLoader) .getResourceAsStream(FILENAME); MultiLangDaemonConfig config; try { config = new MultiLangDaemonConfig(FILENAME, classLoader, buildMockConfigurator()); Assert.fail("Construction of the config should have failed due to property validation failing."); } catch (IllegalArgumentException e) { } catch (IOException e) { Assert.fail(); } }</code><technical_language>Lowercase variable, i.e. String propertiesNoExecutableName</technical_language>

Target:
public void propertyValidation() { String propertiesNoExecutableName = "applicationName = testApp \n" + "streamName = fakeStream \n" + "AWSCredentialsProvider = DefaultAWSCredentialsProviderChain\n" + "processingLanguage = malbolge"; ClassLoader classLoader = Mockito.mock(ClassLoader.class); Mockito.doReturn(new ByteArrayInputStream(propertiesNoExecutableName.getBytes())).when(classLoader) .getResourceAsStream(FILENAME); MultiLangDaemonConfig config; try { config = new MultiLangDaemonConfig(FILENAME, classLoader, buildMockConfigurator()); Assert.fail("Construction of the config should have failed due to property validation failing."); } catch (IllegalArgumentException e) { } catch (IOException e) { Assert.fail(); } }
Source:
<code>public static <T> Sequence<Result<T>> makeCursorBasedQuery( final StorageAdapter adapter, List<Interval> queryIntervals, Filter filter, VirtualColumns virtualColumns, boolean descending, Granularity granularity, final Function<Cursor, Result<T>> mapFn ) { Preconditions.checkArgument( queryIntervals.size() == 1, "Can only handle a single interval, got[%s]", queryIntervals ); return Sequences.filter( Sequences.map( adapter.makeCursors(filter, queryIntervals.get(0), virtualColumns, granularity, descending, null), new Function<Cursor, Result<T>>() { @Override public Result<T> apply(Cursor input) { <START> log.debug("Running over cursor[%s]", input.getTime()); <END> return mapFn.apply(input); } } ), Predicates.<Result<T>>notNull() ); }</code><technical_language>Strange logging "cursor[input.getTime()]". remove this debugging line</technical_language>

Target:
public static <T> Sequence<Result<T>> makeCursorBasedQuery( final StorageAdapter adapter, List<Interval> queryIntervals, Filter filter, VirtualColumns virtualColumns, boolean descending, Granularity granularity, final Function<Cursor, Result<T>> mapFn ) { Preconditions.checkArgument( queryIntervals.size() == 1, "Can only handle a single interval, got[%s]", queryIntervals ); return Sequences.filter( Sequences.map( adapter.makeCursors(filter, queryIntervals.get(0), virtualColumns, granularity, descending, null), new Function<Cursor, Result<T>>() { @Override public Result<T> apply(Cursor input) { return mapFn.apply(input); } } ), Predicates.<Result<T>>notNull() ); }
Source:
<code>protected boolean registerRemoteInstance() throws IOException, ConfigurationException, PackageException { String username; String password; String project; String description = ""; <START> NuxeoClientInstanceType type = null; <END> if (System.console() != null) { username = LauncherRegisterPromptHelper.promptUsername(); password = LauncherRegisterPromptHelper.promptPassword(); List<ConnectProject> projs = getConnectRegisterationBroker().getAvailableProjects(username, password); project = LauncherRegisterPromptHelper.promptProjectId(projs); type = LauncherRegisterPromptHelper.promptInstanceType(); description = LauncherRegisterPromptHelper.promptDescription(); } else { String[] input = new String(IOUtils.toByteArray(System.in)).split("\n"); if (input.length < 4) { throw new IOException("Wrong number of arguments."); } username = input[0]; password = input[1]; project = input[2]; type = NuxeoClientInstanceType.fromString(input[3]); if (input.length > 3) { description = StringUtils.join(Arrays.copyOfRange(input, 4, input.length), "\n"); } } if (type == null) { type = NuxeoClientInstanceType.DEV; } getConnectRegisterationBroker().registerRemote(username, password, project, type, description); log.info("Your server is correctly registered to: " + username); return true; }</code><technical_language>= null needed I</technical_language>

Target:
public boolean registerRemoteInstance() throws IOException, ConfigurationException, PackageException { if (params.length > 5) { throw new ConfigurationException("Wrong number of arguments."); } String username; if (params.length > 0) { username = params[0]; } else { username = prompt("Username: ", s -> Pattern.matches(REGISTRATION_USERNAME_REGEX, s), "Username cannot be empty."); } char[] password; if (params.length == 3 || params.length == 5) { password = params[params.length - 1].toCharArray(); } else { password = promptPassword(false); } ConnectProject project; List<ConnectProject> projs = getConnectRegistrationBroker().getAvailableProjects(username, password); if (params.length > 1) { String projectName = params[1]; project = getConnectRegistrationBroker().getProjectByName(projectName, projs); if (project == null) { throw new ConfigurationException("Unknown project: " + projectName); } } else { project = promptProject(projs); } NuxeoClientInstanceType type; String description; if (params.length > 3) { type = NuxeoClientInstanceType.fromString(params[2]); if (type == null) { throw new ConfigurationException("Unknown type: " + params[2]); } description = params[3]; } else { type = promptInstanceType(); description = promptDescription(); } getConnectRegistrationBroker().registerRemote(username, password, project.getUuid(), type, description); log.info(String.format("Server registered to %s for project %s\nType: %s\nDescription: %s", username, project, type, description)); return true; }
Source:
<code>public void setForeground(Color color) { checkWidget(); <START> Color disabledFg = getDisplay().getSystemColor(SWT.COLOR_WIDGET_DISABLED_FOREGROUND); <END> boolean foregroundDisabled = false; if (!this.enabled && color == null) { if (foreground != null) { if (foreground.equals(disabledFg)) { return; } else { color = new Color (getDisplay(), disabledFg.getRGBA()); foregroundDisabled = true; } } } customForeground = color != null && !this.enableDisableCall && !foregroundDisabled; foreground = color; super.setForeground(color); resetCache(0, content.getLineCount()); setCaretLocation(); super.redraw(); }</code><technical_language>disabledFg Color variable created needed. i.e. condition is met: if (foreground!= null) {</technical_language>

Target:
public void setForeground(Color color) { checkWidget(); boolean foregroundDisabled = false; if (!this.enabled && color == null) { if (foreground != null) { Color disabledFg = getDisplay().getSystemColor(SWT.COLOR_WIDGET_DISABLED_FOREGROUND); if (foreground.equals(disabledFg)) { return; } else { color = new Color (getDisplay(), disabledFg.getRGBA()); foregroundDisabled = true; } } } customForeground = color != null && !this.insideSetEnableCall && !foregroundDisabled; foreground = color; super.setForeground(color); resetCache(0, content.getLineCount()); setCaretLocation(); super.redraw(); }
Source:
<code>public void visitFunctionCall(FunctionCallTree tree) { String functionName = CheckUtils.getFunctionName(tree); if (CAKE_DEBUG_FUNCTIONS.contains(functionName) && tree.arguments().size() == 2) { ExpressionTree firstArg = tree.arguments().get(0); ExpressionTree secondArg = tree.arguments().get(1); if (firstArg.is(Tree.Kind.REGULAR_STRING_LITERAL) && trimQuotes((LiteralTree) firstArg).equals("debug") <START> && isTrueValue(secondArg)) { <END> context().newIssue(this, tree, MESSAGE); } } super.visitFunctionCall(tree); }</code><technical_language>I this is give some FPs, for example secondArg is a literal</technical_language>

Target:
public void visitFunctionCall(FunctionCallTree tree) { String functionName = CheckUtils.getFunctionName(tree); if (CAKE_DEBUG_FUNCTIONS.contains(functionName) && tree.arguments().size() == 2) { ExpressionTree firstArg = tree.arguments().get(0); ExpressionTree secondArg = tree.arguments().get(1); if (firstArg.is(Tree.Kind.REGULAR_STRING_LITERAL) && trimQuotes((LiteralTree) firstArg).equals("debug") && isTrue(secondArg)) { context().newIssue(this, tree, MESSAGE); } } super.visitFunctionCall(tree); }
Source:
<code>private void checkActivatedAdditionalLayers(int expectedNumber) { session = localSession.getOpenedSession(); DAnalysis analysis = (DAnalysis) session.getSessionResource().getContents().get(0); DDiagram dDiagram = (DDiagram) new DViewQuery(analysis.getOwnedViews().get(0)).getLoadedRepresentations().iterator().next(); List<Layer> additionalLayers = Stream.concat(dDiagram.getActivatedLayers().stream(), dDiagram.getActivatedTransientLayers().stream()) .filter(AdditionalLayer.class::isInstance) <START> .collect(Collectors.toList()); <END> assertEquals("There should be " + expectedNumber + " activated additional layers.", expectedNumber, Iterables.size(additionalLayers)); }</code><technical_language>count() number of items is interresting here. I a bit more efficient</technical_language>

Target:
private void checkActivatedAdditionalLayers(int expectedNumber) { session = localSession.getOpenedSession(); DAnalysis analysis = (DAnalysis) session.getSessionResource().getContents().get(0); DDiagram dDiagram = (DDiagram) new DViewQuery(analysis.getOwnedViews().get(0)).getLoadedRepresentations().iterator().next(); long nbAdditionalLayers = Stream.concat(dDiagram.getActivatedLayers().stream(), dDiagram.getActivatedTransientLayers().stream()) .filter(AdditionalLayer.class::isInstance) .count(); assertEquals("There should be " + expectedNumber + " activated additional layers.", expectedNumber, nbAdditionalLayers); }
Source:
<code>public void detectSingleTextLanguage() { DetectedLanguage primaryLanguage = new DetectedLanguage("English", "en", 0.0); List<DetectedLanguage> expectedLanguageList = Collections.singletonList(primaryLanguage); <START> validateDetectedLanguages( <END> Collections.singletonList(client.detectLanguage("This is a test English Text")), expectedLanguageList); }</code><technical_language>validatePrimaryLanguage below</technical_language>

Target:
public void detectSingleTextLanguage() { validatePrimaryLanguage(new DetectedLanguage("English", "en", 0.0), client.detectLanguage("This is a test English Text")); }
Source:
<code>private void discardTableHint() { if (readIf("INDEX")) { if (readIf(OPEN_PAREN)) { do { readExpression(); } while (readIf(COMMA)); <START> read(CLOSE_PAREN); <END> } else if (readIf(EQUAL)){ readExpression(); } else { throw getSyntaxError(); } } else { readExpression(); } }</code><technical_language>} while (readIfMore(true));</technical_language>

Target:
private void discardTableHint() { if (readIf("INDEX")) { if (readIf(OPEN_PAREN)) { do { readExpression(); } while (readIfMore(true)); } else { read(EQUAL); readExpression(); } } else { readExpression(); } }
Source:
<code>private void writeParaText(HwpStreamReader reader, long datasize, StringBuffer buf) throws IOException { <START> int[] chars = reader.uint16((int) (datasize / 2)); <END> for (int index = 0; index < chars.length; index++) { int ch = chars[index]; if (Arrays.binarySearch(HWP_INLINE_CHARS, ch) >= 0) { if (ch == 9) { buf.append('\t'); } index += 7; } else if (Arrays.binarySearch(HWP_EXTENDED_CHARS, ch) >= 0) { index += 7; } else if (Arrays.binarySearch(HWP_CONTROL_CHARS, ch) >= 0) { buf.append(' '); } else { buf.append((char) ch); } } }</code><technical_language>do a sanity/range check datasize...apologies if done earlier</technical_language>

Target:
private void writeParaText(HwpStreamReader reader, long datasize, StringBuffer buf) throws IOException { int[] chars = reader.uint16((int) (datasize / 2)); for (int index = 0; index < chars.length; index++) { int ch = chars[index]; if (ch < 32) { if (ch == 9) { buf.append('\t'); index += 7; } else { int type = HWP_CHAR_TYPE[ch]; if (I == type) { index += 7; } else if (X == type) { ENDED index += 7; } else if (C == type) { buf.append(' '); } } } else { buf.append((char) ch); } } }
Source:
<code>public void setArtifactId(String newArtifactId) { <START> LabeledText projectLocationLabeledText = new LabeledText("Artifact id:"); <END> projectLocationLabeledText.setText(newArtifactId); }</code><technical_language>@zcervink please some more meaningful local variable name "artifactIdLabeledText" "artifactId"...its in methods end of a file...thank</technical_language>

Target:
public void setArtifactId(String newArtifactId) { LabeledText artifactIdLabeledText = new LabeledText("Artifact id:"); artifactIdLabeledText.setText(newArtifactId); }
Source:
<code>private void logResponse(RedisResponse response, String extraMessage, Throwable cause) { if (logger.isDebugEnabled() && response != null) { ByteBuf buf = response.encode(new UnpooledByteBufAllocator(false)); if (cause == null) { logger.debug("Redis command returned: - {}", Command.getHexEncodedString(buf.array(), buf.readableBytes()), extraMessage); } else { <START> logger.warn("Redis command FAILED to return: - {}", <END> Command.getHexEncodedString(buf.array(), buf.readableBytes()), extraMessage, cause); } } }</code><technical_language>this warning message sense? I thought FAILED "to return"</technical_language>

Target:
private void logResponse(RedisResponse response, String extraMessage, Throwable cause) { if (logger.isDebugEnabled() && response != null) { ByteBuf buf = response.encode(new UnpooledByteBufAllocator(false)); if (cause == null) { logger.debug("Redis command returned: - {}", Command.getHexEncodedString(buf.array(), buf.readableBytes()), extraMessage); } else { logger.debug("Redis command FAILED to return: - {}", Command.getHexEncodedString(buf.array(), buf.readableBytes()), extraMessage, cause); } } }
Source:
<code>private List<TimeGraphEntryModel> buildEntryList(@Nullable IProgressMonitor monitor) { List<TimeGraphEntryModel> entryList = new ArrayList<>(); synchronized (fEntryBuilder) { <START> for (Map<String, EntryModelBuilder> rowMap : fEntryBuilder.rowMap().values()) { for (EntryModelBuilder entry : rowMap.values()) { <END> if (monitor != null && monitor.isCanceled()) { return Collections.emptyList(); } entryList.add(entry.build()); } } } return entryList; }</code><technical_language>do for fEntryBuilder.values() instead</technical_language>

Target:
private List<TimeGraphEntryModel> buildEntryList(@Nullable IProgressMonitor monitor) { List<TimeGraphEntryModel> entryList = new ArrayList<>(); synchronized (fEntryBuilder) { for (EntryModelBuilder entry : fEntryBuilder.values()) { if (monitor != null && monitor.isCanceled()) { return Collections.emptyList(); } entryList.add(entry.build()); } } return entryList; }
Source:
<code>protected void onNewIntent(final Intent intent) { <START> if (intent != null && intent.getAction() != null && intent.getAction().equals("android.intent.action.VIEW")) { <END> bitreserveClient.completeAuthorization(intent.getData(), CLIENT_ID, CLIENT_SECRET, "authorization_code", state).then(new PromiseAction<AuthenticationResponse>() { @Override public void call(AuthenticationResponse authenticationResponse) { Intent intent = new Intent(MainActivity.this, UserActivity.class); intent.putExtra(UserActivity.BUNDLE_EXTRA_BEARER_TOKEN, authenticationResponse.getAccessToken()); startActivity(intent); finish(); } }).fail(new PromiseAction<Exception>() { @Override public void call(Exception e) { Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_LONG).show(); } }); } }</code><technical_language>Change this conditional early return</technical_language>

Target:
protected void onNewIntent(final Intent intent) { if (intent == null || intent.getAction() == null || !intent.getAction().equals("android.intent.action.VIEW")) { return; } bitreserveClient.completeAuthorization(intent.getData(), CLIENT_ID, CLIENT_SECRET, "authorization_code", state).then(new PromiseAction<AuthenticationResponse>() { @Override public void call(AuthenticationResponse authenticationResponse) { Intent intent = new Intent(MainActivity.this, UserActivity.class); intent.putExtra(UserActivity.BUNDLE_EXTRA_BEARER_TOKEN, authenticationResponse.getAccessToken()); startActivity(intent); finish(); } }).fail(new PromiseAction<Exception>() { @Override public void call(Exception e) { Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_LONG).show(); } }); }
Source:
<code>protected IProblemLocation createProblemLocation(ProblemMarkerInfo info) { IProblemLocationFactory factory = CodanRuntime.getInstance().getProblemLocationFactory(); <START> IFile file = (IFile) info.file; <END> return factory.createProblemLocation(file, info.startChar, info.endChar, info.lineNumber); }</code><technical_language>Redundant variable - inline</technical_language>

Target:
protected IProblemLocation createProblemLocation(ProblemMarkerInfo info) { IProblemLocationFactory factory = CodanRuntime.getInstance().getProblemLocationFactory(); return factory.createProblemLocation( (IFile) info.file, info.startChar, info.endChar, info.lineNumber); }
Source:
<code>public static String getDocumentUrl(DocumentModel doc, String viewId) { NotificationService notificationService = NotificationServiceHelper.getNotificationService(); DocumentViewCodecManager codecService = Framework.getService(DocumentViewCodecManager.class); DocumentViewCodec codec = codecService.getCodec(NOTIFICATION_DOCUMENT_ID_CODEC_NAME); boolean isNotificationCodec = codec != null; <START> String result = ""; <END> if (isNotificationCodec) { if (viewId == null) { viewId = "view_documents"; } DocumentView view = new DocumentViewImpl(doc); view.setViewId(viewId); result = codecService.getUrlFromDocumentView(NOTIFICATION_DOCUMENT_ID_CODEC_NAME, new DocumentViewImpl(doc), true, notificationService.getServerUrlPrefix()); } return result; }</code><technical_language>want throw exception instead of returning "" log if notification codec contributed</technical_language>

Target:
public static String getDocumentUrl(DocumentModel doc, String viewId) { NotificationService notificationService = NotificationServiceHelper.getNotificationService(); DocumentViewCodecManager codecService = Framework.getService(DocumentViewCodecManager.class); DocumentViewCodec codec = codecService.getCodec(NotificationEventListener.NOTIFICATION_DOCUMENT_ID_CODEC_NAME); boolean isNotificationCodec = codec != null; String result = ""; if (isNotificationCodec) { DocumentView view; if (viewId == null) { view = new DocumentViewImpl(doc); } else { view = new DocumentViewImpl(new DocumentLocationImpl(doc), viewId); } result = codecService.getUrlFromDocumentView(NotificationEventListener.NOTIFICATION_DOCUMENT_ID_CODEC_NAME, view, true, notificationService.getServerUrlPrefix()); } else { log.warn("No codec was found to notify document url. It is like that no UI is installed."); } return result; }
Source:
<code>public DataObjectRemoveNestedClassCommand( DataModelerContext context, String source, DataObject dataObject, DataModelChangeNotifier notifier, JavaClass nestedClass ) { super( context, source, dataObject, notifier ); <START> this.nestedClass = nestedClass; <END> }</code><technical_language>I nestedClass final nestedClass is null with: this.nestedClass = PortablePreconditions.checkNotNull( "nestedClass", nestedClass );</technical_language>

Target:
public DataObjectRemoveNestedClassCommand( DataModelerContext context, String source, DataObject dataObject, DataModelChangeNotifier notifier, JavaClass nestedClass ) { super( context, source, dataObject, notifier ); this.nestedClass = PortablePreconditions.checkNotNull( "nestedClass", nestedClass ); }
Source:
<code>public Result apply(ValuesNode valuesNode, Captures captures, Context context) { AtomicBoolean anyRewritten = new AtomicBoolean(); ImmutableList.Builder<List<RowExpression>> rows = ImmutableList.builder(); for (List<RowExpression> row : valuesNode.getRows()) { ImmutableList.Builder<RowExpression> newRow = ImmutableList.builder(); for (RowExpression rowExpression : row) { Consumer<Expression> consumeExpression = expression -> { Expression rewritten = rewriter.rewrite(expression, context); if (!expression.equals(rewritten)) { anyRewritten.set(true); } newRow.add(toRaw(rewritten)); }; <START> if (!ifRaw(rowExpression, consumeExpression)) { <END> newRow.add(rowExpression); } } rows.add(newRow.build()); } if (anyRewritten.get()) { return Result.ofPlanNode(new ValuesNode(valuesNode.getId(), valuesNode.getOutputSymbols(), rows.build())); } return Result.empty(); }</code><technical_language>ifRaw. This is hard read. more sense: if (isRaw(rowExpression)) { Expression rewritten = rewriter.rewrite(rowExpression, context); newRow.add(toRaw(rewritten)); if (!rowExpression.equals(rewritten)) { anyRewritten.set(true); } } else { newRow.add(rowExpression); } need AtomicBoolean either</technical_language>

Target:
public Result apply(ValuesNode valuesNode, Captures captures, Context context) { boolean anyRewritten = false; ImmutableList.Builder<List<RowExpression>> rows = ImmutableList.builder(); for (List<RowExpression> row : valuesNode.getRows()) { ImmutableList.Builder<RowExpression> newRow = ImmutableList.builder(); for (RowExpression rowExpression : row) { if (isExpression(rowExpression)) { Expression expression = castToExpression(rowExpression); Expression rewritten = rewriter.rewrite(expression, context); newRow.add(castToRowExpression(rewritten)); if (!expression.equals(rewritten)) { anyRewritten = true; } } else { newRow.add(rowExpression); } } rows.add(newRow.build()); } if (anyRewritten) { return Result.ofPlanNode(new ValuesNode(valuesNode.getId(), valuesNode.getOutputSymbols(), rows.build())); } return Result.empty(); }
Source:
<code><START> public void testActivityStream() throws Exception { <END> TaskTask searchTask = new TaskTask(null, LocalRepositoryConnector.REPOSITORY_URL, "1"); searchTask.setSummary("summary"); searchTask.setTaskKey("1"); TaskTask task1 = new TaskTask(null, LocalRepositoryConnector.REPOSITORY_URL, "2"); task1.setSummary("1: hit"); task1.setTaskKey("2"); task1.setCreationDate(new Date()); TaskTask task2 = new TaskTask(null, LocalRepositoryConnector.REPOSITORY_URL, "3"); task2.setSummary("2: miss"); task2.setTaskKey("3"); task2.setCreationDate(new Date()); IndexReference reference = new IndexReference(); TaskListIndex taskListIndex = reference.index(); taskListIndex.getTaskList().addTask(task1); taskListIndex.getTaskList().addTask(task2); TaskActivityProvider provider = new TaskActivityProvider(); IActivitySession session = new IActivitySession() { public IActivityManager getManger() { return null; } public void fireActivityEvent(ActivityEvent event) { events.add(event); } }; provider.open(session); provider.query(new TaskActivityScope(searchTask), null); ActivityEvent expected = new ActivityEvent(task1.getHandleIdentifier(), task1.getConnectorKind(), task1.getSummary(), task1.getCreationDate(), null); assertEquals(Collections.singletonList(expected), events); reference.dispose(); }</code><technical_language>discarded edits in patch set. Please apply changes top of mine</technical_language>

Target:
public void testActivityStream() throws Exception { TaskTask searchTask = new TaskTask(null, LocalRepositoryConnector.REPOSITORY_URL, "1"); searchTask.setSummary("summary"); searchTask.setTaskKey("1"); TaskActivityProvider provider = new TaskActivityProvider(); IActivitySession session = new IActivitySession() { public IActivityManager getManger() { return null; } public void fireActivityEvent(ActivityEvent event) { events.add(event); } }; provider.open(session); provider.query(new TaskActivityScope(searchTask), null); ActivityEvent expected = new ActivityEvent(task1.getHandleIdentifier(), task1.getConnectorKind(), task1.getSummary(), task1.getCreationDate(), null); assertEquals(Collections.singletonList(expected), events); }
Source:
<code>public static JavaInfo parseWinJavaVersion () { if (preferred == null){ List<JavaInfo> javas = JavaFinder.findJavas(); List<JavaInfo> java32 = new ArrayList<JavaInfo>(); List<JavaInfo> java64 = new ArrayList<JavaInfo>(); Logger.logInfo("The FTB Launcher has found the following Java versions installed:"); for (int i = 0; i < javas.size(); i++) { Logger.logInfo(javas.get(i).toString()); if (preferred == null && javas.get(i) != null) preferred = javas.get(i); if (javas.get(i).is64bits) java64.add(javas.get(i)); else java32.add(javas.get(i)); } if (java64.size() > 0) { for (int i = 0; i < java64.size(); i++) { if (!preferred.is64bits || java64.get(i).compareTo(preferred) == 1) preferred = java64.get(i); } for (int i = 0; i < java64.size(); i++) { if (!preferred.is64bits && java32.get(i).compareTo(preferred) == 1) preferred = java32.get(i); } } if (preferred != null) <START> Logger.logInfo("Preferred: " + preferred.toString()); <END> } if(preferred != null){ return preferred; }else{ Logger.logError("No Java versions found!"); return null; } }</code><technical_language>remove logging if null, "Preferred: " + String.valueOf(preferred)</technical_language>

Target:
public static JavaInfo parseWinJavaVersion () { if (preferred == null){ List<JavaInfo> javas = JavaFinder.findJavas(); List<JavaInfo> java32 = new ArrayList<JavaInfo>(); List<JavaInfo> java64 = new ArrayList<JavaInfo>(); Logger.logInfo("The FTB Launcher has found the following Java versions installed:"); for (int i = 0; i < javas.size(); i++) { Logger.logInfo(javas.get(i).toString()); if (preferred == null && javas.get(i) != null) preferred = javas.get(i); if (javas.get(i).is64bits) java64.add(javas.get(i)); else java32.add(javas.get(i)); } if (java64.size() > 0) { for (int i = 0; i < java64.size(); i++) { if (!preferred.is64bits || java64.get(i).compareTo(preferred) == 1) preferred = java64.get(i); } for (int i = 0; i < java64.size(); i++) { if (!preferred.is64bits && java32.get(i).compareTo(preferred) == 1) preferred = java32.get(i); } } Logger.logInfo("Preferred: " + String.valueOf(preferred); } if(preferred != null){ return preferred; }else{ Logger.logError("No Java versions found!"); return null; } }
Source:
<code>public void run() { out.println("Listing vert.x applications..."); List<String> cmd = new ArrayList<>(); if (!ExecUtils.isWindows()) { try { cmd.add("sh"); cmd.add("-c"); cmd.add("ps ax | grep \"vertx.id=\""); dumpFoundVertxApplications(cmd); } catch (Exception e) { e.printStackTrace(out); } } else { try { cmd.add("WMIC"); cmd.add("PROCESS"); cmd.add("WHERE"); cmd.add("CommandLine like '%java.exe%'"); cmd.add("GET"); cmd.add("CommandLine"); cmd.add("/VALUE"); dumpFoundVertxApplications(cmd); } catch (Exception e) { <START> e.printStackTrace(out); <END> } } }</code><technical_language>System.err</technical_language>

Target:
public void run() { out.println("Listing vert.x applications..."); List<String> cmd = new ArrayList<>(); if (!ExecUtils.isWindows()) { try { cmd.add("sh"); cmd.add("-c"); cmd.add("ps ax | grep \"vertx.id=\""); dumpFoundVertxApplications(cmd); } catch (InterruptedException e) { Thread.currentThread().interrupt(); e.printStackTrace(out); } catch (Exception e) { e.printStackTrace(out); } } else { try { cmd.add("WMIC"); cmd.add("PROCESS"); cmd.add("WHERE"); cmd.add("CommandLine like '%java.exe%'"); cmd.add("GET"); cmd.add("CommandLine"); cmd.add("/VALUE"); dumpFoundVertxApplications(cmd); } catch (InterruptedException e) { Thread.currentThread().interrupt(); e.printStackTrace(out); } catch (Exception e) { e.printStackTrace(out); } } }
Source:
<code><START> public void saveSessionBackupFromResult( final BackupResult backupResult ) throws IOException { <END> final byte[] data = backupResult.getData(); if ( data != null ) { final String key = _sessionIdFormat.createBackupKey( _session.getId() ); _memcached.set( key, toMemcachedExpiration(_session.getMemcachedExpirationTimeToSet()), data ); } else { _log.warn( "No data set for backupResultStatus " + backupResult.getStatus() + " for sessionId " + _session.getIdInternal() + ", skipping backup" + " of non-sticky session in secondary memcached." ); } }</code><technical_language>I here, blocking while (at always)</technical_language>

Target:
public void saveSessionBackupFromResult( final BackupResult backupResult ) { final byte[] data = backupResult.getData(); if ( data != null ) { final String key = _sessionIdFormat.createBackupKey( _session.getId() ); _memcached.set( key, toMemcachedExpiration(_session.getMemcachedExpirationTimeToSet()), data ); } else { _log.warn( "No data set for backupResultStatus " + backupResult.getStatus() + " for sessionId " + _session.getIdInternal() + ", skipping backup" + " of non-sticky session in secondary memcached." ); } }
Source:
<code>public void testIDs() { String message = "message Message {\n" + " required binary string (UTF8) = 6;\n" + " required int32 i=1;\n" + " required binary s2= 3;\n" + " required binary s3 =4;\n" + "}\n"; MessageType parsed = MessageTypeParser.parseMessageType(message); MessageType expected = Types.buildMessage() .required(BINARY).as(OriginalType.UTF8).id(6).named("string") .required(INT32).id(1).named("i") .required(BINARY).id(3).named("s2") .required(BINARY).id(4).named("s3") .named("Message"); Assert.assertEquals(expected, parsed); MessageType reparsed = MessageTypeParser.parseMessageType(parsed.toString()); <START> Assert.assertEquals(expected, reparsed); <END> }</code><technical_language>static import Assert.assertEquals</technical_language>

Target:
public void testIDs() { String message = "message Message {\n" + " required binary string (UTF8) = 6;\n" + " required int32 i=1;\n" + " required binary s2= 3;\n" + " required binary s3 =4;\n" + "}\n"; MessageType parsed = parseMessageType(message); MessageType expected = buildMessage() .required(BINARY).as(OriginalType.UTF8).id(6).named("string") .required(INT32).id(1).named("i") .required(BINARY).id(3).named("s2") .required(BINARY).id(4).named("s3") .named("Message"); assertEquals(expected, parsed); MessageType reparsed = parseMessageType(parsed.toString()); assertEquals(expected, reparsed); }
Source:
<code>public CommandTreeTest() { addSubcommand(new CommandPing()); addSubcommand(new CommandValue()); <START> addSubcommand(new CommandTreeHelp(this)); <END> }</code><technical_language>4 spaces instead of tabs</technical_language>

Target:
public CommandTreeTest() { addSubcommand(new CommandPing(this)); addSubcommand(new CommandValue(this)); addSubcommand(new CommandTreeHelp(this)); }
Source:
<code>public void whenAppLaunched_withAnonymousUser_landingScreenIsDisplayed() { { final MainApplication application = MainApplication.instance(); final EdxEnvironment environment = application.getInjector().getInstance(EdxEnvironment.class); new PrefManager(application, PrefManager.Pref.LOGIN).clearAuth(); environment.getSegment().resetIdentifyUser(); <START> environment.getNotificationDelegate().unsubscribeAll(); <END> } { final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); final Intent launchIntent = instrumentation.getTargetContext().getPackageManager() .getLaunchIntentForPackage(instrumentation.getTargetContext().getPackageName()) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); instrumentation.startActivitySync(launchIntent); instrumentation.waitForIdleSync(); } { onView(withId(R.id.edx_logo)).check(matches(isCompletelyDisplayed())); } }</code><technical_language>This removed. Logout works fine crashing mobile-devi parse config</technical_language>

Target:
public void whenAppLaunched_withAnonymousUser_landingScreenIsDisplayed() { { final MainApplication application = MainApplication.instance(); final EdxEnvironment environment = application.getInjector().getInstance(EdxEnvironment.class); new PrefManager(application, PrefManager.Pref.LOGIN).clearAuth(); environment.getSegment().resetIdentifyUser(); } { final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); final Intent launchIntent = instrumentation.getTargetContext().getPackageManager() .getLaunchIntentForPackage(instrumentation.getTargetContext().getPackageName()) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); instrumentation.startActivitySync(launchIntent); instrumentation.waitForIdleSync(); } { onView(withId(R.id.edx_logo)).check(matches(isCompletelyDisplayed())); } }
Source:
<code>public void shouldResolveZookeeperHostFromCliProperty() { System.setProperty(SERVICE_DISCOVERY_ZK_HOST, ZK_HOST); final TestService testedService = RatelStandaloneFactory.fromZookeeperServer().getServiceProxy( TestService.class, <START> null); <END> then(testedService.hello()).isEqualTo("success"); }</code><technical_language>null better</technical_language>

Target:
public void shouldResolveZookeeperHostFromCliProperty() { System.setProperty(SERVICE_DISCOVERY_ZK_HOST, ZK_HOST); final TestService testedService = RatelStandaloneFactory.fromZookeeperServer().getServiceProxy(TestService.class); then(testedService.hello()).isEqualTo("success"); }
Source:
<code>private static int nextPrime(int previousPrime) { <START> final Integer nextPrime = Match <END> .when(2, (i) -> 3) .orElse(() -> Stream.gen(previousPrime + 2, (v) -> v + 2) .filter((i) -> !isEvenlyDiversableByKnownPrimes(previousPrime, i)) .take(1).head()) .apply(previousPrime); return nextPrime; }</code><technical_language>In general, I return match result. need introduce a variable, name method</technical_language>

Target:
private static int nextPrime(int previousPrime) { return Match .when(2, i -> 3) .orElse(() -> Stream.gen(previousPrime + 2, v -> v + 2) .filter(i -> !isEvenlyDiversableByKnownPrimes(previousPrime, i)) .take(1).head()) .apply(previousPrime); }
Source:
<code>protected List<AppWidgetProviderInfo> getInstalledProvidersForProfile(UserHandle profile) { <START> return new ArrayList<>(installedProvidersForProfile.get(profile)); <END> }</code><technical_language>nit: change this ImmutableList? I return needs mutable. change getInstalledProviders return ImmutableList</technical_language>

Target:
protected List<AppWidgetProviderInfo> getInstalledProvidersForProfile(UserHandle profile) { return ImmutableList.copyOf(installedProvidersForProfile.get(profile)); }
Source:
<code>public void testToFile() throws MalformedURLException { String filename = "test.txt"; <START> String unixUrl = "file:/program files/eclipse/"; <END> String expectedUnixFolder = "/program files/eclipse"; String expectedUnixFile = expectedUnixFolder + "/" + filename; assertEquals(new File(expectedUnixFolder), EquinoxManipulatorImpl.toFile(new URL(unixUrl))); assertEquals(new File(expectedUnixFile), EquinoxManipulatorImpl.toFile(new URL(unixUrl + filename))); String windowsUrl = "file:/C:/Program Files/eclipse/"; String expectedWindowsFolder = "C:\\Program Files\\eclipse"; String expectedWindowsFile = expectedWindowsFolder + "\\" + filename; assertEquals(new File(expectedWindowsFolder), EquinoxManipulatorImpl.toFile(new URL(windowsUrl))); assertEquals(new File(expectedWindowsFile), EquinoxManipulatorImpl.toFile(new URL(windowsUrl + filename))); String uncUrl = "file://server/share/folder/"; String expectedUncFolder = " String expectedUncFile = expectedUncFolder + "/" + filename; assertEquals(new File(expectedUncFolder), EquinoxManipulatorImpl.toFile(new URL(uncUrl))); assertEquals(new File(expectedUncFile), EquinoxManipulatorImpl.toFile(new URL(uncUrl + filename))); }</code><technical_language>I suggest %20 instead of space in URIs new URI("...") throws exceptions for spaces. Calling toURI this URL throws exception. In other words, good for this test tests %20 is properly decoded a space</technical_language>

Target:
public void testToFile() throws MalformedURLException { String filename = "test.txt"; String unixUrl = "file:/program files/eclipse/"; String expectedUnixFolder = "/program files/eclipse"; String expectedUnixFile = expectedUnixFolder + "/" + filename; assertEquals(new File(expectedUnixFolder), EquinoxManipulatorImpl.toFile(new URL(unixUrl))); assertEquals(new File(expectedUnixFile), EquinoxManipulatorImpl.toFile(new URL(unixUrl + filename))); String windowsUrl = "file:/C:/Program Files/eclipse/"; String expectedWindowsFolder = "C:\\Program Files\\eclipse"; String expectedWindowsFile = expectedWindowsFolder + "\\" + filename; assertEquals(new File(expectedWindowsFolder), EquinoxManipulatorImpl.toFile(new URL(windowsUrl))); assertEquals(new File(expectedWindowsFile), EquinoxManipulatorImpl.toFile(new URL(windowsUrl + filename))); String uncUrl = "file://server/share/folder/"; String expectedUncFolder = " String expectedUncFile = expectedUncFolder + "/" + filename; assertEquals(new File(expectedUncFolder), EquinoxManipulatorImpl.toFile(new URL(uncUrl))); assertEquals(new File(expectedUncFile), EquinoxManipulatorImpl.toFile(new URL(uncUrl + filename))); String notFileUrl = "<LINK_0>"; String expectedOtherFolder = "/path/to/folder"; String expectedOtherFile = expectedOtherFolder + "/" + filename; assertEquals(new File(expectedOtherFolder), EquinoxManipulatorImpl.toFile(new URL(notFileUrl))); assertEquals(new File(expectedOtherFile), EquinoxManipulatorImpl.toFile(new URL(notFileUrl + filename))); }
Source:
<code>public HoeUpgrade() { <START> super(UPGRADE_NAME, "enderio.darksteel.upgrade.hoe", new ItemStack(Items.DIAMOND_HOE), DarkSteelConfig.darkSteelHoeCost.get()); <END> }</code><technical_language>super(String, String, ItemStack, IValue<Integer>) here, super(String, String, ItemStack, int)</technical_language>

Target:
public HoeUpgrade() { super(UPGRADE_NAME, "enderio.darksteel.upgrade.hoe", new ItemStack(Items.DIAMOND_HOE), DarkSteelConfig.darkSteelHoeCost); }