auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public PaletteItemDropCommand(IPaletteItem paletteItem, boolean doNotShowWizard){ super(); this.paletteItem = paletteItem; this.doNotShowWizard = doNotShowWizard; START wizard = paletteItem.createWizard(); END corrector = paletteItem.createPositionCorrector(); } Wizard instance is created too early. It should not be cached, and should be created by requesting paletteItem only in createDropWizard(). Implementation of getCustomWizardName() is not needed - it is used here only to check if wizard is available. Hence IPaletteItem just needs method hasWizard(). Old implementations called getCustomWizardName() to create wizard. Here, as wizard is created by IPaletteItem it should also answer if it can be created without actually creating it.

Target:
public PaletteItemDropCommand(IPaletteItem paletteItem, boolean doNotShowWizard){ super(); this.paletteItem = paletteItem; this.doNotShowWizard = doNotShowWizard; corrector = paletteItem.createPositionCorrector(); }
Source:
public void setCommand(IDropCommand command) { super.setCommand(command); IHTMLLibraryVersion vName = ((PaletteItemDropCommand)command).getPaletteItem().getCategory().getVersionGroup().getVersion(); for (IonicVersion v: IonicVersion.ALL_VERSIONS) { if(v.equals(vName)) { version = v; } } START END preferredVersions = new PreferredJSLibVersions(getFile(), getVersion()); preferredVersions.updateLibEnablementAndSelection(); } It should be just version = (IonicVersion)((PaletteItemDropCommand)command).getPaletteItem().getCategory().getVersionGroup().getVersion(); even without check for instance of, because NewIonicWidgetWizard may not be initialized with other version than IonicVersion, it is an error that should cause failure. The same should be done in NewJQueryWidgetWizard.setCommand.

Target:
public void setCommand(IDropCommand command) { super.setCommand(command); version = (IonicVersion)((PaletteItemDropCommand)command).getPaletteItem().getCategory().getVersionGroup().getVersion(); preferredVersions = new PreferredJSLibVersions(getFile(), getVersion()); preferredVersions.updateLibEnablementAndSelection(); }
Source:
public String getKeywordsAsString(){ if(keywords == null){ List<String> list = PaletteInsertManager.getInstance().getKeyWords(xobject.getPath()); keywords = ""; if(list != null){ for(String word : list){ START keywords += word + " "; END } }else{ keywords = getLabel(); } } return keywords; } Use StringBuilder instead.

Target:
public String getKeywordsAsString(){ if(keywords == null){ List<String> list = PaletteInsertManager.getInstance().getKeyWords(xobject.getPath()); if(list != null){ StringBuilder buffer = new StringBuilder(); for(String word : list){ buffer.append(word + " "); } keywords = buffer.toString(); }else{ keywords = getLabel(); } } return keywords; }
Source:
public void resourceChanged(IResourceChangeEvent event) { if(event.getType() == IResourceChangeEvent.PRE_DELETE) { IResource resource = event.getResource(); IProject project = (IProject)resource.getAdapter(IProject.class); if(project != null) { if(mockProjectStore.containsKey(project)) { START System.out.println("remove " + project); END } mockProjectStore.remove(project); } } } Remove this System.out.println please.

Target:
public void resourceChanged(IResourceChangeEvent event) { if(event.getType() == IResourceChangeEvent.PRE_DELETE) { IResource resource = event.getResource(); IProject project = (IProject)resource.getAdapter(IProject.class); if(project != null) { mockProjectStore.remove(project); } } }
Source:
public JSLibModel getWorkingCopy() { if(workingCopy == null) { synchronized (this) { START workingCopy = createCopy(getPreferenceModel()); END } } return workingCopy; } If you want to make this method thread safe then both if(workingCopy == null) and workingCopy = ... should be in the same synchronized block.

Target:
public synchronized JSLibModel getWorkingCopy() { if(workingCopy == null) { workingCopy = createCopy(getPreferenceModel()); } return workingCopy; }
Source:
public void init(IWorkbench workbench, IStructuredSelection selection) { START System.out.println("!!!!!!!!!!!!!!!!"); END } You forgot to remove this println.

Target:
public void init(IWorkbench workbench, IStructuredSelection selection) { }
Source:
public int hashCode() { final int iHash = Double.hashCode( getRealDouble() ); START final int rHash = Double.hashCode( getImaginaryDouble() ); END return Util.combineHash( iHash, rHash ); } You probably want to swap these, so that `rHash <= getRealDouble()` and `iHash <= getImaginaryDouble()`, no?

Target:
public int hashCode() { final int rHash = Double.hashCode( getRealDouble() ); final int iHash = Double.hashCode( getImaginaryDouble() ); return Util.combineHash( rHash, iHash ); }
Source:
protected T cache( final T type ) { if ( t == null ) t = type; return type == null ? t : type; START } END This type cache in ImgFactory is unnecessary complicated. See https://github.com/maarzt/imglib2/commit/ce7966f27abab694e4b261671fe1d4f270bf19e8

Target:
protected void cache( final T type ) { if ( this.type == null ) this.type = type; }
Source:
final static public < A extends LongAccess > ArrayImg< Unsigned4BitType, A > unsigned4Bits( final A access, final long... dim ) { START final ArrayImg< Unsigned4BitType, A > img = new ArrayImg<>( access, dim, new Fraction( 1, 64 ) ); END final Unsigned4BitType t = new Unsigned4BitType( img ); img.setLinkedType( t ); return img; } Shouldn't this be `new Fraction( t.getBitsPerPixel(), 64 )` instead of `new Fraction( 1, 64 )` here?

Target:
final static public < A extends LongAccess > ArrayImg< Unsigned4BitType, A > unsigned4Bits( final A access, final long... dim ) { final ArrayImg< Unsigned4BitType, A > img = new ArrayImg<>( access, dim, new Fraction( 4, 64 ) ); final Unsigned4BitType t = new Unsigned4BitType( img ); img.setLinkedType( t ); return img; }
Source:
final static public < A extends LongAccess > ArrayImg< Unsigned2BitType, A > unsigned2Bits( final A access, final long... dim ) { START final ArrayImg< Unsigned2BitType, A > img = new ArrayImg<>( access, dim, new Fraction( 1, 64 ) ); END final Unsigned2BitType t = new Unsigned2BitType( img ); img.setLinkedType( t ); return img; } Shouldn't this be `new Fraction( t.getBitsPerPixel(), 64 )` instead of `new Fraction( 1, 64 )` here?

