auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void findChildren(CalledFunction node, int callStackQuark, ITmfStateSystem ss, int maxQuark) { fStore.add(node); long curTime = node.getStart(); long limit = node.getEnd(); ITmfStateInterval interval = null; while (curTime < limit) { try { if (callStackQuark + 1 <= maxQuark) { interval = ss.querySingleState(curTime, callStackQuark + 1); } else { return; } } catch (StateSystemDisposedException e) { e.printStackTrace(); } if (interval != null) { ITmfStateValue stateValue = interval.getStateValue(); if (!stateValue.isNull()) { long intervalStart = interval.getStartTime(); long intervalEnd = interval.getEndTime(); CalledFunction segment = new CalledFunction(intervalStart, intervalEnd + 1, stateValue.unboxLong()); segment.setDepth(node.getDepth() + 1); <START> findChildren(segment, callStackQuark + 1, ss, maxQuark); <END> node.addChild(segment); segmentStatics.calculateStatistics(segment); curTime = interval.getEndTime() + 1; } else { curTime = interval.getEndTime() + 1; } } } }</code><technical_language>Quarks for a callstack in state system in order. If processes, level 4 of thread X attributes quarks other threads, callStackQuark + 1 represent right attribute, this code work. pass list of quarks callstack get list item i+1</technical_language>

Target:
private void findChildren(CalledFunction node, int callStackQuark, ITmfStateSystem ss, int maxQuark) { fStore.add(node); long curTime = node.getStart(); long limit = node.getEnd(); ITmfStateInterval interval = null; while (curTime < limit) { try { if (callStackQuark + 1 <= maxQuark) { interval = ss.querySingleState(curTime, actualQuarks.get(callStackQuark + 1)); } else { return; } } catch (StateSystemDisposedException e) { e.printStackTrace(); } if (interval != null) { ITmfStateValue stateValue = interval.getStateValue(); if (!stateValue.isNull()) { long intervalStart = interval.getStartTime(); long intervalEnd = interval.getEndTime(); CalledFunction segment = new CalledFunction(intervalStart, intervalEnd + 1, stateValue.unboxLong()); segment.setDepth(node.getDepth() + 1); findChildren(segment, actualQuarks.get(callStackQuark + 1), ss, maxQuark); node.addChild(segment); fSegmentStatics.calculateStatistics(segment); curTime = interval.getEndTime() + 1; } else { curTime = interval.getEndTime() + 1; } } } }
Source:
<code>public void getSuitablePnpm_tooNewVersionInstalledAndSkipVersionCheck_accepted() throws Exception { Assume.assumeFalse( tools.getNodeExecutable().isEmpty()); <START> String originalPropertyValue = System <END> .getProperty(FrontendUtils.PARAM_IGNORE_VERSION_CHECKS); createFakePnpm("5.5.0"); try { System.setProperty(FrontendUtils.PARAM_IGNORE_VERSION_CHECKS, "true"); List<String> pnpmCommand = tools.getSuitablePnpm(baseDir); Assert.assertNotEquals("expected pnpm version 5.5.0 accepted", 0, pnpmCommand.size()); } finally { if (originalPropertyValue != null) { System.setProperty(FrontendUtils.PARAM_IGNORE_VERSION_CHECKS, originalPropertyValue); } else { System.clearProperty(FrontendUtils.PARAM_IGNORE_VERSION_CHECKS); } } }</code><technical_language>Making flag a parameter in CTOR allow test FrontendTools properly: system properties. code sets system property is thread safe least: property modified of this test time</technical_language>

Target:
public void getSuitablePnpm_tooNewVersionInstalledAndSkipVersionCheck_accepted() throws Exception { tools = new FrontendTools(baseDir, () -> vaadinHomeDir, "v12.10.0", new File(baseDir).toURI(), true); Assume.assumeFalse( tools.getNodeExecutable().isEmpty()); createFakePnpm("5.5.0"); List<String> pnpmCommand = tools.getSuitablePnpm(baseDir); Assert.assertNotEquals("expected pnpm version 5.5.0 accepted", 0, pnpmCommand.size()); }
Source:
<code>private static Stream<ImmutableList<String>> parseLine(String line, char separator) { if (line.length() == 0 || line.startsWith("#") || line.startsWith(";")) { return Stream.empty(); } ImmutableList.Builder<String> builder = ImmutableList.builder(); int start = 0; String terminated = line + separator; <START> int nextComma = terminated.indexOf(separator, start); <END> while (nextComma >= 0) { String possible = terminated.substring(start, nextComma).trim(); if (possible.startsWith("\"")) { while (true) { if (possible.substring(1).replace("\"\"", "").endsWith("\"")) { possible = possible.substring(1, possible.length() - 1).replace("\"\"", "\""); break; } else { nextComma = terminated.indexOf(separator, nextComma + 1); if (nextComma < 0) { throw new IllegalArgumentException("Mismatched quotes on line: " + line); } possible = terminated.substring(start, nextComma).trim(); } } } builder.add(possible); start = nextComma + 1; nextComma = terminated.indexOf(separator, start); } ImmutableList<String> fields = builder.build(); if (!hasContent(fields)) { return Stream.empty(); } return Stream.of(fields); }</code><technical_language>avoid word 'comma' changes</technical_language>

