auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected ExtendedComponent convertDocToExtendedComponent(IBranchPath branchPath, Document doc) { final String iconId = doc.get(Mappings.iconId().fieldName()); final List<Integer> types = Mappings.type().getValues(doc); final String id; if (types.isEmpty()) { <START> id = Long.toString(SnomedMappings.memberReferencedComponentId().getValue(doc)); <END> } else { id = Long.toString(SnomedMappings.id().getValue(doc)); } final short terminologyComponentId; if (types.size() == 1) { terminologyComponentId = types.get(0).shortValue(); } else { terminologyComponentId = SnomedTerminologyComponentConstants.CONCEPT_NUMBER; } final String terminologyComponentIdAsString = CoreTerminologyBroker.getInstance().getTerminologyComponentId(terminologyComponentId); final IComponentNameProvider nameProvider = CoreTerminologyBroker.getInstance().getNameProviderFactory(terminologyComponentIdAsString).getNameProvider(); final String label = nameProvider.getComponentLabel(branchPath, id); return new ExtendedComponentImpl(id, label, iconId, terminologyComponentId); }</code><technical_language>This needs reference set member's UUID..</technical_language>

Target:
protected ExtendedComponent convertDocToExtendedComponent(IBranchPath branchPath, Document doc) { final String iconId = doc.get(Mappings.iconId().fieldName()); final List<Integer> types = Mappings.type().getValues(doc); final String id; if (types.isEmpty()) { id = Long.toString(SnomedMappings.memberReferencedComponentId().getValue(doc)); } else { id = Long.toString(SnomedMappings.id().getValue(doc)); } final short terminologyComponentId; if (types.isEmpty()) { terminologyComponentId = SnomedMappings.memberReferencedComponentType().getShortValue(doc); } else if (types.size() == 1) { terminologyComponentId = types.get(0).shortValue(); } else { terminologyComponentId = SnomedTerminologyComponentConstants.CONCEPT_NUMBER; } final String terminologyComponentIdAsString = CoreTerminologyBroker.getInstance().getTerminologyComponentId(terminologyComponentId); final IComponentNameProvider nameProvider = CoreTerminologyBroker.getInstance().getNameProviderFactory(terminologyComponentIdAsString).getNameProvider(); final String label = nameProvider.getComponentLabel(branchPath, id); if (types.isEmpty()) { return new ExtendedComponentImpl(SnomedMappings.memberUuid().getValue(doc), label, iconId, SnomedTerminologyComponentConstants.REFSET_MEMBER_NUMBER); } else { return new ExtendedComponentImpl(id, label, iconId, terminologyComponentId); } }
Source:
<code>protected Map<String, Object> extractCustomAttributes(String xml) { final Document document = XmlUtils.newDocument(xml); final HashMap<String, Object> attributes = new HashMap<String, Object>(); NodeList attributeList = document.getElementsByTagName("cas:attribute"); for (int i = 0; i < attributeList.getLength(); i++) { final Node attribute = attributeList.item(i); <START> if (attribute.getAttributes().getLength() > 0) { <END> attributes.put(attribute.getAttributes().getNamedItem("name").getNodeValue(), attribute.getAttributes().getNamedItem("value").getNodeValue()); } else { attributes.put(attribute.getLocalName(), attribute.getNodeValue()); } } return attributes; }</code><technical_language>want extract attribute.getAttributes() something, repeat call a more times</technical_language>

Target:
protected Map<String, Object> extractCustomAttributes(String xml) { final Document document = XmlUtils.newDocument(xml); final NodeList attributeList = document.getElementsByTagName("cas:attribute"); if (attributeList.getLength() == 0) { return super.extractCustomAttributes(xml); } final HashMap<String, Object> attributes = new HashMap<String, Object>(); for (int i = 0; i < attributeList.getLength(); i++) { final Node casAttributeNode = attributeList.item(i); final NamedNodeMap nodeAttributes = casAttributeNode.getAttributes(); final String name = nodeAttributes.getNamedItem("name").getNodeValue(); final String value = nodeAttributes.getNamedItem("value").getTextContent(); final Object mapValue = attributes.get(name); if (mapValue != null) { if (mapValue instanceof List) { ((List) mapValue).add(value); } else { final LinkedList<Object> list = new LinkedList<Object>(); list.add(mapValue); list.add(value); attributes.put(name, list); } } else { attributes.put(name, value); } } return attributes; }
Source:
<code>public void testAccuracyStrategyTypeParamsSetttings() throws ResolverConfigurationValidationException { expectedException.expect(ResolverConfigurationValidationException.class); <START> expectedException.expectMessage( "'Audit' parameter value in 'Resolver configuration.policy.strategy params' settings " <END> + "must be bigger than 'Resolver configuration.policy.strategy.strategy params.block'."); final Policy policy = new Policy(); final Strategy strategy = new Strategy(); strategy.setStrategyType(StrategyType.accuracy); final StrategyParams strategyParams = new StrategyParams(); strategyParams.setAudit(50); strategyParams.setBlock(30); strategy.setStrategyParams(strategyParams); policy.setStrategy(strategy); resolverConfiguration.setPolicies(Collections.singletonList(policy)); validator.accuracyStrategyTypeParamsSetttings(resolverConfiguration); }</code><technical_language>@hugeox text of expected exception different? i a fix in older abandoned branch. copy-paste apply patch: <LINK_0></technical_language>

Target:
public void testAccuracyStrategyTypeParamsSetttings() throws ResolverConfigurationValidationException { expectedException.expect(ResolverConfigurationValidationException.class); expectedException.expectMessage("'Audit' parameter value in 'Resolver configuration.policy.strategy params' settings " + "must not be bigger than 'Resolver configuration.policy.strategy.strategy params.block' but " + "for the special case where either 'Audit' or 'Block' are 0. None of the parameters can be outside <0, 100>."); final Policy policy = new Policy(); final Strategy strategy = new Strategy(); strategy.setStrategyType(StrategyType.accuracy); final StrategyParams strategyParams = new StrategyParams(); strategyParams.setAudit(50); strategyParams.setBlock(30); strategy.setStrategyParams(strategyParams); policy.setStrategy(strategy); resolverConfiguration.setPolicies(Collections.singletonList(policy)); validator.accuracyStrategyTypeParamsSetttings(resolverConfiguration); }
Source:
<code>private List<ExtensionComponent<T>> ensureLoaded() { if(extensions!=null) return extensions; <START> if (jenkins != null && jenkins.getInitLevel().compareTo(InitMilestone.PLUGINS_PREPARED) < 0) <END> return legacyInstances; synchronized (getLoadLock()) { if(extensions==null) { List<ExtensionComponent<T>> r = load(); r.addAll(legacyInstances); extensions = sort(r); } return extensions; } }</code><technical_language>suggestion if (jenkins == null || jenkins.getInitLevel().compareTo(InitMilestone.PLUGINS_PREPARED) < 0)</technical_language>

