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
40 changes: 39 additions & 1 deletion src/main/java/core/basesyntax/SalaryInfo.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
package core.basesyntax;

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code."

public class SalaryInfo {
public String getSalaryInfo(String[] names, String[] data, String dateFrom, String dateTo) {
return null;
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 the requirement: "If a date formatter is created, it must be a constant field." The formatter should be declared as a static final constant, not inside the method.

LocalDate startDate = LocalDate.parse(dateFrom, formatter);
LocalDate endDate = LocalDate.parse(dateTo, formatter);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code."

StringBuilder reportBuilder = new StringBuilder();
reportBuilder.append("Report for period ")
.append(dateFrom)
.append(" - ")
.append(dateTo);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code."

for (String name : names) {
int totalSalary = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code."

for (String record : data) {
String[] parts = record.split(" ");

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 the requirement: "Move any magic numbers to constant fields with informative names." The indices 0, 1, 2, and 3 used in parts[0], parts[1], etc., should be replaced with named constants.

String recordDateStr = parts[0];

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 the requirement: "Move any magic numbers to constant fields with informative names." The indices 0, 1, 2, and 3 used in parts[0], parts[1], etc., should be replaced with named constants.

String recordName = parts[1];

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 the requirement: "Move any magic numbers to constant fields with informative names." The indices 0, 1, 2, and 3 used in parts[0], parts[1], etc., should be replaced with named constants.

int hours = Integer.parseInt(parts[2]);

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 the requirement: "Move any magic numbers to constant fields with informative names." The indices 0, 1, 2, and 3 used in parts[0], parts[1], etc., should be replaced with named constants.

int rate = Integer.parseInt(parts[3]);

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 the requirement: "Move any magic numbers to constant fields with informative names." The indices 0, 1, 2, and 3 used in parts[0], parts[1], etc., should be replaced with named constants.


Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code."

LocalDate recordDate = LocalDate.parse(recordDateStr, formatter);

if (name.equals(recordName)
&& !recordDate.isBefore(startDate)
&& !recordDate.isAfter(endDate)) {
totalSalary += hours * rate;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code."

reportBuilder.append(System.lineSeparator())
.append(name)
.append(" - ")
.append(totalSalary);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is a redundant empty line here, which violates the requirement: "Remove all redundant empty lines from the code."

return reportBuilder.toString();
}
}