Target:
private static Stream<ImmutableList<String>> parseLine(String line, char separator) { if (line.length() == 0 || line.startsWith("#") || line.startsWith(";")) { return Stream.empty(); } ImmutableList.Builder<String> builder = ImmutableList.builder(); int start = 0; String terminated = line + separator; int nextSeparator = terminated.indexOf(separator, start); while (nextSeparator >= 0) { String possible = terminated.substring(start, nextSeparator).trim(); if (possible.startsWith("\"")) { while (true) { if (possible.substring(1).replace("\"\"", "").endsWith("\"")) { possible = possible.substring(1, possible.length() - 1).replace("\"\"", "\""); break; } else { nextSeparator = terminated.indexOf(separator, nextSeparator + 1); if (nextSeparator < 0) { throw new IllegalArgumentException("Mismatched quotes on line: " + line); } possible = terminated.substring(start, nextSeparator).trim(); } } } builder.add(possible); start = nextSeparator + 1; nextSeparator = terminated.indexOf(separator, start); } ImmutableList<String> fields = builder.build(); if (!hasContent(fields)) { return Stream.empty(); } return Stream.of(fields); }
Source:
<code>public SAMFileWriter makeBAMWriter(final SAMFileHeader header, final boolean presorted, final Path outputPath, final int compressionLevel) { try { final boolean createMd5File = this.createMd5File && IOUtil.isRegularPath(outputPath); if (this.createMd5File && !createMd5File) { log.warn("Cannot create MD5 file for BAM because output file is not a regular file: " + outputPath.toUri()); } OutputStream os = IOUtil.maybeBufferOutputStream(Files.newOutputStream(outputPath), bufferSize); if (createMd5File) os = new Md5CalculatingOutputStream(os, IOUtil.addExtension(outputPath,".md5")); final BAMFileWriter ret = new BAMFileWriter(os, outputPath.toUri().toString(), compressionLevel, deflaterFactory); final boolean createIndex = this.createIndex && IOUtil.isRegularPath(outputPath); if (this.createIndex && !createIndex) { log.warn("Cannot create index for BAM because output file is not a regular file: " + outputPath.toUri()); } initializeBAMWriter(ret, header, presorted, createIndex); if (this.useAsyncIo) return new AsyncSAMFileWriter(ret, this.asyncOutputBufferSize); else return ret; } catch (final IOException ioe) { <START> throw new RuntimeIOException("Error opening file '" + outputPath.toUri() + "': " + ioe); <END> } }</code><technical_language>@jean-philippe-martin This is a good idea, pass ioe cause? get stack trace in a reasonable way</technical_language>

Target:
public SAMFileWriter makeBAMWriter(final SAMFileHeader header, final boolean presorted, final Path outputPath, final int compressionLevel) { try { final boolean createMd5File = this.createMd5File && IOUtil.isRegularPath(outputPath); if (this.createMd5File && !createMd5File) { log.warn("Cannot create MD5 file for BAM because output file is not a regular file: " + outputPath.toUri()); } OutputStream os = IOUtil.maybeBufferOutputStream(Files.newOutputStream(outputPath), bufferSize); if (createMd5File) os = new Md5CalculatingOutputStream(os, IOUtil.addExtension(outputPath,".md5")); final BAMFileWriter ret = new BAMFileWriter(os, outputPath.toUri().toString(), compressionLevel, deflaterFactory); final boolean createIndex = this.createIndex && IOUtil.isRegularPath(outputPath); if (this.createIndex && !createIndex) { log.warn("Cannot create index for BAM because output file is not a regular file: " + outputPath.toUri()); } initializeBAMWriter(ret, header, presorted, createIndex); if (this.useAsyncIo) return new AsyncSAMFileWriter(ret, this.asyncOutputBufferSize); else return ret; } catch (final IOException ioe) { throw new RuntimeIOException("Error opening file: " + outputPath.toUri(), ioe); } }
Source:
<code>public ReferenceContext(final int serializableSequenceId) { this.serializableSequenceId = serializableSequenceId; switch (serializableSequenceId) { <START> case INTERNAL_INT_MULTIPLE: <END> this.type = ReferenceContextType.MULTI_REFERENCE; break; case INTERNAL_INT_UNMAPPED: this.type = ReferenceContextType.UNMAPPED_UNPLACED; break; default: if (serializableSequenceId >= 0) { this.type = ReferenceContextType.SINGLE_REFERENCE; } else { throw new CRAMException("Invalid Reference Sequence ID: " + serializableSequenceId); } } }</code><technical_language>I this a public constructor takes a is defined constants public (I initialized public ones, strange callers values implementation). a bit cleaner a single definition</technical_language>

Target:
public ReferenceContext(final int serializableSequenceId) { this.serializableSequenceId = serializableSequenceId; switch (serializableSequenceId) { case MULTIPLE_REFERENCE_ID: this.type = ReferenceContextType.MULTIPLE_REFERENCE_TYPE; break; case UNMAPPED_UNPLACED_ID: this.type = ReferenceContextType.UNMAPPED_UNPLACED_TYPE; break; default: if (serializableSequenceId >= 0) { this.type = ReferenceContextType.SINGLE_REFERENCE_TYPE; } else { throw new CRAMException("Invalid Reference Sequence ID: " + serializableSequenceId); } } }
Source:
<code>public QuickOutlinePageDescriptor(final IQuickOutlineCallback quickOutlineCallback, final IQuickOutlineLabelProvider labelProvider, final IContentProvider contentProvider, String pageDescription) { Preconditions.checkArgument(quickOutlineCallback != null); Preconditions.checkArgument(labelProvider != null); Preconditions.checkArgument(contentProvider != null); Preconditions.checkArgument(pageDescription != null); <START> this.quickOutlineCallback = quickOutlineCallback; this.labelProvider = labelProvider; this.contentProvider = contentProvider; this.pageDescription = pageDescription; <END> }</code><technical_language>Preconditions.checkNotNull() returns tested if null, rewritten in this style: this.x = Preconditions.checkNotNull(x);</technical_language>