Target:
private List<ExtensionComponent<T>> ensureLoaded() { if(extensions!=null) return extensions; if (jenkins == null || jenkins.getInitLevel().compareTo(InitMilestone.PLUGINS_PREPARED) < 0) return legacyInstances; synchronized (getLoadLock()) { if(extensions==null) { List<ExtensionComponent<T>> r = load(); r.addAll(legacyInstances); extensions = sort(r); } return extensions; } }
Source:
<code>public void onAdd(SolApplication solApplication) { <START> continueControl.setEnabled(SaveManager.resourceExists("prevShip.ini")); <END> }</code><technical_language>I request bring "hasPrevShip" method, if a wrrapper for resourceExists. NewGameScreen need name of save file</technical_language>

Target:
public void onAdd(SolApplication solApplication) { continueControl.setEnabled(SaveManager.hasPrevShip("prevShip.ini")); }
Source:
<code>public void createExternalDataset(@Nullable Schema schema) { DatasetProperties datasetProperties; if (schema == null) { datasetProperties = DatasetProperties.EMPTY; } else { datasetProperties = DatasetProperties.of(Collections.singletonMap(DatasetProperties.SCHEMA, schema.toString())); } try { if (!context.datasetExists(dataset)) { context.createDataset(dataset, Constants.EXTERNAL_DATASET_TYPE, datasetProperties); } else { <START> LOG.info("Failed to create dataset with schema {}. A dataset with the given name already exists.", <END> dataset, schema); } } catch (DatasetManagementException e) { throw new RuntimeException(String.format("Failed to create dataset %s with schema %s.", dataset, schema), e); } }</code><technical_language>this is a failure logged one. this needs logged all, happen a pipeline is run more once</technical_language>

Target:
public void createExternalDataset(@Nullable Schema schema) { DatasetProperties datasetProperties; if (schema == null) { datasetProperties = DatasetProperties.EMPTY; } else { datasetProperties = DatasetProperties.of(Collections.singletonMap(DatasetProperties.SCHEMA, schema.toString())); } try { if (!context.datasetExists(dataset)) { context.createDataset(dataset, Constants.EXTERNAL_DATASET_TYPE, datasetProperties); } } catch (InstanceConflictException e) { return; } catch (DatasetManagementException e) { throw new RuntimeException(String.format("Failed to create dataset %s with schema %s.", dataset, schema), e); } }
Source:
<code>public CacheResource parse(ConfigResource parent, IdString id) throws AuthException, ResourceNotFoundException { final CurrentUser user = self.get(); if (user instanceof AnonymousUser) { throw new AuthException("Authentication required"); } else if(!(user.isIdentifiedUser())) { throw new ResourceNotFoundException(); } if (!user.getCapabilities().canViewCaches()) { throw new AuthException("not allowed to view caches"); } String cacheName = id.get(); String pluginName = "gerrit"; int i = <START> cacheName.indexOf('-'); <END> if (i != -1) { pluginName = cacheName.substring(0, i); cacheName = cacheName.length() > i + 1 ? cacheName.substring(i + 1) : ""; } Provider<Cache<?, ?>> cacheProvider = cacheMap.byPlugin(pluginName).get(cacheName); if (cacheProvider == null) { throw new ResourceNotFoundException(id); } return new CacheResource(pluginName, cacheName, cacheProvider); }</code><technical_language>lastIndexOf('-') instead? Consider a plugin "-" in name, for example, rename "quota" plugin "file-system-quota-plugin". In this case cache name be: [...] "file-system-quota-plugin-repo_size": { "type": "DISK", "entries": { "space": " 0.00k" }, "hit_ratio": } [...]</technical_language>

Target:
public CacheResource parse(ConfigResource parent, IdString id) throws AuthException, ResourceNotFoundException { final CurrentUser user = self.get(); if (user instanceof AnonymousUser) { throw new AuthException("Authentication required"); } else if(!(user.isIdentifiedUser())) { throw new ResourceNotFoundException(); } if (!user.getCapabilities().canViewCaches()) { throw new AuthException("not allowed to view caches"); } String cacheName = id.get(); String pluginName = "gerrit"; int i = cacheName.lastIndexOf('-'); if (i != -1) { pluginName = cacheName.substring(0, i); cacheName = cacheName.length() > i + 1 ? cacheName.substring(i + 1) : ""; } Provider<Cache<?, ?>> cacheProvider = cacheMap.byPlugin(pluginName).get(cacheName); if (cacheProvider == null) { throw new ResourceNotFoundException(id); } return new CacheResource(pluginName, cacheName, cacheProvider); }
Source:
<code>private ContextHandler servletContextHandler(ManagementContext managementContext) { ResourceConfig config = new DefaultResourceConfig(); for (Object r: BrooklynRestApi.getAllResources()) config.getSingletons().add(r); <START> config.getSingletons().add(new ShutdownRequestListenerProvider(new TestShutdownRequestListener())); <END> ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setAttribute(BrooklynServiceAttributes.BROOKLYN_MANAGEMENT_CONTEXT, managementContext); ServletHolder servletHolder = new ServletHolder(new ServletContainer(config)); context.addServlet(servletHolder, "/*"); context.setContextPath("/"); installBrooklynFilters(context, this.filters); return context; }</code><technical_language>this new TestShutdownRequestListener related shutdownListener field? field</technical_language>

Target:
private ContextHandler servletContextHandler(ManagementContext managementContext) { ResourceConfig config = new DefaultResourceConfig(); for (Object r: BrooklynRestApi.getAllResources()) config.getSingletons().add(r); config.getSingletons().add(new ShutdownHandlerProvider(shutdownListener)); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setAttribute(BrooklynServiceAttributes.BROOKLYN_MANAGEMENT_CONTEXT, managementContext); ServletHolder servletHolder = new ServletHolder(new ServletContainer(config)); context.addServlet(servletHolder, "/*"); context.setContextPath("/"); installBrooklynFilters(context, this.filters); return context; }
Source:
<code>protected AbstractEndpoint extractEndpoint(Binding<MessageChannel> binding) { <START> Assert.isInstanceOf(DefaultBinding.class, binding, "Binding not of expected type, found " + binding.getClass().getName() + " instead"); <END> DirectFieldAccessor accessor = new DirectFieldAccessor(binding); return (AbstractEndpoint) accessor.getPropertyValue("endpoint"); }</code><technical_language>this brittle in future; fine for</technical_language>

