Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion src/main/java/core/basesyntax/SalaryInfo.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,46 @@
package core.basesyntax;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item "Don't begin class or method implementation with an empty line. Remove all redundant empty lines": there is an empty line between the package declaration and the first import, which counts as starting the class file with an unnecessary empty line.

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class SalaryInfo {
static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd.MM.yyyy");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item "Don't begin class or method implementation with an empty line. Remove all redundant empty lines": there is an extra empty line between the class declaration and the formatter field; the class implementation should not start with a blank line.

public String getSalaryInfo(String[] names, String[] data, String dateFrom, String dateTo) {
return null;
StringBuilder stringBuilder = new StringBuilder("Report for period "

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to checklist item "Any magic numbers should be constants / Move all hardcoded values to constant fields", the string literal "Report for period " should be extracted into a constant with an informative name instead of being inlined here.

+ dateFrom + " - " + dateTo);
if (names == null || data == null) {
return "No data";
}
String[] partsOfData;
String dataName;
int workingHour;
int incomePerHour;
int calcSalary = 0;

LocalDate localDateFrom = LocalDate.parse(dateFrom, FORMATTER);
LocalDate localDateTo = LocalDate.parse(dateTo, FORMATTER);
for (String name : names) {
for (String datum : data) {
if (datum == null) {
continue;
}
partsOfData = datum.split(" ");
dataName = partsOfData[1];
workingHour = Integer.parseInt(partsOfData[2]);
incomePerHour = Integer.parseInt(partsOfData[3]);
LocalDate localDate = LocalDate.parse(partsOfData[0], FORMATTER);
if (name.equals(dataName)
&& !localDate.isBefore(localDateFrom)
&& !localDate.isAfter(localDateTo)) {
calcSalary = calcSalary + (workingHour * incomePerHour);
}
}
stringBuilder.append(System.lineSeparator()).append(name)
.append(" - ").append(calcSalary);
calcSalary = 0;
}
return stringBuilder.toString();
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item "Don't begin class or method implementation with an empty line. Remove all redundant empty lines": there is an extra empty line at the end of the file after the closing brace of the class.

Loading