Target:
public QuickOutlinePageDescriptor(final IQuickOutlineCallback quickOutlineCallback, final IQuickOutlineLabelProvider labelProvider, final IContentProvider contentProvider, String pageDescription) { this.quickOutlineCallback = Preconditions.checkNotNull(quickOutlineCallback); this.labelProvider = Preconditions.checkNotNull(labelProvider); this.contentProvider = Preconditions.checkNotNull(contentProvider); this.pageDescription = Preconditions.checkNotNull(pageDescription); }
Source:
<code>public boolean parseMib(File mibFile) { if (mibDirectory == null || !mibDirectory.isDirectory()) { errorHandler.addError("MIB directory has not been set."); return false; } missingDependencies.clear(); List<URL> queue = new ArrayList<URL>(); parser.getFileParserPhase().setInputUrls(queue); final Map<String,File> mibDirectoryFiles = new HashMap<String,File>(); for (final File file : mibDirectory.listFiles()) { mibDirectoryFiles.put(file.getName().toLowerCase(), file); } LOG.debug("Parsing {}", mibFile.getAbsolutePath()); SmiMib mib = null; addFileToQueue(queue, mibFile); while (true) { errorHandler.reset(); try { mib = parser.parse(); } catch (Exception e) { <START> LOG.error("Can't compile " + mibFile, e); <END> errorHandler.addError(e.getMessage()); return false; } if (errorHandler.isOk()) { break; } else { List<String> dependencies = errorHandler.getDependencies(); if (dependencies.isEmpty()) break; missingDependencies.addAll(dependencies); if (!addDependencyToQueue(queue, mibDirectoryFiles)) break; } } if (errorHandler.isNotOk()) return false; LOG.info("The MIB has been parsed successfully.", mibFile.getAbsolutePath()); module = getModule(mib, mibFile); return module != null; }</code><technical_language>change these? of end printing message. Exception e = new Exception(); String param = "p1"; LOG.error("error: {}", param, e); LOG.error("error: " + param, e); 2017-10-30 09:54:19,207 ERROR [main] org.opennms.netmgt.snmp.LogTest - error: p1 java.lang.Exception org.opennms.netmgt.snmp.LogTest.doIt(LogTest.java:40) ... 2017-10-30 09:54:19,213 ERROR [main] org.opennms.netmgt.snmp.LogTest - error: p1 java.lang.Exception org.opennms.netmgt.snmp.LogTest.doIt(LogTest.java:40) ..</technical_language>

Target:
public boolean parseMib(File mibFile) { if (mibDirectory == null || !mibDirectory.isDirectory()) { errorHandler.addError("MIB directory has not been set."); return false; } missingDependencies.clear(); List<URL> queue = new ArrayList<URL>(); parser.getFileParserPhase().setInputUrls(queue); final Map<String,File> mibDirectoryFiles = new HashMap<String,File>(); for (final File file : mibDirectory.listFiles()) { mibDirectoryFiles.put(file.getName().toLowerCase(), file); } LOG.debug("Parsing {}", mibFile.getAbsolutePath()); SmiMib mib = null; addFileToQueue(queue, mibFile); while (true) { errorHandler.reset(); try { mib = parser.parse(); } catch (Exception e) { LOG.error("Can't compile {}", mibFile, e); errorHandler.addError(e.getMessage()); return false; } if (errorHandler.isOk()) { break; } else { List<String> dependencies = errorHandler.getDependencies(); if (dependencies.isEmpty()) break; missingDependencies.addAll(dependencies); if (!addDependencyToQueue(queue, mibDirectoryFiles)) break; } } if (errorHandler.isNotOk()) return false; LOG.info("The MIB has been parsed successfully.", mibFile.getAbsolutePath()); module = getModule(mib, mibFile); return module != null; }
Source:
<code>public LocalApplicationRunner(SamzaApplication app, Config config) { this.appDesc = ApplicationDescriptorUtil.getAppDescriptor(app, config); <START> Boolean isAppModeBatch = new ApplicationConfig(appDesc.getConfig()).getAppMode() == ApplicationConfig.ApplicationMode.BATCH; <END> if(isAppModeBatch) { initializeCoordinationUtils(config); initializeRunId(); } this.planner = new LocalJobPlanner(appDesc, coordinationUtils, uid, runId); }</code><technical_language>nit: primitive instead of Boolean</technical_language>

Target:
public LocalApplicationRunner(SamzaApplication app, Config config) { this.appDesc = ApplicationDescriptorUtil.getAppDescriptor(app, config); isAppModeBatch = new ApplicationConfig(config).getAppMode() == ApplicationConfig.ApplicationMode.BATCH; coordinationUtils = getCoordinationUtils(config); }
Source:
<code>public void characters(char ch[], int start, int length) throws SAXException { for (int i = 0; i < length; i++) { <START> cell += Character.toString(ch[i + start]); <END> } String title = ""; if (isTitle) { title = cell; title = title.replaceAll("/", "_"); title = title.replaceAll(" ", "_"); if (title.equals("")) { title = "empty_title"; } try { RoughArtifact roughArtifact = new RoughArtifact(RoughArtifactKind.CONTAINER); roughArtifact.addAttribute(CoreAttributeTypes.Name, title.trim()); roughArtifact.setGuid(GUID.create()); roughArtifact.setSectionNumber("0"); collector.addRoughArtifact(roughArtifact); isTitle = false; } catch (OseeCoreException ex) { throw new SAXException(ex); } } }</code><technical_language>Change cell StringBuilder append method instead</technical_language>

Target:
public void characters(char ch[], int start, int length) { for (int i = 0; i < length; i++) { cell.append(Character.toString(ch[i + start])); } String title = ""; if (isTitle) { title = cell.toString(); title = title.replaceAll("/", "_"); title = title.replaceAll(" ", "_"); if (title.equals("")) { title = "empty_title"; } try { RoughArtifact roughArtifact = new RoughArtifact(RoughArtifactKind.CONTAINER); roughArtifact.addAttribute(CoreAttributeTypes.Name, title.trim()); roughArtifact.setGuid(GUID.create()); roughArtifact.setSectionNumber("0"); collector.addRoughArtifact(roughArtifact); isTitle = false; } catch (OseeCoreException ex) { } } }
Source:
<code>public Repository open(HttpServletRequest req, String name) throws RepositoryNotFoundException, ServiceNotEnabledException { if (!name.equals(repoName)) <START> throw new RepositoryNotFoundException(name); <END> Repository db = repo.getRepository(); db.incrementOpen(); return db; }</code><technical_language>Done. (Copy-paste)</technical_language>

Target:
public Repository open(HttpServletRequest req, String name) throws RepositoryNotFoundException, ServiceNotEnabledException { if (!name.equals(repoName)) { throw new RepositoryNotFoundException(name); } Repository db = repo.getRepository(); db.incrementOpen(); return db; }
Source:
<code>private void loadTab(int position) { QuestionGroupTab tab = mQuestionGroupTabs.get(position); if (!tab.isLoaded()) { Timber.d("Loading Tab #%d", position); tab.load(); tab.loadState(); setupDependencies(); if (mOnTabLoadedListener != null) { <START> mOnTabLoadedListener.OnTabLoaded(); <END> } } }</code><technical_language>suggestion mOnTabLoadedListener.onTabLoaded();</technical_language>