Target:
protected AbstractEndpoint extractEndpoint(Binding<MessageChannel> binding) { DirectFieldAccessor accessor = new DirectFieldAccessor(binding); return (AbstractEndpoint) accessor.getPropertyValue("endpoint"); }
Source:
<code>protected void drawGui(ResourceLocation rl) { if(rl != null) { <START> System.out.println(width+" "+height+" "+xSize+" "+ySize); <END> bindTexture(rl); guiLeft = (width - xSize) / 2; guiTop = (height - ySize) / 2; if(guiTab == 0) { drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize - PlayerInventory.invYSize); } else if(guiTab == 1) { drawTexturedModalRect(guiLeft, guiTop, 0, 86, xSize, ySize - PlayerInventory.invYSize); } } if(drawInventory) PlayerInventory.drawInventory(this, width, height, ySize - PlayerInventory.invYSize); }</code><technical_language>Please removing console spam submitting PRs</technical_language>

Target:
protected void drawGui(ResourceLocation rl) { if(rl != null) { bindTexture(rl); guiLeft = (width - xSize) / 2; guiTop = (height - ySize) / 2; if(guiTab == 0) { drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize - PlayerInventory.invYSize); } else if(guiTab == 1) { drawTexturedModalRect(guiLeft, guiTop, 0, 86, xSize, ySize - PlayerInventory.invYSize); } } if(drawInventory) PlayerInventory.drawInventory(this, width, height, ySize - PlayerInventory.invYSize); }
Source:
<code>private HashMap<String, Integer> calculationForProgress(List<?> tasks) { HashMap<String, Integer> results = new HashMap<>(); int open = 0; int inProcessing = 0; int closed = 0; int locked = 0; for (Object task : tasks) { if (task instanceof Task) { if (((Task)task).getProcessingStatusEnum() == TaskStatus.DONE) { closed++; } else if (((Task)task).getProcessingStatusEnum() == TaskStatus.OPEN) { open++; } else if (((Task)task).getProcessingStatusEnum() == TaskStatus.LOCKED) { locked++; } else { inProcessing++; } } else if (task instanceof TaskDTO) { if (((TaskDTO)task).getProcessingStatus() == TaskStatus.DONE) { closed++; } else if (((TaskDTO)task).getProcessingStatus() == TaskStatus.OPEN) { open++; } else if (((TaskDTO)task).getProcessingStatus() == TaskStatus.LOCKED) { locked++; } else { inProcessing++; } } else { <START> throw new InvalidParameterException("List should contain tasks as Bean or DTO!"); <END> } } results.put("closed", closed); results.put("inProcessing", inProcessing); results.put("open", open); results.put("locked", locked); if ((open + inProcessing + closed + locked) == 0) { results.put("locked", 1); } return results; }</code><technical_language>IllegalArgumentException a proper exception instead of including a exception java.security package</technical_language>

Target:
private HashMap<String, Integer> calculationForProgress(List<?> tasks) { HashMap<String, Integer> results = new HashMap<>(); int open = 0; int inProcessing = 0; int closed = 0; int locked = 0; for (Object task : tasks) { if (task instanceof Task) { if (((Task)task).getProcessingStatusEnum() == TaskStatus.DONE) { closed++; } else if (((Task)task).getProcessingStatusEnum() == TaskStatus.OPEN) { open++; } else if (((Task)task).getProcessingStatusEnum() == TaskStatus.LOCKED) { locked++; } else { inProcessing++; } } else if (task instanceof TaskDTO) { if (((TaskDTO)task).getProcessingStatus() == TaskStatus.DONE) { closed++; } else if (((TaskDTO)task).getProcessingStatus() == TaskStatus.OPEN) { open++; } else if (((TaskDTO)task).getProcessingStatus() == TaskStatus.LOCKED) { locked++; } else { inProcessing++; } } else { throw new IllegalArgumentException("List should contain tasks as Bean or DTO!"); } } results.put("closed", closed); results.put("inProcessing", inProcessing); results.put("open", open); results.put("locked", locked); if ((open + inProcessing + closed + locked) == 0) { results.put("locked", 1); } return results; }
Source:
<code>public SamzaResourceRequest(int numCores, int memoryMB, String preferredHost, String processorId) { <START> this(numCores, memoryMB, preferredHost, processorId, Instant.now(), null); <END> }</code><technical_language>emptyset instead of null? however, empty set/null mean? request ignore fault domain notions if null break behavior if empty set</technical_language>

Target:
public SamzaResourceRequest(int numCores, int memoryMB, String preferredHost, String processorId) { this(numCores, memoryMB, preferredHost, processorId, Instant.now(), ImmutableSet.of()); }
Source:
<code>public void bridgeShouldInitialize() { <START> waitForAssert(() -> assertEquals(ThingStatus.ONLINE, bridge.getStatus())); <END> }</code><technical_language>running a plain Java unit test I assume waitForAssert is necessary. designed work in JavaOSGiTest, wait for async events</technical_language>

Target:
public void bridgeShouldInitialize() { assertEquals(ThingStatus.ONLINE, bridge.getStatus()); }
Source:
<code>public void addEntry(String resourceTag, String stateUnitKey, String state, InstanceConfig config) { if (!stateInfoMap.containsKey(state)) { <START> Comparator<InstanceConfig> comparator = new Comparator<InstanceConfig>() { <END> @Override public int compare(InstanceConfig o1, InstanceConfig o2) { if (o1 == o2) { return 0; } if (o1 == null) { return -1; } if (o2 == null) { return 1; } int compareTo = o1.getHostName().compareTo(o2.getHostName()); if (compareTo == 0) { return o1.getPort().compareTo(o2.getPort()); } else { return compareTo; } } }; stateInfoMap.put(state, new TreeSet<InstanceConfig>(comparator)); } Set<InstanceConfig> set = stateInfoMap.get(state); set.add(config); if (!partitionInfoMap.containsKey(stateUnitKey)) { partitionInfoMap.put(stateUnitKey, new PartitionInfo()); } PartitionInfo stateUnitKeyInfo = partitionInfoMap.get(stateUnitKey); stateUnitKeyInfo.addEntry(state, config); if (!tagResourceInfoMap.containsKey(resourceTag)) { tagResourceInfoMap.put(resourceTag, new ResourceInfo()); } ResourceInfo resourceInfo = tagResourceInfoMap.get(resourceTag); resourceInfo.addEntry(stateUnitKey, state, config); }</code><technical_language>Declare comparator identical in ResourceInfo</technical_language>