Target:
final static public < A extends LongAccess > ArrayImg< Unsigned2BitType, A > unsigned2Bits( final A access, final long... dim ) { final ArrayImg< Unsigned2BitType, A > img = new ArrayImg<>( access, dim, new Fraction( 2, 64 ) ); final Unsigned2BitType t = new Unsigned2BitType( img ); img.setLinkedType( t ); return img; }
Source:
final static public < A extends LongAccess > ArrayImg< UnsignedVariableBitLengthType, A > unsignedVariableBitLengths( final A access, final int nbits, final long... dim ) { START final ArrayImg< UnsignedVariableBitLengthType, A > img = new ArrayImg<>( access, dim, new Fraction( 1, 64 ) ); END final UnsignedVariableBitLengthType t = new UnsignedVariableBitLengthType( img, nbits ); img.setLinkedType( t ); return img; } Shouldn't this be `new Fraction( t.getBitsPerPixel(), 64 )` instead of `new Fraction( 1, 64 )` here?

Target:
final static public < A extends LongAccess > ArrayImg< UnsignedVariableBitLengthType, A > unsignedVariableBitLengths( final A access, final int nbits, final long... dim ) { final ArrayImg< UnsignedVariableBitLengthType, A > img = new ArrayImg<>( access, dim, new Fraction( nbits, 64 ) ); final UnsignedVariableBitLengthType t = new UnsignedVariableBitLengthType( img, nbits ); img.setLinkedType( t ); return img; }
Source:
public boolean valueEquals( C t ) { if ( t.length == length ) { final Iterator< T > a = iterator(); START final Iterator< T > b = iterator(); END while ( a.hasNext() ) if ( !a.next().valueEquals( b.next() ) ) return false; return true; } else return false; } One of these should be `t.iterator()`.

Target:
public boolean valueEquals( C t ) { if ( t.length == length ) { final Iterator< T > a = iterator(); final Iterator< T > b = t.iterator(); while ( a.hasNext() ) if ( !a.next().valueEquals( b.next() ) ) return false; return true; } else return false; }
Source:
START public static < A, B > RandomAccessiblePair< A, B > pair( END final RandomAccessible< A > sourceA, final RandomAccessible< B > sourceB ) { return new RandomAccessiblePair< A, B >( sourceA, sourceB ); } I would suggest to make the return type `RandomAccessible<Pair<A, B>>` or even `RandomAccessible<? extends Pair<A, B>>`, if there is no strong need for being _exactly_ `RandomAccessiblePair<A, B>`. I can imagine that we might want to add other variants implementing this later.

Target:
public static < A, B > RandomAccessible< Pair< A, B > > pair( final RandomAccessible< A > sourceA, final RandomAccessible< B > sourceB ) { return new RandomAccessiblePair< A, B >( sourceA, sourceB ); }
Source:
START public HttpHeaders getHttpHeader(MediaType mediaType) { END return HttpHeaders .of(HttpStatus.OK) .add(HttpHeaderNames.SERVER, "armeria") .add(HttpHeaderNames.DATE, DateTimeFormatter.RFC_1123_DATE_TIME .format(ZonedDateTime.now(ZoneOffset.UTC))) .contentType(mediaType); } This method doesn't depend on any internal state so it can be `static`: ```java public static HttpHeaders getHttpHeader(MediaType mediaType) { ``` That way you don't need to create a new instance of `HttpHeadersHelper` in order to use the method. Where you call it, it'll look like: ```java HttpHeadersHelper.getHttpHeader(...) ``` rather than: ```java new HttpHeadersHelper().getHttpHeader(...) ```