Target:
private void loadTab(int position) { QuestionGroupTab tab = mQuestionGroupTabs.get(position); if (!tab.isLoaded()) { Timber.d("Loading Tab #%d", position); tab.load(); tab.loadState(); setupDependencies(); if (mOnTabLoadedListener != null) { mOnTabLoadedListener.onTabLoaded(); } } }
Source:
<code>private void updatePositionInfo(final StreamInfo info) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); final boolean playbackResumeEnabled = prefs.getBoolean(activity.getString(R.string.enable_watch_history_key), true) && prefs.getBoolean(activity.getString(R.string.enable_playback_resume_key), true); if (!playbackResumeEnabled || info.getDuration() <= 0) { positionView.setVisibility(View.INVISIBLE); detailPositionView.setVisibility(View.GONE); return; } if (recordManager == null) { recordManager = new HistoryRecordManager(requireContext()); } disposables.add(recordManager.loadStreamState(info) .onErrorComplete() .subscribeOn(Schedulers.io()) .delaySubscription(500, TimeUnit.MILLISECONDS) .observeOn(AndroidSchedulers.mainThread()) .subscribe( state -> { final int seconds = (int) (state.getProgressTime() / 1000.f); if (seconds > BasePlayer.PLAYBACK_SAVE_THRESHOLD_START_SECONDS && seconds < info.getDuration() - BasePlayer.PLAYBACK_SAVE_THRESHOLD_END_SECONDS) { positionView.setMax((int) info.getDuration()); positionView.setProgress(seconds); detailPositionView.setText(Localization.getDurationString(seconds)); animateView(positionView, true, 500); animateView(detailPositionView, true, 500); } else { animateView(positionView, false, 500); animateView(detailPositionView, false, 500); } }, error -> { <START> Log.e(TAG, "Player resume failure: ", error); <END> }, () -> { animateView(positionView, false, 500); animateView(detailPositionView, false, 500); } )); }</code><technical_language>suggestion if (DEBUG) Log.e(TAG, "Player resume failure: ", error);</technical_language>

Target:
private void updatePositionInfo(final StreamInfo info) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); final boolean playbackResumeEnabled = prefs.getBoolean(activity.getString(R.string.enable_watch_history_key), true) && prefs.getBoolean(activity.getString(R.string.enable_playback_resume_key), true); if (!playbackResumeEnabled || info.getDuration() <= 0) { positionView.setVisibility(View.INVISIBLE); detailPositionView.setVisibility(View.GONE); return; } if (recordManager == null) { recordManager = new HistoryRecordManager(requireContext()); } disposables.add(recordManager.loadStreamState(info) .onErrorComplete() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( state -> { final int seconds = (int) (state.getProgressTime() / 1000.f); if (seconds > BasePlayer.PLAYBACK_SAVE_THRESHOLD_START_SECONDS && seconds < info.getDuration() - BasePlayer.PLAYBACK_SAVE_THRESHOLD_END_SECONDS) { positionView.setMax((int) info.getDuration()); positionView.setProgress(seconds); detailPositionView.setText(Localization.getDurationString(seconds)); animateView(positionView, true, 500); animateView(detailPositionView, true, 500); } else { animateView(positionView, false, 500); animateView(detailPositionView, false, 500); } }, error -> { if (DEBUG) Log.e(TAG, "Player resume failure: ", error); }, () -> { animateView(positionView, false, 500); animateView(detailPositionView, false, 500); } )); }
Source:
<code>public String getDevicePassword(long id, String protocol, String defaultPassword) { <START> String password = lookupAttributeString(id, Command.KEY_DEVICE_PASSWORD, null, false); <END> if (password != null) { return password; } if (protocol != null) { password = Context.getConfig().getString(protocol + "." + Command.KEY_DEVICE_PASSWORD); if (password != null) { return password; } } return defaultPassword; }</code><technical_language>This checks server-wide settings for password</technical_language>

Target:
public String getDevicePassword(long id, String protocol, String defaultPassword) { String password = lookupAttributeString(id, Command.KEY_DEVICE_PASSWORD, null, false, false); if (password != null) { return password; } if (protocol != null) { password = Context.getConfig().getString(protocol + "." + Command.KEY_DEVICE_PASSWORD); if (password != null) { return password; } } return defaultPassword; }
Source:
<code>private boolean safeWaitForCompletion( Future future, long timeoutSeconds ) { try { future.get( timeoutSeconds, TimeUnit.SECONDS ); } catch ( TimeoutException te ) { <START> System.out.println( "Thread timed out." ); <END> return false; } catch ( InterruptedException | ExecutionException e ) { fail(); } return true; }</code><technical_language>Replace sysout. fail(message)</technical_language>

Target:
private boolean safeWaitForCompletion( Future future, long timeoutSeconds ) { try { future.get( timeoutSeconds, TimeUnit.SECONDS ); } catch ( TimeoutException te ) { return false; } catch ( InterruptedException | ExecutionException e ) { fail(); } return true; }
Source:
<code>public boolean allowsStyleWithHash(@Nonnull HashAlgorithm algorithm, @Nonnull Base64Value hashValue) { if (this.allowsUnsafeInlineStyle()) { return true; } StyleSrcElemDirective styleSrcElemDirective = this.getDirectiveByType(StyleSrcElemDirective.class); <START> if (styleSrcElemDirective == null) { <END> StyleSrcDirective styleSrcDirective = this.getDirectiveByType(StyleSrcDirective.class); if (styleSrcDirective == null) { return this.defaultsAllowHash(algorithm, hashValue); } return styleSrcDirective.matchesHash(algorithm, hashValue); } return styleSrcElemDirective.matchesHash(algorithm, hashValue); }</code><technical_language>This kind of nesting is a bit weird. prefer do a != check early return locals contiguous possible. java StyleSrcElemDirective styleSrcElemDirective = this.getDirectiveByType(StyleSrcElemDirective.class); if (styleSrcElemDirective != null) { return styleSrcElemDirective.matchesHash(algorithm, hashValue); } StyleSrcDirective styleSrcDirective = this.getDirectiveByType(StyleSrcDirective.class); if (styleSrcDirective != null) { return styleSrcDirective.matchesHash(algorithm, hashValue); } return this.defaultsAllowHash(algorithm, hashValue); for other additions below</technical_language>