Target:
public void addEntry(String resourceTag, String stateUnitKey, String state, InstanceConfig config) { aggregatedResourceInfo.addEntry(stateUnitKey, state, config); if (!tagToResourceMap.containsKey(resourceTag)) { tagToResourceMap.put(resourceTag, new ResourceInfo()); } ResourceInfo resourceInfo = tagToResourceMap.get(resourceTag); resourceInfo.addEntry(stateUnitKey, state, config); }
Source:
<code>public TracerProvider(Iterable<Tracer> tracers) { <START> this.tracers = tracers; <END> }</code><technical_language>suggestion this.tracers = Objects.requireNotNull(tracers, "'tracers' null.");</technical_language>

Target:
public TracerProvider(Iterable<Tracer> tracers) { Objects.requireNonNull(tracers, "'tracers' cannot be null."); tracers.forEach(e -> this.tracers.add(e)); }
Source:
<code>public <T extends Node> void walk(Class<T> nodeType, Consumer<T> consumer) { new TreeVisitor() { @Override public void process(Node node) { if (nodeType.isInstance(node)) { consumer.accept(nodeType.cast(node)); } } <START> }.visitPreOrder(this); <END> }</code><technical_language>order (preOrder/postOrder) a flag</technical_language>

Target:
public <T extends Node> void walk(Class<T> nodeType, Consumer<T> consumer) { walk(TreeTraversal.PREORDER, node -> { if (nodeType.isAssignableFrom(node.getClass())) { consumer.accept(nodeType.cast(node)); } }); }
Source:
<code>private void handleChange(Collection collection, Vertex vertex) { GraphTraversal<Vertex, Vertex> traversal = graphWrapper.getGraph().traversal().V(vertex.id()); String docCaption = traversal.asAdmin().clone() .union(collection.getDisplayName().traversalJson()) .next() .getOrElse(jsn("")) .asText(); if (collection.getEntityTypeName().equals("wwdocument")) { Collection wwpersons = collection.getVre().getCollectionForCollectionName("wwpersons").get(); List<String> authors = traversal.out("isCreatedBy") .union(wwpersons.getDisplayName().traversalJson()).map(x -> x.get().getOrElse(jsn("")).asText()) .toList(); Collections.sort(authors); String authorCaption = String.join( "; ", authors ); docCaption = authorCaption + " " + docCaption; <START> } <END> indexHandler.addToQuickSearchIndex(collection, docCaption, vertex); }</code><technical_language>remove vertex</technical_language>

Target:
private void handleChange(Collection collection, Vertex vertex) { GraphTraversal<Vertex, Vertex> traversal = graphWrapper.getGraph().traversal().V(vertex.id()); String docCaption = traversal.asAdmin().clone() .union(collection.getDisplayName().traversalJson()) .next() .getOrElse(jsn("")) .asText(); if (collection.getEntityTypeName().equals("wwdocument")) { Collection wwpersons = collection.getVre().getCollectionForCollectionName("wwpersons").get(); List<String> authors = traversal.out("isCreatedBy") .union(wwpersons.getDisplayName().traversalJson()) .map(x -> x.get().getOrElse(jsn("")).asText()) .toList(); Collections.sort(authors); String authorCaption = String.join( "; ", authors ); docCaption = authorCaption + " " + docCaption; } indexHandler.insertIntoQuickSearchIndex(collection, docCaption, vertex); }
Source:
<code>public <T extends MetaParam> void replace(Class<T> type, Function<T, T> f) { int hole = -1; for (int i = 0; i < metas.length; ++i) { MetaParam<?> m = metas[i]; if (m == null) { hole = i; <START> } else if (m != null && m.getClass().isAssignableFrom(type)) { <END> T newMeta = f.apply((T) m); assert newMeta == null || type.isInstance(newMeta); if (newMeta == null) { --length; } metas[i] = newMeta; assert checkLength(); return; } } T newMeta = f.apply(null); if (newMeta == null) { assert checkLength(); return; } else if (hole < 0) { ++length; MetaParam<?>[] newMetas = Arrays.copyOf(metas, metas.length + 1); newMetas[newMetas.length - 1] = newMeta; metas = newMetas; } else { ++length; metas[hole] = newMeta; } assert checkLength(); }</code><technical_language>minor: need check for null</technical_language>

Target:
public <T extends MetaParam> void replace(Class<T> type, Function<T, T> f) { int hole = -1; for (int i = 0; i < metas.length; ++i) { MetaParam<?> m = metas[i]; if (m == null) { hole = i; } else if (m.getClass().isAssignableFrom(type)) { T newMeta = f.apply((T) m); assert newMeta == null || type.isInstance(newMeta); if (newMeta == null) { --length; } metas[i] = newMeta; assert checkLength(); return; } } T newMeta = f.apply(null); if (newMeta == null) { assert checkLength(); return; } else if (hole < 0) { ++length; MetaParam<?>[] newMetas = Arrays.copyOf(metas, metas.length + 1); newMetas[newMetas.length - 1] = newMeta; metas = newMetas; } else { ++length; metas[hole] = newMeta; } assert checkLength(); }
Source:
<code>public final void initialize(IProvisioningAgent agent, IProcessingStepDescriptor descriptor, IArtifactDescriptor context) { super.initialize(agent, descriptor, context); <START> basicInitialize(descriptor); <END> String data = descriptor.getData(); if (IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".").concat(algorithmId).equals(data)) expectedChecksum = ChecksumHelper.getChecksums(context, IArtifactDescriptor.DOWNLOAD_CHECKSUM).get(algorithmId); else if (IArtifactDescriptor.ARTIFACT_CHECKSUM.concat(".").concat(algorithmId).equals(data)) expectedChecksum = ChecksumHelper.getChecksums(context, IArtifactDescriptor.ARTIFACT_CHECKSUM).get(algorithmId); else expectedChecksum = data; if (ofNullable(expectedChecksum).orElse("").isEmpty()) { int code = (descriptor == null) ? IStatus.ERROR : descriptor.isRequired() ? IStatus.ERROR : IStatus.INFO; setStatus(new Status(code, Activator.ID, NLS.bind(Messages.Error_invalid_checksum, algorithmName, expectedChecksum))); } }</code><technical_language>return is status != OK</technical_language>