Target:
public static HttpHeaders getHttpHeader(MediaType mediaType) { return HttpHeaders .of(HttpStatus.OK) .add(HttpHeaderNames.SERVER, "armeria") .add(HttpHeaderNames.DATE, DateTimeFormatter.RFC_1123_DATE_TIME .format(ZonedDateTime.now(ZoneOffset.UTC))) .contentType(mediaType); }
Source:
public boolean configure(StaplerRequest req, JSONObject json) throws FormException { BulkChange b = new BulkChange(this); SMTPAuthentication current = this.authentication; try { // reset optional authentication to default before data-binding // Would not be necessary by https://github.com/jenkinsci/jenkins/pull/3669 this.authentication = null; req.bindJSON(this, json); b.commit(); } catch (IOException e) { START this.authentication = current; END b.abort(); throw new FormException("Failed to apply configuration", e, null); } return true; } Should be in `finally` just in case

Target:
public boolean configure(StaplerRequest req, JSONObject json) throws FormException { BulkChange b = new BulkChange(this); SMTPAuthentication current = this.authentication; try { // reset optional authentication to default before data-binding // Would not be necessary by https://github.com/jenkinsci/jenkins/pull/3669 this.authentication = null; req.bindJSON(this, json); b.commit(); } catch (IOException e) { b.abort(); throw new FormException("Failed to apply configuration", e, null); } finally { this.authentication = current; } return true; }
Source:
public void autoService() { START JavaSourcesSubject.assertThat( END JavaFileObjects.forResource("test/SomeService.java"), JavaFileObjects.forResource("test/SomeServiceProvider1.java"), JavaFileObjects.forResource("test/SomeServiceProvider2.java"), JavaFileObjects.forResource("test/Enclosing.java"), JavaFileObjects.forResource("test/AnotherService.java"), JavaFileObjects.forResource("test/AnotherServiceProvider.java")) .processedWith(new AutoServiceProcessor()) .compilesWithoutError() .and().generatesFiles( JavaFileObjects.forResource("META-INF/services/test.SomeService"), JavaFileObjects.forResource("META-INF/services/test.AnotherService")); } nit: Can you static import `assertThat`

Target:
public void autoService() { assertThat( JavaFileObjects.forResource("test/SomeService.java"), JavaFileObjects.forResource("test/SomeServiceProvider1.java"), JavaFileObjects.forResource("test/SomeServiceProvider2.java"), JavaFileObjects.forResource("test/Enclosing.java"), JavaFileObjects.forResource("test/AnotherService.java"), JavaFileObjects.forResource("test/AnotherServiceProvider.java")) .processedWith(new AutoServiceProcessor()) .compilesWithoutError() .and().generatesFiles( JavaFileObjects.forResource("META-INF/services/test.SomeService"), JavaFileObjects.forResource("META-INF/services/test.AnotherService")); }
Source:
Set<ExecutableElement> abstractBuildMethods() { START return ImmutableSet.copyOf(buildMethods).stream() END .filter(MoreElements.hasModifiers(Modifier.ABSTRACT)) .collect(Collectors.toSet()); } The `copyOf` seems superfluous here

Target:
Set<ExecutableElement> abstractBuildMethods() { return buildMethods.stream() .filter(MoreElements.hasModifiers(Modifier.ABSTRACT)) .collect(Collectors.toSet()); }
Source:
START private <K, V> ImmutableBiMap<K, V> newImmutableBiMapRemovingKeys(ImmutableBiMap<K, V> original, END Set<K> keysToRemove) { ImmutableBiMap.Builder<K, V> builder = ImmutableBiMap.builder(); for (Map.Entry<K, V> property : original.entrySet()) { if (!keysToRemove.contains(property.getKey())) { builder.put(property); } } return builder.build(); } Ugh, nevermind. **Immutable**BiMap

Target:
private static <K, V> ImmutableBiMap<K, V> newImmutableBiMapRemovingKeys(ImmutableBiMap<K, V> original, Set<K> keysToRemove) { ImmutableBiMap.Builder<K, V> builder = ImmutableBiMap.builder(); for (Map.Entry<K, V> property : original.entrySet()) { if (!keysToRemove.contains(property.getKey())) { builder.put(property); } } return builder.build(); }
Source:
private <T> ImmutableSet<T> newFilteredImmutableSet(ImmutableSet<T> original, START Predicate<T> predicate) { END ImmutableSet.Builder<T> builder = ImmutableSet.builder(); for (T item : original) { if (predicate.apply(item)) builder.add(item); } return builder.build(); } also looks like this method can be static

Target:
private static <T> ImmutableSet<T> newFilteredImmutableSet(ImmutableSet<T> original, Predicate<T> predicate) { ImmutableSet.Builder<T> builder = ImmutableSet.builder(); for (T item : original) { if (predicate.apply(item)) builder.add(item); } return builder.build(); }
Source:
public synchronized void init(ProcessingEnvironment processingEnv) { super.init(processingEnv); if (extensions == null) { START extensions = ServiceLoader.load(AutoValueExtension.class, getClass().getClassLoader()); END } errorReporter = new ErrorReporter(processingEnv); } I think I would do this directly in the no-arg constructor, i.e. ``` java this(ServiceLoader.load(AutoValueExtension.class, getClass().getClassLoader())); ```

Target:
public synchronized void init(ProcessingEnvironment processingEnv) { super.init(processingEnv); errorReporter = new ErrorReporter(processingEnv); }
Source:
protected Object readResolve() { START if (dirName != null && delegate == null) { END delegate = new AbstractOnDiskBinding.UnbinderImpl(dirName); } return this; } Here `dirName` should never be null, and `delegate` should always be null.

Target:
protected Object readResolve() { return new AbstractOnDiskBinding.UnbinderImpl(dirName); }
Source:
private String result() { START return new String(stream.toString()); END } I don't think you need this `new String`

Target:
private String result() { return stream.toString(); }
Source:
START public void clearErrors() { END this.errors = Collections.emptyList(); } errors can keep final, and instead of attribute `emptyList` here, you can call `List.clear()` method.

Target:
public void clearErrors() { this.errors.clear(); }
Source:
public RegexParseSpec( @JsonProperty("timestampSpec") TimestampSpec timestampSpec, @JsonProperty("dimensionsSpec") DimensionsSpec dimensionsSpec, @JsonProperty("listDelimiter") String listDelimiter, @JsonProperty("columns") List<String> columns, @JsonProperty("pattern") String pattern ) { super(timestampSpec, dimensionsSpec); this.listDelimiter = listDelimiter; START Preconditions.checkNotNull(columns, "columns"); END this.columns = columns; this.pattern = pattern; verify(dimensionsSpec.getDimensions()); } are you sure you don't want this to be optional?

Target:
public RegexParseSpec( @JsonProperty("timestampSpec") TimestampSpec timestampSpec, @JsonProperty("dimensionsSpec") DimensionsSpec dimensionsSpec, @JsonProperty("listDelimiter") String listDelimiter, @JsonProperty("columns") List<String> columns, @JsonProperty("pattern") String pattern ) { super(timestampSpec, dimensionsSpec); this.listDelimiter = listDelimiter; this.columns = columns; this.pattern = pattern; verify(dimensionsSpec.getDimensions()); }
Source:
public Parser<String, Object> makeParser() { START if(flattenSpec != null) { END return new JSONPathParser(convertFieldSpecs(flattenSpec.getFields()), flattenSpec.isUseFieldDiscovery(), null); } else { return new JSONParser(objectMapper, null); } } If possible I think we should always use the JSONPathParser (so, if there is no flattenSpec, use an empty fieldSpecs list and always enable discovery). I think for it to be possible we need: - `new JSONPathParser(ImmutableList.of(), true, objectMapper)` should behave effectively the same as `new JSONParser(objectMapper, null)` - performance should be similar or better I think this is a good goal because it means the underlying implementation won't be switched around just because someone has one thing they want to un-nest.

Target:
public Parser<String, Object> makeParser() { return new JSONPathParser( convertFieldSpecs(flattenSpec.getFields()), flattenSpec.isUseFieldDiscovery(), objectMapper ); }
Source:
public TimestampSpec( @JsonProperty("column") String timestampColumn, @JsonProperty("format") String format ) { this.timestampColumn = (timestampColumn == null) ? defaultColumn : timestampColumn.toLowerCase(); this.timestampFormat = format == null ? defaultFormat : format; START try { END this.timestampConverter = ParserUtils.createTimestampParser(timestampFormat); } catch (ParseException e) { throw Throwables.propagate(e); } } I don't think ParseException wrapping is the right thing here, because it is creating a parser, not actually parsing anything

Target:
public TimestampSpec( @JsonProperty("column") String timestampColumn, @JsonProperty("format") String format ) { this.timestampColumn = (timestampColumn == null) ? defaultColumn : timestampColumn.toLowerCase(); this.timestampFormat = format == null ? defaultFormat : format; this.timestampConverter = ParserUtils.createTimestampParser(timestampFormat); }
Source:
private void setVendorFaxNumberValue(VendorAddress vendorAddress, String vendorFaxNumber) { try { Class type = ObjectUtils.easyGetPropertyType(vendorAddress, VendorPropertyConstants.VENDOR_FAX_NUMBER); ObjectUtils.setObjectProperty(vendorAddress, VendorPropertyConstants.VENDOR_FAX_NUMBER, type, vendorFaxNumber); } catch (FormatException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { vendorAddress.setVendorFaxNumber(null); LOG.error("setVendorFaxNumberValue: Vendor Fax Number cannot be set due to exception: " + e); START e.printStackTrace(); END } } It would be better to use Log4j to print the stack trace, rather than using the exception's printStackTrace() method.

Target:
private void setVendorFaxNumberValue(VendorAddress vendorAddress, String vendorFaxNumber) { try { Class type = ObjectUtils.easyGetPropertyType(vendorAddress, VendorPropertyConstants.VENDOR_FAX_NUMBER); ObjectUtils.setObjectProperty(vendorAddress, VendorPropertyConstants.VENDOR_FAX_NUMBER, type, vendorFaxNumber); } catch (FormatException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { vendorAddress.setVendorFaxNumber(null); LOG.error("setVendorFaxNumberValue: Vendor Fax Number cannot be set due to exception: " + e.getMessage(), e); } }
Source:
private String getSubmitter(String documentId) { String submitterPrincipalId = null; String principalId = workflowDocumentService.getRoutedByPrincipalIdByDocumentId(documentId); List<ActionTaken> actionTakenDTOs = workflowDocumentService.getActionsTaken(documentId); for (ActionTaken actionTaken : actionTakenDTOs) { START if (principalId.equals(actionTaken.getPrincipalId())) { END submitterPrincipalId = principalId; } } return submitterPrincipalId; } I would suggest doing this principalId comparison in a null-safe way.

Target:
private String getSubmitter(String documentId) { String submitterPrincipalId = null; String principalId = workflowDocumentService.getRoutedByPrincipalIdByDocumentId(documentId); List<ActionTaken> actionTakenDTOs = workflowDocumentService.getActionsTaken(documentId); for (ActionTaken actionTaken : actionTakenDTOs) { if (StringUtils.equals(principalId, actionTaken.getPrincipalId())) { submitterPrincipalId = principalId; } } return submitterPrincipalId; }
Source:
private Object[] buildClosedAccountsForItChartArgumentList(Map<String, Date> dateRange) { List<Object> argumentList = new ArrayList<>(); SimpleDateFormat formatter = new SimpleDateFormat(CUKFSConstants.DATE_FORMAT_dd_MMM_yy, Locale.US); argumentList.add(formatter.format(dateRange.get(CuCoaBatchConstants.ClosedAccountsFileCreationConstants.FROM_DATE))); START argumentList.add(formatter.format(dateRange.get(CuCoaBatchConstants.ClosedAccountsFileCreationConstants.TO_DATE))); END return argumentList.toArray(); } Now that the query is using parameters for the dates, do you still need to format them as strings? I believe the parameter replacement can handle the dates as-is, as long as they're using the java.sql.Date or java.sql.Timestamp type.

Target:
private Object[] buildClosedAccountsForItChartArgumentList(Map<String, Date> dateRange) { List<Object> argumentList = new ArrayList<>(); argumentList.add(dateRange.get(CuCoaBatchConstants.ClosedAccountsFileCreationConstants.FROM_DATE)); argumentList.add(dateRange.get(CuCoaBatchConstants.ClosedAccountsFileCreationConstants.TO_DATE)); return argumentList.toArray(); }
Source:
private List<String> buildFileNameList(String... fileNames) { List<String> fileNameList = new ArrayList<String>(); for (String fileName : fileNames) { START fileNameList.add(fileName); END } return fileNameList; } You could greatly simplify this code by using Arrays.asList() instead.

Target:
private List<String> buildFileNameList(String... fileNames) { List<String> fileNameList = Arrays.asList(fileNames); return fileNameList; }
Source:
protected boolean defaultAccountIndicatorIsActive(String rowIndicatorValue) { START return StringUtils.equals(rowIndicatorValue, KFSConstants.ACTIVE_INDICATOR) ? true : false; END } You can just return the StringUtils.equals() result directly; making it a ternary of "? true : false" is redundant.

Target:
protected boolean defaultAccountIndicatorIsActive(String rowIndicatorValue) { return StringUtils.equals(rowIndicatorValue, KFSConstants.ACTIVE_INDICATOR); }
Source:
protected void sendReport(RassBatchJobReport report) { START LOG.debug("sendReport, The report-sending functionality has not been implemented yet."); END rassReportService.sendReportEmail(); } Now that you've implemented the reporting functionality, this log statement can be removed.

Target:
protected void sendReport(RassBatchJobReport report) { rassReportService.sendReportEmail(); }
Source:
private void safelyAddProperty(Properties properties, String key, KualiDecimal value) { START properties.put(key, ObjectUtils.isNull(value) ? KFSConstants.EMPTY_STRING : value.floatValue()); END } Should the KualiDecimal's value just be converted to a String instead of a float, to help avoid the risk of losing data? If you need to convert it to a primitive, I would suggest converting to a "double" instead if you can. The same goes for the equivalent BigDecimal method below.

Target:
private void safelyAddProperty(Properties properties, String key, KualiDecimal value) { properties.put(key, ObjectUtils.isNull(value) ? KFSConstants.EMPTY_STRING : value.toString()); }
Source:
private void safelyAddProperty(Properties properties, String key, Integer value) { START properties.put(key, ObjectUtils.isNull(value) ? KFSConstants.EMPTY_STRING : value.intValue()); END } Do you need to call intValue() here? This particular line of code is just going to implicitly convert the primitive int back into an Integer.

Target:
private void safelyAddProperty(Properties properties, String key, Integer value) { properties.put(key, ObjectUtils.isNull(value) ? KFSConstants.EMPTY_STRING : value); }
Source:
public static <T extends Document> T buildMockDocument(Class<T> documentClass) { PowerMockito.suppress(PowerMockito.constructor(LedgerPostingDocumentBase.class)); T document = null; try { document = PowerMockito.spy(documentClass.newInstance()); } catch (InstantiationException | IllegalAccessException e) { START e.printStackTrace(); END throw new RuntimeException(e); } performInitializationFromSkippedConstructor(document); return document; } should this be logged instead of printed?

Target:
public static <T extends Document> T buildMockDocument(Class<T> documentClass) { PowerMockito.suppress(PowerMockito.constructor(LedgerPostingDocumentBase.class)); T document = null; try { document = PowerMockito.spy(documentClass.newInstance()); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } performInitializationFromSkippedConstructor(document); return document; }
Source:
private static CuRequisitionDocument buildMockCuRequisitionDocument() { START PowerMockito.suppress(PowerMockito.constructor(LedgerPostingDocumentBase.class)); END CuRequisitionDocument document = PowerMockito.spy(new CuRequisitionDocument()); return document; } This exact same suppression is being called by all three of the document-building methods in this class. Would it be possible to perform the suppression in a "Before" or "BeforeClass" annotated method? Or is it necessary to suppress this right before the constructor call?

Target:
private static CuRequisitionDocument buildMockCuRequisitionDocument() { CuRequisitionDocument document = PowerMockito.spy(new CuRequisitionDocument()); return document; }
Source:
public int hashCode() { return Objects.hash(proposalNumber, status, projectTitle, startDate, stopDate, directCostAmount, indirectCostAmount, totalAmount, grantNumber, grantDescription, federalPassThrough, federalPassThroughAgencyNumber, cfdaNumber, organizationCode, costShareRequired, finalReportDueDate, principalAndCoPrincipalInvestigators, START principalAndCoPrincipalInvestigators); END } The "principalAndCoPrincipalInvestigators" list is being hashed twice. I would suggest using it only once when building the hashCode.

Target:
public int hashCode() { return Objects.hash(proposalNumber, status, projectTitle, startDate, stopDate, directCostAmount, indirectCostAmount, totalAmount, grantNumber, grantDescription, federalPassThrough, federalPassThroughAgencyNumber, cfdaNumber, organizationCode, costShareRequired, finalReportDueDate, principalAndCoPrincipalInvestigators); }
Source:
private DateTime parseShortDate(String dateString) { if (StringUtils.isNotBlank(dateString)) { START return new DateTime(RassStringToJavaShortDateTimeAdapter.parseToDateTime(dateString).toDate()); END } else { return null; } } The method RassStringToJavaShortDateTimeAdapter.parseToDateTime() is already returning a DateTime, so extracting its Date value and re-wrapping it in a new DateTime seems redundant.

Target:
private DateTime parseShortDate(String dateString) { if (StringUtils.isNotBlank(dateString)) { return RassStringToJavaShortDateTimeAdapter.parseToDateTime(dateString); } else { return null; } }
Source:
private RassXmlDocumentWrapperFixture(String extractDateString, RassXmlAwardEntryFixture[] awardsArray, RassXmlAgencyEntryFixture[] agencyArray) { START extractDate = new DateTime(RassStringToJavaLongDateTimeAdapter.parseToDateTime(extractDateString).toDate()); END awards = XmlDocumentFixtureUtils.toImmutableList(awardsArray); agencies = XmlDocumentFixtureUtils.toImmutableList(agencyArray); } Another potential redundant re-wrap of a DateTime value.

Target:
private RassXmlDocumentWrapperFixture(String extractDateString, RassXmlAwardEntryFixture[] awardsArray, RassXmlAgencyEntryFixture[] agencyArray) { extractDate = RassStringToJavaLongDateTimeAdapter.parseToDateTime(extractDateString); awards = XmlDocumentFixtureUtils.toImmutableList(awardsArray); agencies = XmlDocumentFixtureUtils.toImmutableList(agencyArray); }
Source:
public void testFindMimeTypeNullFileName() { START String mimeType = attachmentService.findMimeType(StringUtils.EMPTY); END assertEquals(StringUtils.EMPTY, mimeType); } This test case is actually using an empty string instead of a null string. Should it be updated to use a null string, or should this test method just be removed altogether?

Target:
public void testFindMimeTypeNullFileName() { String mimeType = attachmentService.findMimeType(null); assertEquals(StringUtils.EMPTY, mimeType); }
Source:
public List<IndirectCostRecoveryAccount> getActiveIndirectCostRecoveryAccounts() { START List<IndirectCostRecoveryAccount> activeList = new ArrayList(); END for (IndirectCostRecoveryAccount icr : getIndirectCostRecoveryAccounts()) { if (icr.isActive()) { activeList.add(IndirectCostRecoveryAccount.copyICRAccount(icr)); } } return activeList; } Diamond operator is missing from this statement.

Target:
public List<IndirectCostRecoveryAccount> getActiveIndirectCostRecoveryAccounts() { List<IndirectCostRecoveryAccount> activeList = new ArrayList<>(); for (IndirectCostRecoveryAccount icr : getIndirectCostRecoveryAccounts()) { if (icr.isActive()) { activeList.add(IndirectCostRecoveryAccount.copyICRAccount(icr)); } } return activeList; }
Source:
protected boolean shouldValidateOnBudgetTotal() { Boolean validateOnBudgetTotal = parameterService.getParameterValueAsBoolean(ArConstants.AR_NAMESPACE_CODE, ArConstants.CONTRACTS_GRANTS_INVOICE_COMPONENT, START CuArConstants.CG_INVOICE_AMT_BILLED_SUSPENSION_BY_BUDGET_TOTAL, Boolean.TRUE.booleanValue()); END if (LOG.isDebugEnabled()) { LOG.debug("shouldValidateOnBudgetTotal, the value of " + CuArConstants.CG_INVOICE_AMT_BILLED_SUSPENSION_BY_BUDGET_TOTAL + " is " + validateOnBudgetTotal.booleanValue()); } return validateOnBudgetTotal.booleanValue(); } This ParameterService method accepts a Boolean object, so you don't need to unbox Boolean.TRUE here.

Target:
protected boolean shouldValidateOnBudgetTotal() { Boolean validateOnBudgetTotal = parameterService.getParameterValueAsBoolean(ArConstants.AR_NAMESPACE_CODE, ArConstants.CONTRACTS_GRANTS_INVOICE_COMPONENT, CuArConstants.CG_INVOICE_AMT_BILLED_SUSPENSION_BY_BUDGET_TOTAL, Boolean.TRUE); if (LOG.isDebugEnabled()) { LOG.debug("shouldValidateOnBudgetTotal, the value of " + CuArConstants.CG_INVOICE_AMT_BILLED_SUSPENSION_BY_BUDGET_TOTAL + " is " + validateOnBudgetTotal.booleanValue()); } return validateOnBudgetTotal.booleanValue(); }
Source:
private void configureParameterServiceForSuspensionCheck(Boolean value) { Mockito.when(parameterService.getParameterValueAsBoolean(ArConstants.AR_NAMESPACE_CODE, START ArConstants.CONTRACTS_GRANTS_INVOICE_COMPONENT, CuArConstants.CG_INVOICE_AMT_BILLED_SUSPENSION_BY_BUDGET_TOTAL, Boolean.TRUE.booleanValue())).thenReturn(value); END suspensionCategory.setParameterService(parameterService); } Another area where Boolean unboxing may not be needed.

Target:
private void configureParameterServiceForSuspensionCheck(Boolean value) { Mockito.when(parameterService.getParameterValueAsBoolean(ArConstants.AR_NAMESPACE_CODE, ArConstants.CONTRACTS_GRANTS_INVOICE_COMPONENT, CuArConstants.CG_INVOICE_AMT_BILLED_SUSPENSION_BY_BUDGET_TOTAL, Boolean.TRUE)).thenReturn(value); suspensionCategory.setParameterService(parameterService); }
Source:
protected boolean checkContinuationAccountsForNewSubAccounts(MaintenanceDocument maintenanceDocument) { SubAccountGlobal subAccountGlobal = (SubAccountGlobal) maintenanceDocument.getNewMaintainableObject().getBusinessObject(); subAccountGlobal.getSubAccountGlobalNewAccountDetails().stream() START .forEach(this::updateDetailToUseContinuationAccountIfNecessary); END return true; } Is .stream() needed since the getSubAccountGlobalNewAccountDetails() returns a List?

Target:
protected boolean checkContinuationAccountsForNewSubAccounts(MaintenanceDocument maintenanceDocument) { SubAccountGlobal subAccountGlobal = (SubAccountGlobal) maintenanceDocument.getNewMaintainableObject().getBusinessObject(); subAccountGlobal.getSubAccountGlobalNewAccountDetails() .forEach(this::updateDetailToUseContinuationAccountIfNecessary); return true; }
Source:
protected String getDescriptivePayeeTypesAsString(Collection<String> payeeTypeCodes) { List<String> payeeTypeDescriptions = new ArrayList<>(); for (String payeeTypeCode : payeeTypeCodes) { String description = disbursementVoucherPayeeService.getPayeeTypeDescription(payeeTypeCode); if (payeeTypeDescriptions.indexOf(description) == -1) { payeeTypeDescriptions.add(description); } } START return this.convertListToString(payeeTypeDescriptions); END } Is "this" needed here?

Target:
protected String getDescriptivePayeeTypesAsString(Collection<String> payeeTypeCodes) { List<String> payeeTypeDescriptions = new ArrayList<>(); for (String payeeTypeCode : payeeTypeCodes) { String description = disbursementVoucherPayeeService.getPayeeTypeDescription(payeeTypeCode); if (payeeTypeDescriptions.indexOf(description) == -1) { payeeTypeDescriptions.add(description); } } return convertListToString(payeeTypeDescriptions); }
Source:
public List<? extends GlobalBusinessObjectDetail> getAllDetailObjects() { List<GlobalBusinessObjectDetail> detailObjects = new ArrayList<>(); detailObjects.addAll(subAccountGlobalDetails); detailObjects.addAll(subAccountGlobalNewAccountDetails); START return subAccountGlobalDetails; END } I think the return object needs to be updated to return the new detailObjects

Target:
public List<? extends GlobalBusinessObjectDetail> getAllDetailObjects() { List<GlobalBusinessObjectDetail> detailObjects = new ArrayList<>(); detailObjects.addAll(subAccountGlobalDetails); detailObjects.addAll(subAccountGlobalNewAccountDetails); return detailObjects; }
Source:
private KfsVendorDataWrapper createInsuranceCertificateNote(PaymentWorksVendor pmwVendor, KfsVendorDataWrapper kfsVendorDataWrapper) { if (paymentWorksVendorIsPurchaseOrderVendor(pmwVendor) && StringUtils.isNotBlank(pmwVendor.getInsuranceCertificate())) { START StringBuilder sbText = new StringBuilder(getConfigurationService().getPropertyValueAsString(PaymentWorksKeyConstants.NEW_VENDOR_PVEN_NOTES_INSURANCE_CERTIFICATE_URL_EXISTS_MESSAGE)); END kfsVendorDataWrapper = getPaymentWorksBatchUtilityService().createNoteRecordingAnyErrors(kfsVendorDataWrapper, sbText.toString(), PaymentWorksConstants.ErrorDescriptorForBadKfsNote.INSURANCE_CERTIFICATE.getNoteDescriptionString()); } return kfsVendorDataWrapper; } Nothing is being appended to this StringBuilder after constructing it with the initial text, so this could be replaced with a plain String instead.

Target:
private KfsVendorDataWrapper createInsuranceCertificateNote(PaymentWorksVendor pmwVendor, KfsVendorDataWrapper kfsVendorDataWrapper) { if (paymentWorksVendorIsPurchaseOrderVendor(pmwVendor) && StringUtils.isNotBlank(pmwVendor.getInsuranceCertificate())) { kfsVendorDataWrapper = getPaymentWorksBatchUtilityService().createNoteRecordingAnyErrors(kfsVendorDataWrapper, getConfigurationService().getPropertyValueAsString(PaymentWorksKeyConstants.NEW_VENDOR_PVEN_NOTES_INSURANCE_CERTIFICATE_URL_EXISTS_MESSAGE), PaymentWorksConstants.ErrorDescriptorForBadKfsNote.INSURANCE_CERTIFICATE.getNoteDescriptionString()); } return kfsVendorDataWrapper; }
Source:
public void updateExistingPaymentWorksVendorInStagingTable(Integer id, String kfsVendorProcessingStatus, Integer vendorHeaderGeneratedIdentifier, Integer vendorDetailAssignedIdentifier, Timestamp processingTimeStamp) { START updateExistingPaymentWorksVendorInStagingTable(id, null, kfsVendorProcessingStatus, KFSConstants.EMPTY_STRING, KFSConstants.EMPTY_STRING, KFSConstants.EMPTY_STRING, processingTimeStamp, vendorHeaderGeneratedIdentifier, vendorDetailAssignedIdentifier, null); END } The second arg for this call should also be set to an empty string.

Target:
public void updateExistingPaymentWorksVendorInStagingTable(Integer id, String kfsVendorProcessingStatus, Integer vendorHeaderGeneratedIdentifier, Integer vendorDetailAssignedIdentifier, Timestamp processingTimeStamp) { updateExistingPaymentWorksVendorInStagingTable(id, KFSConstants.EMPTY_STRING, kfsVendorProcessingStatus, KFSConstants.EMPTY_STRING, KFSConstants.EMPTY_STRING, KFSConstants.EMPTY_STRING, processingTimeStamp, vendorHeaderGeneratedIdentifier, vendorDetailAssignedIdentifier, null); }
Source:
protected org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeExpense buildNonEmployeeExpense() { org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeExpense nonEmployeeExpense = new org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeExpense(); START return nonEmployeeExpense; END } Would it be better to shorten this to return new org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeExpense() in one line?

Target:
protected DisbursementVoucherNonEmployeeExpense buildNonEmployeeExpense() { return new DisbursementVoucherNonEmployeeExpense(); }
Source:
START protected org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeExpense buildNonEmployeeExpense() { END org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeExpense expense = Mockito.spy(new org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeExpense()); Mockito.doNothing().when(expense).refreshNonUpdateableReferences(); return expense; } Could you import this Class to make the method cleaner?

Target:
protected DisbursementVoucherNonEmployeeExpense buildNonEmployeeExpense() { DisbursementVoucherNonEmployeeExpense expense = Mockito.spy(new DisbursementVoucherNonEmployeeExpense()); Mockito.doNothing().when(expense).refreshNonUpdateableReferences(); return expense; }
Source:
protected void findAndResetInvoiceColumn(ResultRow row) { row.getColumns().stream() START .filter(col -> StringUtils.equalsAnyIgnoreCase(col.getPropertyName(), INVOICE_LINK_COLUMN_NAME)) END .findFirst() .ifPresent(col -> resetInvoiceColumn(row, col)); } Another spot where you could use "equalsIgnoreCase" instead of "equalsAnyIgnoreCase".

Target:
protected void findAndResetInvoiceColumn(ResultRow row) { row.getColumns().stream() .filter(col -> StringUtils.equalsIgnoreCase(col.getPropertyName(), INVOICE_LINK_COLUMN_NAME)) .findFirst() .ifPresent(col -> resetInvoiceColumn(row, col)); }
Source:
private boolean recordPvenRouteStatusChangeForPaymentWorksIsEnabled() { START return (getPaymentWorksBatchUtilityService().retrievePaymentWorksParameterValue(PaymentWorksParameterConstants.PMW_INTEGRATION_IS_ACTIVE_IND).equalsIgnoreCase(KFSConstants.ParameterValues.YES) ? true : false); END } You're already getting a boolean result from this check, so adding a ternary operation of "? true : false" is redundant.

Target:
private boolean recordPvenRouteStatusChangeForPaymentWorksIsEnabled() { return (getPaymentWorksBatchUtilityService().retrievePaymentWorksParameterValue(PaymentWorksParameterConstants.PMW_INTEGRATION_IS_ACTIVE_IND).equalsIgnoreCase(KFSConstants.ParameterValues.YES)); }
Source:
private boolean servicesAreBeingProvided(PaymentWorksVendor pmwVendor) { return (StringUtils.isNotBlank(pmwVendor.getServicesProvided()) && (StringUtils.equalsIgnoreCase(pmwVendor.getServicesProvided(), PaymentWorksConstants.PaymentWorksGoodsVsServicesOptions.SERVICES.getOptionValueAsString()) START | StringUtils.equalsIgnoreCase(pmwVendor.getServicesProvided(), PaymentWorksConstants.PaymentWorksGoodsVsServicesOptions.GOODS_WITH_SERVICES.getOptionValueAsString()))); END } This operator should be changed from a bitwise OR to a logical OR.

Target:
private boolean servicesAreBeingProvided(PaymentWorksVendor pmwVendor) { return (StringUtils.isNotBlank(pmwVendor.getServicesProvided()) && (StringUtils.equalsIgnoreCase(pmwVendor.getServicesProvided(), PaymentWorksConstants.PaymentWorksGoodsVsServicesOptions.SERVICES.getOptionValueAsString()) || StringUtils.equalsIgnoreCase(pmwVendor.getServicesProvided(), PaymentWorksConstants.PaymentWorksGoodsVsServicesOptions.GOODS_WITH_SERVICES.getOptionValueAsString()))); }
Source:
public boolean equals(Object comparingDefaultKfsAccountForAws) { if (comparingDefaultKfsAccountForAws == null) { return false; } if (!(comparingDefaultKfsAccountForAws instanceof DefaultKfsAccountForAws)) { return false; } final DefaultKfsAccountForAws defaultKfsAccountForAws = (DefaultKfsAccountForAws) comparingDefaultKfsAccountForAws; return ObjectUtils.equals(defaultKfsAccountForAws.getKfsDefaultAccount(), kfsDefaultAccount) && START ObjectUtils.equals(defaultKfsAccountForAws.getAwsAccount(), awsAccount) && END ObjectUtils.equals(defaultKfsAccountForAws.getUpdatedAt(), updatedAt); } I think StringUtils would be better here

Target:
public boolean equals(Object comparingDefaultKfsAccountForAws) { if (comparingDefaultKfsAccountForAws == null) { return false; } if (!(comparingDefaultKfsAccountForAws instanceof DefaultKfsAccountForAws)) { return false; } final DefaultKfsAccountForAws defaultKfsAccountForAws = (DefaultKfsAccountForAws) comparingDefaultKfsAccountForAws; return StringUtils.equals(defaultKfsAccountForAws.getKfsDefaultAccount(), kfsDefaultAccount) && StringUtils.equals(defaultKfsAccountForAws.getAwsAccount(), awsAccount) && ObjectUtils.equals(defaultKfsAccountForAws.getUpdatedAt(), updatedAt); }
Source:
private boolean pmwDtosCouldConvertCustomAttributesToPmwJavaClassAttributes(PaymentWorksVendor stgNewVendorRequestDetailToProcess) { START if (stgNewVendorRequestDetailToProcess.isCustomFieldConversionErrors()) { END return false; } else{ return true; } } could probably just return !stgNewVendorRequestDetailToProcess.isCustomFieldConversionErrors()?

Target:
private boolean pmwDtosCouldConvertCustomAttributesToPmwJavaClassAttributes(PaymentWorksVendor stgNewVendorRequestDetailToProcess) { return !stgNewVendorRequestDetailToProcess.isCustomFieldConversionErrors(); }
Source:
public KualiAddress() { super(); this.active = true; START this.objectId = UUID.randomUUID().toString(); END } there is no need to set the value for the object id

Target:
public KualiAddress() { super(); active = true; }
Source:
private void logAccountingLineBaseList(List accountingLines, StringBuilder sb) { List<AccountingLineBase> accountingLineBases = accountingLines; START accountingLineBases.stream().map(line -> line.toString()).forEach(sb::append); END } You could simplify this by using a method reference for the "toString" call.

Target:
private void logAccountingLineBaseList(List accountingLines, StringBuilder sb) { List<AccountingLineBase> accountingLineBases = accountingLines; accountingLineBases.stream().map(AccountingLineBase::toString).forEach(sb::append); }
Source:
protected void cleanTransactionsTable() { LOG.info("cleanTransactionsTable, cleaning CorporateBilledCorporatePaidTransaction table"); START businessObjectService.deleteMatching(CorporateBilledCorporatePaidTransaction.class, new HashMap()); END } Missing generics on HashMap.

Target:
protected void cleanTransactionsTable() { LOG.info("cleanTransactionsTable, cleaning CorporateBilledCorporatePaidTransaction table"); businessObjectService.deleteMatching(CorporateBilledCorporatePaidTransaction.class, new HashMap<String, String>()); }
Source:
private boolean corporateAddressExists(PaymentWorksNewVendorDetailDTO paymentWorksNewVendorDetailDTO) { START if (ObjectUtils.isNotNull(paymentWorksNewVendorDetailDTO.getRequesting_company().getCorp_address())) { END return true; } else { return false; } } do you need to check for nulls on paymentWorksNewVendorDetailDTO and paymentWorksNewVendorDetailDTO.getRequesting_company()?

Target:
private boolean corporateAddressExists(PaymentWorksNewVendorDetailDTO paymentWorksNewVendorDetailDTO) { return (ObjectUtils.isNotNull(paymentWorksNewVendorDetailDTO.getRequesting_company().getCorp_address())); }
Source:
private void logErrorsWithOriginalAccountingDetails(ConcurStandardAccountingExtractDetailLine line) { ConcurAccountInfo accountingInformation = buildConcurAccountingInformation( START line, line.getJournalAccountCode(), line.getSubObjectCode()); END buildValidationResult(accountingInformation, false); } This line should be updated to call the new one-arg buildConcurAccountingInformation() method so that it logs errors for the correct sub-object code.

Target:
private void logErrorsWithOriginalAccountingDetails(ConcurStandardAccountingExtractDetailLine line) { ConcurAccountInfo accountingInformation = buildConcurAccountingInformation(line); buildValidationResult(accountingInformation, false); }
Source:
public boolean validateConcurStandardAccountingExtractDetailLineWithObjectCodeOverride(ConcurStandardAccountingExtractDetailLine line, ConcurStandardAccountingExtractBatchReportData reportData, String overriddenObjectCode, String overriddenSubObjectCode) { boolean valid = validateConcurStandardAccountingExtractDetailLineBase(line, reportData); START valid = validateAccountingLineWithObjectCodeOverrides(line, reportData, overriddenSubObjectCode, null) && valid; END return valid; } Based on the new method signature, the third arg should be the object code and the fourth should be the sub-object code.

Target:
public boolean validateConcurStandardAccountingExtractDetailLineWithObjectCodeOverride(ConcurStandardAccountingExtractDetailLine line, ConcurStandardAccountingExtractBatchReportData reportData, String overriddenObjectCode, String overriddenSubObjectCode) { boolean valid = validateConcurStandardAccountingExtractDetailLineBase(line, reportData); valid = validateAccountingLineWithObjectCodeOverrides(line, reportData, overriddenObjectCode, overriddenSubObjectCode) && valid; return valid; }
Source:
private ConcurAccountInfo buildConcurAccountingInformation(ConcurStandardAccountingExtractDetailLine line) { String objectCode = line.getJournalAccountCode(); String subObjectCode; if (getConcurBatchUtilityService().lineRepresentsPersonalExpenseChargedToCorporateCard(line)) { subObjectCode = line.getSubObjectCode(); } else { START subObjectCode = line.getReportSubObjectCode(); END } ConcurAccountInfo accountingInformation = buildConcurAccountingInformation(line, objectCode, subObjectCode); return accountingInformation; } The if-else results here need to be reversed, so that the original sub-object code is used for non-personal-expense situations.

Target:
private ConcurAccountInfo buildConcurAccountingInformation(ConcurStandardAccountingExtractDetailLine line) { String objectCode = line.getJournalAccountCode(); String subObjectCode; if (getConcurBatchUtilityService().lineRepresentsPersonalExpenseChargedToCorporateCard(line)) { subObjectCode = line.getReportSubObjectCode(); } else { subObjectCode = line.getSubObjectCode(); } ConcurAccountInfo accountingInformation = buildConcurAccountingInformation(line, objectCode, subObjectCode); return accountingInformation; }
Source:
private boolean isDetailFileLineValidCashAdvanceRequest(ConcurRequestExtractRequestDetailFileLine detailFileLine) { START if (detailFileLine.getValidationResult().isCashAdvanceLine() && detailFileLine.getValidationResult().isValidCashAdvanceLine()) { END return true; } else { return false; } } Can we just return the boolean expression?

Target:
private boolean isDetailFileLineValidCashAdvanceRequest(ConcurRequestExtractRequestDetailFileLine detailFileLine) { return (detailFileLine.getValidationResult().isCashAdvanceLine() && detailFileLine.getValidationResult().isValidCashAdvanceLine()); }
Source:
private boolean isNotDuplicateMessage(String message) { START for (String currentMessage : getMessages()) { END if (StringUtils.equals(currentMessage, message)) { return false; } } return true; } This function is presuming that the method caller is verifying "messages" is not null prior to being called which is ok for these changes as that is happening but if this private method is used elsewhere in this class in the future that may pose an issue.

Target:
private boolean isNotDuplicateMessage(String message) { for (String currentMessage : getMessages()) { if (StringUtils.equalsIgnoreCase(currentMessage, message)) { return false; } } return true; }
Source:
public void verifyAddEmptyCollectionMessage() { validationResult.addMessage(TEST_STRING_ONE); START validationResult.addMessages(new ArrayList()); END assertEquals("There should only be one line", 1, validationResult.getMessages().size()); } Missing generics on ArrayList. Adding at least an empty "<>" should allow the compiler to derive the correct generic type, provided that the addMessages() method signature has enough information.

Target:
public void verifyAddEmptyCollectionMessage() { validationResult.addMessage(TEST_STRING_ONE); validationResult.addMessages(new ArrayList<String>()); assertEquals("There should only be one line", 1, validationResult.getMessages().size()); }