Target:
public boolean allowsStyleWithHash(@Nonnull HashAlgorithm algorithm, @Nonnull Base64Value hashValue) { if (this.allowsUnsafeInlineStyle()) { return true; } StyleSrcElemDirective styleSrcElemDirective = this.getDirectiveByType(StyleSrcElemDirective.class); if (styleSrcElemDirective != null) { return styleSrcElemDirective.matchesHash(algorithm, hashValue); } StyleSrcDirective styleSrcDirective = this.getDirectiveByType(StyleSrcDirective.class); if (styleSrcDirective != null) { return styleSrcDirective.matchesHash(algorithm, hashValue); } return this.defaultsAllowHash(algorithm, hashValue); }
Source:
<code>public ChangesResult changes(String selector, Object since, Integer limit) { <START> Map<String, Object> options = getDefaultChangeFeedOptions(); <END> if(selector != null) { options.put("filter", "_selector"); } if(since != null) { options.put("since", since); } if (limit != null) { options.put("limit", limit); } if(limit != null) { options.put("seq_interval", limit); } else { options.put("seq_interval", 1000); } return this.changes(selector, options); }</code><technical_language>a lot of copy paste this existing constructor, hive this a utility function builds options</technical_language>

Target:
public ChangesResult changes(String selector, Object since, Integer limit) { Misc.checkNotNullOrEmpty(selector,null); Map<String, Object> options = getParametrizedChangeFeedOptions(since, limit); options.put("filter", "_selector"); URI changesFeedUri = uriHelper.changesUri(options); HttpConnection connection = Http.POST(changesFeedUri, "application/json"); connection.setRequestBody(selector); return executeToJsonObjectWithRetry(connection, ChangesResult.class); }
Source:
<code>public void randomBigDecimalUsingRange() { RandomFunction random = new RandomFunction(BigDecimal.class, new Range(1, 1000)); BigDecimal bigDecimal = random.generateValue(); assertNotNull("Generated BigDecimal must not be null", bigDecimal); assertTrue("Generated value must be a BigDecimal", bigDecimal instanceof BigDecimal); <START> assertTrue(new BigDecimal("1").compareTo(bigDecimal) != 1); <END> assertTrue(new BigDecimal("1000").compareTo(bigDecimal) != -1); }</code><technical_language>check if generated is in range instead of checking if limit values. like: assertTrue(new BigDecimal("1").compareTo(bigDecimal) >= 1); assertTrue(new BigDecimal("1000").compareTo(bigDecimal) <= 1000); do think</technical_language>

Target:
public void randomBigDecimalUsingRange() { RandomFunction random = new RandomFunction(BigDecimal.class, new Range(1, 1000)); BigDecimal bigDecimal = random.generateValue(); assertNotNull("Generated BigDecimal must not be null", bigDecimal); assertTrue("Generated value must be a BigDecimal", bigDecimal instanceof BigDecimal); assertTrue(bigDecimal.compareTo(new BigDecimal("1")) >= 0); assertTrue(bigDecimal.compareTo(new BigDecimal("1000")) <= 0); }
Source:
<code>public Iterable<User> iterate() { return new RtPagination<User>( this.request, new RtPagination.Mapping<User, JsonObject>() { @Override public User map(final JsonObject object) { <START> return new RtUser( <END> RtCollaborators.this.owner.github(), RtCollaborators.this.entry, object.getString("login") ); } } ); }</code><technical_language>this is a hard-coded dependency, bad practice. instead, get user Users, get this.owner</technical_language>

Target:
public Iterable<User> iterate() { return new RtPagination<User>( this.request, new RtPagination.Mapping<User, JsonObject>() { @Override public User map(final JsonObject object) { return RtCollaborators.this.owner.github().users() .get(object.getString("login")); } } ); }
Source:
<code>protected void executeInternal(ServiceHub hub) throws DockerAccessException, MojoExecutionException { if (skipBuild) { return; } List<ImageConfiguration> resolvedImages = getResolvedImages(); <START> if(resolvedImages == null || resolvedImages.isEmpty()) { <END> resolvedImages.add(ImageConfiguration.getDefaultImageConfiguration(project, imageName)); } for (ImageConfiguration imageConfig : resolvedImages) { BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration(); if (buildConfig != null) { if (buildConfig.skip()) { log.info("%s : Skipped building", imageConfig.getDescription()); } else { buildAndTag(hub, imageConfig); } } } }</code><technical_language>resolvedImges null next for loop fail NPE. I put this extra method returns early in this case put this if-else loop</technical_language>

Target:
protected void executeInternal(ServiceHub hub) throws DockerAccessException, MojoExecutionException { if (skipBuild) { return; } List<ImageConfiguration> resolvedImages = getResolvedImages(); if(resolvedImages.isEmpty()) { if(imageName == null) { imageName = project.getGroupId() + "/" + project.getArtifactId() + ":" + project.getVersion(); } ImageConfiguration aDefaultImageConfig = ImageConfiguration.getDefaultImageConfiguration(imageName, project.getBasedir().getAbsolutePath()); processImageConfig(hub, aDefaultImageConfig); return; } else { for (ImageConfiguration imageConfig : resolvedImages) { processImageConfig(hub, imageConfig); } } }
Source:
<code>private void createButtons() { btnCancel = createButton( locale.buttonCancel(), "git-revert-cancel", <START> new ClickHandler() { <END> @Override public void onClick(ClickEvent event) { delegate.onCancelClicked(); ; } }); addButtonToFooter(btnCancel); btnRevert = createButton( locale.buttonRevert(), "git-revert", new ClickHandler() { @Override public void onClick(ClickEvent event) { delegate.onRevertClicked(); } }); addButtonToFooter(btnRevert); }</code><technical_language>Please replace lamda</technical_language>