Target:
public final void initialize(IProvisioningAgent agent, IProcessingStepDescriptor descriptor, IArtifactDescriptor context) { super.initialize(agent, descriptor, context); basicInitialize(descriptor); if (!getStatus().isOK()) { return; } String data = descriptor.getData(); if (IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".").concat(algorithmId).equals(data)) expectedChecksum = ChecksumHelper.getChecksums(context, IArtifactDescriptor.DOWNLOAD_CHECKSUM).get(algorithmId); else if (IArtifactDescriptor.ARTIFACT_CHECKSUM.concat(".").concat(algorithmId).equals(data)) expectedChecksum = ChecksumHelper.getChecksums(context, IArtifactDescriptor.ARTIFACT_CHECKSUM).get(algorithmId); else expectedChecksum = data; if (ofNullable(expectedChecksum).orElse("").isEmpty()) { int code = buildErrorCode(descriptor); setStatus(new Status(code, Activator.ID, NLS.bind(Messages.Error_invalid_checksum, algorithmName, expectedChecksum))); } }
Source:
<code>public int hashCode() { int result = diskImage.hashCode(); <START> result = 31 * result + vms.hashCode(); <END> return result; }</code><technical_language>I this re-generated added id</technical_language>

Target:
public int hashCode() { return Objects.hash(diskImage, vms, id); }
Source:
<code>public void package_relative_import() { Map<String, Symbol> osSymbols = TypeShed.symbolsForModule("os").stream().collect(Collectors.toMap(Symbol::name, Function.identity(), AmbiguousSymbolImpl::mergeTwoSymbols)); Symbol sysSymbol = osSymbols.get("sys"); assertThat(sysSymbol.kind()).isEqualTo(Kind.AMBIGUOUS); Symbol timesResult = osSymbols.get("times_result"); <START> assertThat(timesResult.kind()).isEqualTo(Kind.CLASS); <END> Map<String, Symbol> requestsSymbols = TypeShed.symbolsForModule("requests").stream().collect(Collectors.toMap(Symbol::name, Function.identity(), AmbiguousSymbolImpl::mergeTwoSymbols)); Symbol requestSymbol = requestsSymbols.get("request"); assertThat(requestSymbol.kind()).isEqualTo(Kind.FUNCTION); assertThat(requestSymbol.fullyQualifiedName()).isEqualTo("requests.api.request"); }</code><technical_language>assert FQN</technical_language>

Target:
public void package_relative_import() { Map<String, Symbol> osSymbols = TypeShed.symbolsForModule("os").stream().collect(Collectors.toMap(Symbol::name, Function.identity(), AmbiguousSymbolImpl::create)); Symbol sysSymbol = osSymbols.get("sys"); assertThat(sysSymbol.kind()).isEqualTo(Kind.AMBIGUOUS); Symbol timesResult = osSymbols.get("times_result"); assertThat(timesResult.kind()).isEqualTo(Kind.CLASS); assertThat(timesResult.fullyQualifiedName()).isEqualTo("posix.times_result"); Map<String, Symbol> requestsSymbols = TypeShed.symbolsForModule("requests").stream().collect(Collectors.toMap(Symbol::name, Function.identity(), AmbiguousSymbolImpl::create)); Symbol requestSymbol = requestsSymbols.get("request"); assertThat(requestSymbol.kind()).isEqualTo(Kind.FUNCTION); assertThat(requestSymbol.fullyQualifiedName()).isEqualTo("requests.api.request"); }
Source:
<code>public void shutdown(IRecordProcessorCheckpointer checkpointer, ShutdownReason reason) { LOGGER.warn("SHUTDOWN: {}", reason.toString()); <START> if(reason == ShutdownReason.TERMINATE) { <END> try { checkpointer.checkpoint(); } catch (InvalidStateException e) { LOGGER.error(e.getMessage()); } catch (ShutdownException e) { LOGGER.error(e.getMessage()); } } }</code><technical_language>reverse equality check, Objects.equal(a,b) if reason null</technical_language>

Target:
public void shutdown(IRecordProcessorCheckpointer checkpointer, ShutdownReason reason) { LOGGER.warn("SHUTDOWN: {}", reason.toString()); if (Objects.equals(ShutdownReason.TERMINATE, reason)) { try { checkpointer.checkpoint(); } catch (InvalidStateException e) { LOGGER.error(e.getMessage()); } catch (ShutdownException e) { LOGGER.error(e.getMessage()); } } }
Source:
<code>protected ITmfTreeColumnDataProvider getColumnDataProvider() { return new ITmfTreeColumnDataProvider() { @Override public List<@Nullable TmfTreeColumnData> getColumnData() { return ImmutableList.of( <START> createTmfTreeColumnData(COLUMN_NAMES[0], NonNullUtils.checkNotNull(Comparator.comparing(SegmentStoreStatisticsEntry::getName))), <END> createTmfTreeColumnData(COLUMN_NAMES[1], NonNullUtils.checkNotNull(Comparator.comparingLong(s -> s.getEntry().getMin()))), createTmfTreeColumnData(COLUMN_NAMES[2], NonNullUtils.checkNotNull(Comparator.comparingLong(s -> s.getEntry().getMax()))), createTmfTreeColumnData(COLUMN_NAMES[3], NonNullUtils.checkNotNull(Comparator.comparingDouble(s -> s.getEntry().getMean()))), createTmfTreeColumnData(COLUMN_NAMES[4], NonNullUtils.checkNotNull(Comparator.comparingDouble(s -> s.getEntry().getStdDev()))), createTmfTreeColumnData(COLUMN_NAMES[5], NonNullUtils.checkNotNull(Comparator.comparingLong(s -> s.getEntry().getNbElements()))), createTmfTreeColumnData(COLUMN_NAMES[6], NonNullUtils.checkNotNull(Comparator.comparingDouble(s -> s.getEntry().getTotal()))), new TmfTreeColumnData("")); } }; }</code><technical_language>objects.requireNonNull()</technical_language>

