// this field causes unused private field
private static final String ASSGIN_NEW_BRAND = "...";
private void reassignAccountBrands(Map<String, Brand> brandMap) {
// this local variable causes unused local variable
Map<Long, Brand> brandIds = brandMap.values().stream().collect(toMap(Brand::getId, Function.identity())); jdbcTemplate.query(SELECT_ACCOUNTS, Account::new)
.stream() .filter(a -> !brandIds.keySet().contains(a.getBrand())) // uses the local variable inside lambda... .peek(a -> a.replaceBrand(brandMap)) .forEach(a -> jdbcTemplate.update(ASSGIN_NEW_BRAND, updateArgs(a))); // uses the field and the method inside lambda...
// more code
}
// this method causes unused private methodprivate Map<String, ?> updateArgs(Account a) { // code}--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/63648f2a-ad96-40d8-837a-3178c05cf183%40googlegroups.com.
runQuery(query, rs -> write(writer, extractor.extractData(rs)));
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/5edf7351-7dc8-41b5-9e9e-ebeb422f74e3%40googlegroups.com.To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+unsubscribe@googlegroups.com.
private <D, L extends List<D>> Path queryToCsv(String type, String query, ResultSetExtractor<L> extractor) { Path tempFile = createCsvTempFile(type); try (BufferedWriter writer = Files.newBufferedWriter(tempFile)) { runQuery(query, rs -> write(writer, extractor.extractData(rs))); // write(Writer, L) used here writer.flush(); return tempFile; } catch (IOException e) { deleteFileIfExists(tempFile); throw new TaskException("unable to write query result to csv", e); } }
private <D, L extends List<D>> void write(Writer writer, L data) { // unused method according to sonar try { for (D item : data) { writer.write(item.toString()); writer.write("\r\n"); } } catch (IOException e) { throw new TaskException("unable to write line", e); } }To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/0774d756-a03f-4346-9a8e-e84b9bfede3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/77884e29-850e-44f3-9218-f2e0e76c555f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import com.vaadin.server.StreamResource;
private void downloadByStreaming() {
/* do some stuff */public Supplier<Map<ApportionmentTarget, BigDecimal>> costCenter( EtlBranch targetBranch, int bookingMonth) { BiPredicate<DataKey, Set<EtlCostCenter>> shouldAdd = (key, src) -> src.contains(key.getCostCenter()) && targetBranch .equals(key.getPostApportionmentBranch());
return turnover( calculateTurnover(extractHelper::extractSourceCostCenter, shouldAdd, bookingMonth), calculateTurnover(extractHelper::extractSourceCostCenter, shouldAdd, bookingMonth));}
// this method is deteced as unused but is used in the above method twice as parameter to turnover()
private <APPORT, SRC> Function<APPORT, BigDecimal> calculateTurnover( Function<APPORT, Set<SRC>> sourceExtractor, BiPredicate<DataKey, Set<SRC>> shouldAdd, int bookingMonth) { return appOrTarget -> { BigDecimal result = BigDecimal.ZERO; Set<SRC> sources = sourceExtractor.apply(appOrTarget); for (Entry<DataKey, DataValue> entry : profitData) { if (entry.getKey().getBookingTime() .getMonth() == bookingMonth && shouldAdd.test(entry.getKey(), sources)) { result = result .add(entry.getValue().getPreApportionment()); } } return result; };}
// here the turnover() signature in case it is related
private Supplier<Map<ApportionmentTarget, BigDecimal>> turnover( Function<Apportionment, BigDecimal> turnoverCalculator, Function<ApportionmentTarget, BigDecimal> targetTurnoverCalculator) {
// code cut
}To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/010ff7f4-3ba2-4a3c-83ab-11d088c65adc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/010ff7f4-3ba2-4a3c-83ab-11d088c65adc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/010ff7f4-3ba2-4a3c-83ab-11d088c65adc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.