Target:
private void createButtons() { btnCancel = createButton( locale.buttonCancel(), "git-revert-cancel", event -> { delegate.onCancelClicked(); }); addButtonToFooter(btnCancel); btnRevert = createButton( locale.buttonRevert(), "git-revert", event -> { delegate.onRevertClicked(); }); addButtonToFooter(btnRevert); }
Source:
<code>public void emitTuples() { while ((!fileQueue.isEmpty()) && (fileCount < getMaxFilesPerWindow())) { Path newPath = fileQueue.peek(); String newPathString = newPath.toString(); pendingFiles.add(newPathString); <START> synchronized (processedFiles.getClass()) { <END> processedFiles.add(newPathString); } localProcessedFileCount.increment(); fileQueue.remove(); fileCount++; } super.emitTuples(); }</code><technical_language>This is needed ConcurrentHashSet</technical_language>

Target:
public void emitTuples() { getFilesFromQueue(); super.emitTuples(); }
Source:
<code>public PrestoS3OutputStream( AmazonS3 s3, String host, String key, File tempFile, boolean sseEnabled, PrestoS3SseType sseType, String sseKmsKeyId, long multiPartUploadMinFileSize, long multiPartUploadMinPartSize, PrestoS3AclType aclType) throws IOException { super(new BufferedOutputStream(new FileOutputStream(requireNonNull(tempFile, "tempFile is null")))); transferManager = TransferManagerBuilder.standard() .withS3Client(requireNonNull(s3, "s3 is null")) .withMinimumUploadPartSize(multiPartUploadMinPartSize) .withMultipartUploadThreshold(multiPartUploadMinFileSize).build(); this.host = requireNonNull(host, "host is null"); this.key = requireNonNull(key, "key is null"); this.tempFile = tempFile; this.sseEnabled = sseEnabled; this.sseType = requireNonNull(sseType, "sseType is null"); <START> this.sseKmsKeyId = sseKmsKeyId; <END> this.aclType = aclType.getCannedACL(); log.debug("OutputStream for key '%s' using file: %s", key, tempFile); }</code><technical_language>Please add requireNonNull(aclType, "aclType is null"); assignment this.host above</technical_language>

Target:
public PrestoS3OutputStream( AmazonS3 s3, String host, String key, File tempFile, boolean sseEnabled, PrestoS3SseType sseType, String sseKmsKeyId, long multiPartUploadMinFileSize, long multiPartUploadMinPartSize, PrestoS3AclType aclType) throws IOException { super(new BufferedOutputStream(new FileOutputStream(requireNonNull(tempFile, "tempFile is null")))); transferManager = TransferManagerBuilder.standard() .withS3Client(requireNonNull(s3, "s3 is null")) .withMinimumUploadPartSize(multiPartUploadMinPartSize) .withMultipartUploadThreshold(multiPartUploadMinFileSize).build(); requireNonNull(aclType, "aclType is null"); this.aclType = aclType.getCannedACL(); this.host = requireNonNull(host, "host is null"); this.key = requireNonNull(key, "key is null"); this.tempFile = tempFile; this.sseEnabled = sseEnabled; this.sseType = requireNonNull(sseType, "sseType is null"); this.sseKmsKeyId = sseKmsKeyId; log.debug("OutputStream for key '%s' using file: %s", key, tempFile); }
Source:
<code>private static CqlClient create( TaggedMetricRegistry taggedMetricRegistry, Session session, int preparedStatementCacheSize) { QueryCache queryCache = QueryCache.create( <START> key -> session.prepare(key.formatQueryString()).setConsistencyLevel(key.queryConsistency()), <END> taggedMetricRegistry, preparedStatementCacheSize); return new CqlClientImpl(session, queryCache); }</code><technical_language>odd place put it/why is part of cache key</technical_language>

Target:
private static CqlClient create( TaggedMetricRegistry taggedMetricRegistry, Session session, int preparedStatementCacheSize) { QueryCache queryCache = QueryCache.create( key -> session.prepare(key.formatQueryString()), taggedMetricRegistry, preparedStatementCacheSize); return new CqlClientImpl(session, queryCache); }
Source:
<code>public void execute() throws BuildException { if (includes == null && includesFile == null) { return; } if (destDir == null) { throw new BuildException("Destination directory not defined"); } if (!destDir.exists()) { try { <START> destDir.mkdir(); <END> } catch (SecurityException e) { throw new BuildException("Destination directory " + destDir + " does not exist and could not be created."); } } try { final FileUtils fileUtils = FileUtils.newFileUtils(); final List<String> incs = getIncludes(); if (relativePaths == null) { for (final String inc: incs) { final File srcFile = new File(inc); if (srcFile.exists()) { final File destFile = new File(destDir, srcFile.getName()); fileUtils.copyFile(srcFile, destFile); } } } else { for (final String inc: incs) { final File srcFile = new File(inc); File destFile = null; for (final String rel: relativePaths.split(COMMA)) { final File temp = new File(destDir, rel); if (temp.getName().equalsIgnoreCase(srcFile.getName())) { destFile = temp; break; } } if (srcFile.exists() && destFile != null) { fileUtils.copyFile(srcFile, destFile); } } } } catch (final IOException e) { throw new BuildException(e.getMessage(), e); } }</code><technical_language>This mkdirs(), mkdir(), missing directories in multiple levels. Also, this catch SecurityException; check return of mkdirs() throw IOException a BuildException if returns false</technical_language>

Target:
public void execute() throws BuildException { if (includes == null && includesFile == null) { return; } if (destDir == null) { throw new BuildException("Destination directory not defined"); } if (!destDir.exists() && !destDir.mkdirs()) { throw new BuildException(new IOException("Destination directory " + destDir + " cannot be created")); } try { final FileUtils fileUtils = FileUtils.newFileUtils(); final List<String> incs = getIncludes(); if (relativePaths == null) { for (final String inc: incs) { final File srcFile = new File(inc); if (srcFile.exists()) { final File destFile = new File(destDir, srcFile.getName()); fileUtils.copyFile(srcFile, destFile); } } } else { for (final String inc: incs) { final File srcFile = new File(inc); File destFile = null; for (final String rel: relativePaths.split(COMMA)) { final File temp = new File(destDir, rel); if (temp.getName().equalsIgnoreCase(srcFile.getName())) { destFile = temp; break; } } if (srcFile.exists() && destFile != null) { fileUtils.copyFile(srcFile, destFile); } } } } catch (final IOException e) { throw new BuildException(e.getMessage(), e); } }
Source:
<code>public void triggerMisfired(Trigger trigger) { if (trigger.getKey().getGroup() == Scheduler.DEFAULT_GROUP) { long misfireDeltaMs = System.currentTimeMillis() - trigger.getNextFireTime().getTime(); <START> registry.timer("triggers.cronMisfires").record(misfireDeltaMs, TimeUnit.MILLISECONDS); <END> } }</code><technical_language>track additional information here, kind of trigger is? cardinality of that? (e.g. is a pipeline trigger, internal trigger, etc)</technical_language>