Target:
protected ITmfTreeColumnDataProvider getColumnDataProvider() { return new ITmfTreeColumnDataProvider() { @Override public List<@Nullable TmfTreeColumnData> getColumnData() { return ImmutableList.of( createTmfTreeColumnData(COLUMN_NAMES[0], Objects.requireNonNull(Comparator.comparing(SegmentStoreStatisticsEntry::getName))), createTmfTreeColumnData(COLUMN_NAMES[1], Objects.requireNonNull(Comparator.comparingLong(s -> s.getEntry().getMin()))), createTmfTreeColumnData(COLUMN_NAMES[2], Objects.requireNonNull(Comparator.comparingLong(s -> s.getEntry().getMax()))), createTmfTreeColumnData(COLUMN_NAMES[3], Objects.requireNonNull(Comparator.comparingDouble(s -> s.getEntry().getMean()))), createTmfTreeColumnData(COLUMN_NAMES[4], Objects.requireNonNull(Comparator.comparingDouble(s -> s.getEntry().getStdDev()))), createTmfTreeColumnData(COLUMN_NAMES[5], Objects.requireNonNull(Comparator.comparingLong(s -> s.getEntry().getNbElements()))), createTmfTreeColumnData(COLUMN_NAMES[6], Objects.requireNonNull(Comparator.comparingDouble(s -> s.getEntry().getTotal()))), new TmfTreeColumnData("")); } }; }
Source:
<code><START> public void onEvent(CacheEvent<K, V> event) { <END> final EventType type = event.getType(); LOGGER.trace("Cache Event notified for event type {}", type); CacheEventWrapper<K, V> cacheEventWrapper = new CacheEventWrapper<K, V>(event); if(eventThreadLocal.get().isEmpty()) { eventThreadLocal.setOrdered(orderedListenerCount.get() != 0); } eventThreadLocal.get().add(cacheEventWrapper); markFailedCacheEventsInThreadLocal(); if (eventThreadLocal.isOrdered()) { ConcurrentLinkedQueue<CacheEventWrapper> eventWrapperQueue = getEventQueue(event.getKey()); eventWrapperQueue.add(cacheEventWrapper); } }</code><technical_language>need find a bypass completely creation of thread locals registered listeners</technical_language>

Target:
public void onEvent(CacheEvent<K, V> event) { final EventType type = event.getType(); EventThreadLocal threadLocal = eventThreadLocal; LOGGER.trace("Cache Event notified for event type {}", type); CacheEventWrapper<K, V> cacheEventWrapper = new CacheEventWrapper<K, V>(event); if (hasListeners()) { threadLocal.verifyOrderedDispatch(orderedListenerCount.get() != 0); threadLocal.addToEventList(cacheEventWrapper); if (threadLocal.isOrdered()) { ConcurrentLinkedQueue<CacheEventWrapper> eventWrapperQueue = getEventQueue(event.getKey()); eventWrapperQueue.add(cacheEventWrapper); } } }
Source:
<code>public void postDrawEvent(ITimeEvent event, Rectangle bounds, GC gc) { if (fAverageCharWidth == null) { fAverageCharWidth = gc.getFontMetrics().getAverageCharWidth(); } if (bounds.width <= fAverageCharWidth) { return; } if (!(event instanceof FlamegraphEvent)) { return; } String funcSymbol = ""; ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace(); if (activeTrace != null) { FlamegraphEvent fgEvent = (FlamegraphEvent) event; funcSymbol = <START> getFuntionSymbol(fgEvent); <END> } gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE)); Utils.drawText(gc, funcSymbol, bounds.x, bounds.y, bounds.width, bounds.height, true, true); }</code><technical_language>typo</technical_language>

Target:
public void postDrawEvent(ITimeEvent event, Rectangle bounds, GC gc) { if (fAverageCharWidth == null) { fAverageCharWidth = gc.getFontMetrics().getAverageCharWidth(); } if (bounds.width <= fAverageCharWidth) { return; } if (!(event instanceof FlamegraphEvent)) { return; } String funcSymbol = ""; ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace(); if (activeTrace != null) { FlamegraphEvent fgEvent = (FlamegraphEvent) event; funcSymbol = getFunctionSymbol(fgEvent); } gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE)); Utils.drawText(gc, funcSymbol, bounds.x, bounds.y, bounds.width, bounds.height, true, true); }
Source:
<code>public void saveToFile(Object object) { try { Writer writer = new OutputStreamWriter(new FileOutputStream(jsonFile) , CHARSET); gson.toJson(object, object.getClass(), writer); writer.close(); <START> } catch (IOException e) { <END> logger.error("Failed to save object to JSON", e); } }</code><technical_language>if exception swallowed here. In general, if this fails save, caller allowed react in some way</technical_language>

Target:
public void saveToFile(Object object) throws IOException { createDirectories(); Writer writer = new OutputStreamWriter(new FileOutputStream(jsonFile) , CHARSET); gson.toJson(object, object.getClass(), writer); writer.close(); }
Source:
<code>public void testReadWriteMergeHeads() throws IOException { assertEquals(db.readMergeHeads(), null); db.writeMergeHeads(Arrays.asList(ObjectId.zeroId(), <START> ObjectId.fromString(sampleId))); <END> assertEquals(db.readMergeHeads().size(), 2); assertEquals(db.readMergeHeads().get(0), ObjectId.zeroId()); assertEquals(db.readMergeHeads().get(1), ObjectId.fromString(sampleId)); db.writeMergeHeads(Collections.EMPTY_LIST); assertEquals(db.readMergeHeads(), null); FileOutputStream fos = new FileOutputStream(new File(db.getDirectory(), Constants.MERGE_HEAD)); try { fos.write(sampleId.getBytes(Constants.CHARACTER_ENCODING)); } finally { fos.close(); } assertEquals(db.readMergeHeads().size(), 1); assertEquals(db.readMergeHeads().get(0), ObjectId.fromString(sampleId)); }</code><technical_language>test write functionality reading file making format is expect, relying read code path</technical_language>