Target:
public void triggerMisfired(Trigger trigger) { if (trigger.getKey().getGroup() == Scheduler.DEFAULT_GROUP) { long misfireDeltaMs = System.currentTimeMillis() - trigger.getNextFireTime().getTime(); registry.timer("echo.triggers.quartz.misfires").record(misfireDeltaMs, TimeUnit.MILLISECONDS); } }
Source:
<code>public void close() throws IOException { txnLog.close(); <START> txnLog = null; <END> snapLog.close(); snapLog = null; }</code><technical_language>if set this variable null calling this method result in ugly NullPointerException try { if (txnLog != null) { txnLog.close(); } } finally { txnLog = null; }</technical_language>

Target:
public void close() throws IOException { if (txnLog != null) { txnLog.close(); txnLog = null; } if (snapLog != null) { snapLog.close(); snapLog = null; } }
Source:
<code>@Test public void doNotOverrideWrapperEnvVar() throws Exception { FreeStyleProject p = setupProjectWithDefaultEnvValue(); p.getBuildWrappersList().add(new ContributingWrapper("DISPLAY", "BUILD_VAL")); <START> validate(p); <END> }</code><technical_language>please hide validation process in "mistic guest" this is antipattern of test writing. hamcrest matchers :) cool</technical_language>

Target:
public void doNotOverrideWrapperEnvVar() throws Exception { FreeStyleProject p = setupProjectWithDefaultEnvValue(); p.getBuildWrappersList().add(new ContributingWrapper("DISPLAY", "BUILD_VAL")); assertValueInjected(p); }
Source:
<code>public AccessToken getNewAccessToken(ByteBuffer username) { long stamp = lock.tryOptimisticRead(); <START> checkArgument(isExistingUsername0(username) && isEnabledUsername(username)); <END> if(!lock.validate(stamp)) { lock.readLock(); try { checkArgument(isExistingUsername0(username)); } finally { lock.unlockRead(stamp); } } return tokenManager.addToken(ByteBuffers.encodeAsHex(username)); }</code><technical_language>this call isEnabledUsername0</technical_language>

Target:
public AccessToken getNewAccessToken(ByteBuffer username) { long stamp = lock.tryOptimisticRead(); checkArgument(isEnabledUsername(username)); if(!lock.validate(stamp)) { lock.readLock(); try { checkArgument(isEnabledUsername0(username)); } finally { lock.unlockRead(stamp); } } return tokenManager.addToken(ByteBuffers.encodeAsHex(username)); }
Source:
<code><START> public void validatePaths(String[] paths) { <END> validateZkVersion(); for (String path : paths) { if (!zkClient.exists(path)) { zkClient.createPersistent(path, true); } } }</code><technical_language>is minor, this new name is accurate. I call assurePathExists</technical_language>

Target:
public void validatePaths(String[] paths) { for (String path : paths) { if (!zkClient.exists(path)) { zkClient.createPersistent(path, true); } } }
Source:
<code>public boolean put(final K key, final V val, final CacheEntryPredicate filter) throws IgniteCheckedException { boolean statsEnabled = ctx.statisticsEnabled(); boolean performanceStatsEnabled = ctx.kernalContext().performanceStatistics().statisticsEnabled(); long start = statsEnabled || performanceStatsEnabled ? System.nanoTime() : 0L; A.notNull(key, "key", val, "val"); if (keyCheck) validateCacheKey(key); boolean stored = put0(key, val, filter); if (statsEnabled && stored) metrics0().addPutTimeNanos(System.nanoTime() - start); <START> if (performanceStatsEnabled) <END> writeStatistics(CacheOperationType.PUT, start); return stored; }</code><technical_language>Typo: performanceStatsEnabled name in other cases</technical_language>

Target:
public boolean put(final K key, final V val, final CacheEntryPredicate filter) throws IgniteCheckedException { boolean statsEnabled = ctx.statisticsEnabled(); boolean performanceStatsEnabled = ctx.kernalContext().performanceStatistics().enabled(); long start = statsEnabled || performanceStatsEnabled ? System.nanoTime() : 0L; A.notNull(key, "key", val, "val"); if (keyCheck) validateCacheKey(key); boolean stored = put0(key, val, filter); if (statsEnabled && stored) metrics0().addPutTimeNanos(System.nanoTime() - start); if (performanceStatsEnabled) writeStatistics(OperationType.CACHE_PUT, start); return stored; }
Source:
<code>private void checkTasks() { if (storeOnlyTasks != null) { checkStoreTasks(); } if (stored >= minimalStore && replicated >= minimalReplicated && paged >= minimalPage) { <START> checkGenericTasks(); <END> } }</code><technical_language>rename this checkCompleteContext please</technical_language>