Target:
public void testReadWriteMergeHeads() throws IOException { assertEquals(db.readMergeHeads(), null); db.writeMergeHeads(Arrays.asList(ObjectId.zeroId(), ObjectId.fromString(sampleId))); assertEquals(read(new File(db.getDirectory(), "MERGE_HEAD")), "0000000000000000000000000000000000000000\n1c6db447abdbb291b25f07be38ea0b1bf94947c5\n"); assertEquals(db.readMergeHeads().size(), 2); assertEquals(db.readMergeHeads().get(0), ObjectId.zeroId()); assertEquals(db.readMergeHeads().get(1), ObjectId.fromString(sampleId)); FileOutputStream fos = new FileOutputStream(new File(db.getDirectory(), "MERGE_HEAD")); try { fos.write("0000000000000000000000000000000000000000\n1c6db447abdbb291b25f07be38ea0b1bf94947c5\n".getBytes(Constants.CHARACTER_ENCODING)); } finally { fos.close(); } assertEquals(db.readMergeHeads().size(), 2); assertEquals(db.readMergeHeads().get(0), ObjectId.zeroId()); assertEquals(db.readMergeHeads().get(1), ObjectId.fromString(sampleId)); db.writeMergeHeads(Collections.EMPTY_LIST); assertEquals(read(new File(db.getDirectory(), "MERGE_HEAD")), ""); assertEquals(db.readMergeHeads(), null); fos = new FileOutputStream(new File(db.getDirectory(), "MERGE_HEAD")); try { fos.write(sampleId.getBytes(Constants.CHARACTER_ENCODING)); } finally { fos.close(); } assertEquals(db.readMergeHeads().size(), 1); assertEquals(db.readMergeHeads().get(0), ObjectId.fromString(sampleId)); }
Source:
<code>@Test public void testAddElementTooLarge() throws IOException { QueueFile queue = new QueueFile(file); <START> byte[] newBigValue = new byte[QueueFile.MAX_ELEMENT_SIZE + 1]; <END> try { queue.add(newBigValue); fail("Should have failed with IllegalArgumentException for element too large."); } catch (IllegalArgumentException e) { assertThat(e).hasMessage("Adding element that is " + (QueueFile.MAX_ELEMENT_SIZE + 1) + " to queue with max" + " element size " + QueueFile.MAX_ELEMENT_SIZE + "."); } finally { queue.close(); } }</code><technical_language>Consider making for tests change MAX_ELEMENT_SIZE instead of creating 2Gb arrays in tests</technical_language>

Target:
@Test public void testAddElementTooLarge() throws IOException { int testMaxElementSize = 1000; QueueFile queue = new QueueFile(file, testMaxElementSize); byte[] newBigValue = new byte[testMaxElementSize + 1]; try { queue.add(newBigValue); fail("Should have failed with IllegalArgumentException for element too large."); } catch (IllegalArgumentException e) { assertThat(e).hasMessage("Adding element that is " + (testMaxElementSize + 1) + " to queue with max" + " element size " + testMaxElementSize + "."); } finally { queue.close(); } }
Source:
<code>public void mapExternalLunDisks(List<LunDisk> luns, Map<String, Object> externalLunMap) { luns.forEach(lunDisk -> { if (externalLunMap != null) { LunDisk targetLunDisk = (LunDisk) externalLunMap.get(lunDisk.getId().toString()); <START> if (targetLunDisk != null) { <END> lunDisk.setLun(targetLunDisk.getLun()); lunDisk.getLun() .getLunConnections() .forEach(conn -> conn.setStorageType(lunDisk.getLun().getLunType())); } } }); }</code><technical_language>great if this logged</technical_language>

Target:
public void mapExternalLunDisks(List<LunDisk> luns, Map<String, Object> externalLunMap) { luns.forEach(lunDisk -> { if (externalLunMap != null) { LunDisk targetLunDisk = (LunDisk) externalLunMap.get(lunDisk.getId().toString()); if (targetLunDisk != null) { log.info("Mapping LUN disk '{}' to '{}'", lunDisk.getLun().getLUNId(), targetLunDisk.getLun().getLUNId()); lunDisk.setLun(targetLunDisk.getLun()); lunDisk.getLun() .getLunConnections() .forEach(conn -> conn.setStorageType(lunDisk.getLun().getLunType())); } else { log.warn("No LUN disk will be mapped, LUN '{}' was not found", targetLunDisk.getLun().getLUNId()); } } }); }
Source:
<code>private void putPropertyIfAbsent(URL url, Properties properties, String propertyName) { String propertyValue = url.getParameter(propertyName); <START> if (propertyValue != null && propertyValue.length() != 0) { <END> properties.setProperty(propertyName, propertyValue); } }</code><technical_language>need trim</technical_language>

Target:
private void putPropertyIfAbsent(URL url, Properties properties, String propertyName) { String propertyValue = url.getParameter(propertyName); if (propertyValue != null && propertyValue.trim().length() != 0) { properties.setProperty(propertyName, propertyValue); } }
Source:
<code>protected DocumentTypeDescriptor mergeDocumentTypeDescriptors(DocumentTypeDescriptor src, DocumentTypeDescriptor dst) { <START> return (DocumentTypeDescriptor) dst.clone().merge(src); <END> }</code><technical_language>need add a cast</technical_language>

Target:
protected DocumentTypeDescriptor mergeDocumentTypeDescriptors(DocumentTypeDescriptor src, DocumentTypeDescriptor dst) { return dst.clone().merge(src); }
Source:
<code>public void setLayoutBehaviour(LinearLayoutManager linearLayoutManager, RecyclerMessageAdapter adapter) { setActionBarLayoutBehaviour(linearLayoutManager,adapter); <START> setFabLayoutBehaviour(linearLayoutManager,adapter); <END> }</code><technical_language>Code reduced. I is need functions (they reference here) :)</technical_language>

Target:
public void setLayoutBehaviour(LinearLayoutManager linearLayoutManager, RecyclerMessageAdapter adapter) { CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams(); layoutParams.setBehavior(new RemoveViewsOnScroll(linearLayoutManager, adapter)); appBarLayout.requestLayout(); layoutParams = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); layoutParams.setBehavior(new RemoveViewsOnScroll(linearLayoutManager, adapter)); fab.setLayoutParams(layoutParams); topSnackBar.setMessagesLayoutManager(linearLayoutManager); topSnackBar.setMessagesAdapter(adapter); }
Source:
<code>public static int getLoginDuration() { SharedPreferences properties = CommCareApplication._().getCurrentApp().getAppPreferences(); <START> return Integer.parseInt(properties.getString(LOGIN_DURATION, "28800")); <END> }</code><technical_language>assumption is OK, prefer wrap a default if parse fails</technical_language>

Target:
public static int getLoginDuration() { SharedPreferences properties = CommCareApplication._().getCurrentApp().getAppPreferences(); try { return Integer.parseInt(properties.getString(LOGIN_DURATION, "28800")); } catch (NumberFormatException e) { return 28000; } }
Source:
<code>private boolean updateMetadataIfPossible(LedgerMetadata metadata, LedgerMetadata newMeta) { if (metadata.isNewerThan(newMeta)) { if (LOG.isDebugEnabled()) { LOG.debug("[EnsembleChange-L{}-{}] : reread metadata because local metadata is newer.", new Object[]{ledgerId, ensembleChangeIdx}); } rereadMetadata(this); return true; } if (metadata.isConflictWith(newMeta)) { if (LOG.isDebugEnabled()) { LOG.debug("[EnsembleChange-L{}-{}] : metadata is conflicted, local metadata = \n \n," + " zk metadata = \n \n", ledgerId, ensembleChangeIdx, metadata, newMeta); } return false; } if (LOG.isDebugEnabled()) { LOG.info("[EnsembleChange-L{}-{}] : resolved ledger metadata conflict and writing to zookeeper," + " local meta data is \n \n, zk meta data is \n {}.", ledgerId, ensembleChangeIdx, metadata, newMeta); } metadata.setVersion(newMeta.getVersion()); metadata.mergeEnsembles(newMeta.getEnsembles()); if (!areFailedBookiesReplaced(metadata, ensembleInfo)) { try { ensembleInfo = replaceBookieInMetadata(ensembleInfo.failedBookies, numEnsembleChanges.get()); } catch (BKException.BKNotEnoughBookiesException e) { LOG.error("Could not get additional bookie to remake ensemble, closing ledger: {}", ledgerId); <START> handleUnrecoverableErrorDuringAdd(e.getCode()); <END> return false; } } writeLedgerConfig(new ChangeEnsembleCb(ensembleInfo, curBlockAddCompletions, ensembleChangeIdx)); return true; }</code><technical_language>I if return false ReReadLedgerMetadataCb handle calling handleUnrecoverableErrorDuringAdd, results in called twice</technical_language>

Target:
private boolean updateMetadataIfPossible(LedgerMetadata metadata, LedgerMetadata newMeta) { if (metadata.isNewerThan(newMeta)) { if (LOG.isDebugEnabled()) { LOG.debug("[EnsembleChange-L{}-{}] : reread metadata because local metadata is newer.", new Object[]{ledgerId, ensembleChangeIdx}); } rereadMetadata(this); return true; } if (metadata.isConflictWith(newMeta)) { if (LOG.isDebugEnabled()) { LOG.debug("[EnsembleChange-L{}-{}] : metadata is conflicted, local metadata = \n \n," + " zk metadata = \n \n", ledgerId, ensembleChangeIdx, metadata, newMeta); } return false; } if (LOG.isDebugEnabled()) { LOG.info("[EnsembleChange-L{}-{}] : resolved ledger metadata conflict and writing to zookeeper," + " local meta data is \n \n, zk meta data is \n {}.", ledgerId, ensembleChangeIdx, metadata, newMeta); } metadata.setVersion(newMeta.getVersion()); metadata.mergeEnsembles(newMeta.getEnsembles()); if (!areFailedBookiesReplaced(metadata, ensembleInfo)) { try { ensembleInfo = replaceBookieInMetadata(ensembleInfo.failedBookies, numEnsembleChanges.get()); } catch (BKException.BKNotEnoughBookiesException e) { LOG.error("Could not get additional bookie to remake ensemble, closing ledger: {}", ledgerId); return false; } } writeLedgerConfig(new ChangeEnsembleCb(ensembleInfo, curBlockAddCompletions, ensembleChangeIdx)); return true; }
Source:
<code>public void adsVideoPageAdsMobile() { <START> adsVideoPageAdsDesktop(); <END> }</code><technical_language>This right: a test for mobile devices method called adsVideoPageAdsDesktop ;-) making adsVideoPageAdsDesktop general renaming adsVideoPageAds proxy methods correct annotations for desktop mobile</technical_language>

Target:
public void adsVideoPageAdsMobile() { adsVideoPageAds(); }
Source:
<code>public void createRulesTest() { PylintRuleRepository ruleRepository = new PylintRuleRepository(new RulesDefinitionXmlLoader()); RulesDefinition.Context context = new RulesDefinition.Context(); ruleRepository.define(context); RulesDefinition.Repository repository = context.repository(PylintRuleRepository.REPOSITORY_KEY); assertThat(repository.language()).isEqualTo("py"); assertThat(repository.name()).isEqualTo("Pylint"); List<RulesDefinition.Rule> rules = repository.rules(); assertThat(rules).isNotNull(); <START> assertThat(rules).hasSize(322); <END> long rulesWithoutRemediationCost = rules.stream() .filter(rule -> rule.debtRemediationFunction() == null) .count(); assertThat(rulesWithoutRemediationCost).isEqualTo(28); }</code><technical_language>@pynicolas I noticed inconsistency: declare 322 rules, 328 entries in remediation cost file. while 142 rules added in rules.xml, 116 added in rules_generated</technical_language>

Target:
public void createRulesTest() { PylintRuleRepository ruleRepository = new PylintRuleRepository(new RulesDefinitionXmlLoader()); RulesDefinition.Context context = new RulesDefinition.Context(); ruleRepository.define(context); RulesDefinition.Repository repository = context.repository(PylintRuleRepository.REPOSITORY_KEY); assertThat(repository.language()).isEqualTo("py"); assertThat(repository.name()).isEqualTo("Pylint"); List<RulesDefinition.Rule> rules = repository.rules(); assertThat(rules).isNotNull(); assertThat(rules).hasSize(325); long rulesWithoutRemediationCost = rules.stream() .filter(rule -> rule.debtRemediationFunction() == null) .count(); assertThat(rulesWithoutRemediationCost).isEqualTo(28); }
Source:
<code>public static <E, K, V, M extends Map<K, V>> TCollector<E, ?, M> toMap(Function<? super E, ? extends K> keyMapper, Function<? super E, ? extends V> valueMapper, BinaryOperator<V> mergeFunction, Supplier<M> mapFactory) { return TCollector.of(mapFactory, (map, el) -> map.merge(keyMapper.apply(el), valueMapper.apply(el), mergeFunction), (m1, m2) -> { <START> m2.forEach((k, v) -> m1.merge(k, v, mergeFunction)); <END> return m1; }, TCollector.Characteristics.IDENTITY_FINISH); }</code><technical_language>Please, for statement</technical_language>

Target:
public static <E, K, V, M extends Map<K, V>> TCollector<E, ?, M> toMap(Function<? super E, ? extends K> keyMapper, Function<? super E, ? extends V> valueMapper, BinaryOperator<V> mergeFunction, Supplier<M> mapFactory) { return TCollector.of(mapFactory, (map, el) -> map.merge(keyMapper.apply(el), valueMapper.apply(el), mergeFunction), (m1, m2) -> { for (Map.Entry<K, V> e : m2.entrySet()) { m1.merge(e.getKey(), e.getValue(), mergeFunction); } return m1; }, TCollector.Characteristics.IDENTITY_FINISH); }