Target:
private void checkTasks() { if (storeOnlyTasks != null) { checkStoreTasks(); } if (stored >= minimalStore && replicated >= minimalReplicated && paged >= minimalPage) { checkCompleteContext(); } }
Source:
<code>public Object execute(ExecutionEvent event) throws ExecutionException { GitHistoryPage page = getPage(); Repository repo = getRepository(event); IWizard wiz = null; <START> List<Ref> branches = getBranchesExcludingCurrent(page, repo); <END> if (branches.isEmpty()) { PlotCommit commit = (PlotCommit) getSelection(page) .getFirstElement(); wiz = new CreateBranchWizard(repo, commit.name()); } else { Collections.sort(branches, new Comparator<Ref>() { public int compare(Ref o1, Ref o2) { String refName1 = o1.getName(); String refName2 = o2.getName(); if (refName1.startsWith(Constants.R_REMOTES)) { if (refName2.startsWith(Constants.R_HEADS)) return -1; else return refName1.compareTo(refName2); } else { if (refName2.startsWith(Constants.R_REMOTES)) return 1; else return refName1.compareTo(refName2); } } }); Ref branch = branches.get(0).getLeaf(); wiz = new CreateBranchWizard(repo, branch.getName()); } WizardDialog dlg = new WizardDialog( HandlerUtil.getActiveShellChecked(event), wiz); dlg.setHelpAvailable(false); dlg.open(); return null; }</code><technical_language>I assume excluding current branch done in order avoid current local branch input for CreateBranchWizard. This is needed anymore solution. If is local branch pointing currently selected commit, chosen default if is checked out. Optional: Fix this in this change changing getBranchesExcludingCurrent</technical_language>

Target:
public Object execute(ExecutionEvent event) throws ExecutionException { GitHistoryPage page = getPage(); Repository repo = getRepository(event); IWizard wiz = null; List<Ref> branches = getBranches(page, repo); if (branches.isEmpty()) { PlotCommit commit = (PlotCommit) getSelection(page) .getFirstElement(); wiz = new CreateBranchWizard(repo, commit.name()); } else { Collections.sort(branches, new Comparator<Ref>() { public int compare(Ref o1, Ref o2) { String refName1 = o1.getName(); String refName2 = o2.getName(); if (refName1.startsWith(Constants.R_REMOTES)) { if (refName2.startsWith(Constants.R_HEADS)) return -1; else return refName1.compareTo(refName2); } else { if (refName2.startsWith(Constants.R_REMOTES)) return 1; else return refName1.compareTo(refName2); } } }); Ref branch = branches.get(0).getLeaf(); wiz = new CreateBranchWizard(repo, branch.getName()); } WizardDialog dlg = new WizardDialog( HandlerUtil.getActiveShellChecked(event), wiz); dlg.setHelpAvailable(false); dlg.open(); return null; }
Source:
<code>default Map<String, Object> getEventStyle(ITimeEvent event) { StateItem stateItem = null; int index = getStateTableIndex(event); StateItem[] stateTable = getStateTable(); if (index >= 0 && index < stateTable.length) { stateItem = stateTable[index]; } Map<String, Object> styleMap = stateItem == null ? <START> Collections.emptyMap() : <END> stateItem.getStyleMap(); Map<String, Object> specificEventStyles = getSpecificEventStyle(event); if (specificEventStyles.isEmpty()) { return styleMap; } if (styleMap.isEmpty()) { return specificEventStyles; } styleMap = new HashMap<>(styleMap); styleMap.putAll(specificEventStyles); return styleMap; }</code><technical_language>part of this patch</technical_language>

Target:
default Map<String, Object> getEventStyle(ITimeEvent event) { StateItem stateItem = null; int index = getStateTableIndex(event); StateItem[] stateTable = getStateTable(); if (index >= 0 && index < stateTable.length) { stateItem = stateTable[index]; } Map<String, Object> styleMap = stateItem == null ? Collections.EMPTY_MAP : stateItem.getStyleMap(); Map<String, Object> specificEventStyles = getSpecificEventStyle(event); if (specificEventStyles.isEmpty()) { return styleMap; } if (styleMap.isEmpty()) { return specificEventStyles; } styleMap = new HashMap<>(styleMap); styleMap.putAll(specificEventStyles); return styleMap; }
Source:
<code><START> private static IllegalStateException <END> prepareNotFoundException(Guid macPoolId) { final String msg = String.format(INEXISTENT_POOL_EXCEPTION_MESSAGE, macPoolId); return new IllegalStateException(msg); }</code><technical_language>private static? is this good for? static (except for utility methods in Math class) static factories etc</technical_language>

Target:
private IllegalStateException prepareNotFoundException(Guid macPoolId) { final String msg = String.format(INEXISTENT_POOL_EXCEPTION_MESSAGE, macPoolId); return new IllegalStateException(msg); }
Source:
<code>protected void subAppend(LoggingEvent event) { Level level = event.getLevel(); if (level.equals(Level.INFO)) { super.subAppend(event); } else { this.qw.write(getColour(event.getLevel())); this.qw.write(event.getLevel().toString() + ": "); this.qw.write(END_COLOUR); super.subAppend(event); <START> if (this.immediateFlush) { <END> this.qw.flush(); } } }</code><technical_language>need flush, code of super.subAppend(event);</technical_language>

Target:
protected void subAppend(LoggingEvent event) { if (!Level.INFO.equals(event.getLevel())) { this.qw.write(getColour(event.getLevel())); this.qw.write(event.getLevel().toString() + ": "); this.qw.write(END_COLOUR); } super.subAppend(event); }
Source:
<code>public void draw(GameDrawer drawer, SolGame game) { float x = position.x; float y = position.y; if (level.depth != 1) { Vector2 camPosition = game.getCam().getPosition(); x = (x - camPosition.x) / level.depth + camPosition.x; y = (y - camPosition.y) / level.depth + camPosition.y; } if (isAdditive) { <START> drawer.drawAdditive(getTexture(), textureSizeX, textureSizeY, originalX, originalY, x, y, angle, tint); <END> } else { drawer.draw(getTexture(), textureSizeX, textureSizeY, originalX, originalY, x, y, angle, tint); } }</code><technical_language>Is reason getTexture() instead of texture here? a big deal, avoiding extra function call easily avoided (without loss readability) a no-brainer me</technical_language>

Target:
public void draw(GameDrawer drawer, SolGame game) { float x = position.x; float y = position.y; if (level.depth != 1) { Vector2 camPosition = game.getCam().getPosition(); x = (x - camPosition.x) / level.depth + camPosition.x; y = (y - camPosition.y) / level.depth + camPosition.y; } if (isAdditive) { drawer.drawAdditive(texture, textureSizeX, textureSizeY, originalX, originalY, x, y, angle, tint); } else { drawer.draw(texture, textureSizeX, textureSizeY, originalX, originalY, x, y, angle, tint); } }