From 9e31bfa7d7c7a58bb07475374cea38198e62d8ab Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 19 Apr 2019 17:08:12 +0400 Subject: [PATCH] #106 add checkstyle rules --- checkstyle.xml | 4 ++-- .../java/ru/ulstu/core/model/BaseEntity.java | 6 +++++- src/main/java/ru/ulstu/core/util/DateUtils.java | 9 +++++++-- .../java/ru/ulstu/file/service/FileService.java | 2 +- src/main/java/ru/ulstu/odin/model/OdinField.java | 11 +++++++---- .../ru/ulstu/paper/service/LatexService.java | 16 ++++++++++------ .../students/controller/TaskController.java | 10 ++++++++-- src/main/java/ru/ulstu/students/model/Task.java | 14 +++++++++++++- .../java/ru/ulstu/user/model/UserSession.java | 8 +++++++- 9 files changed, 60 insertions(+), 20 deletions(-) diff --git a/checkstyle.xml b/checkstyle.xml index 5877ec9..828cdaa 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -100,7 +100,7 @@ - + + diff --git a/src/main/java/ru/ulstu/core/model/BaseEntity.java b/src/main/java/ru/ulstu/core/model/BaseEntity.java index bd0f1e4..d3dfa76 100644 --- a/src/main/java/ru/ulstu/core/model/BaseEntity.java +++ b/src/main/java/ru/ulstu/core/model/BaseEntity.java @@ -1,6 +1,10 @@ package ru.ulstu.core.model; -import javax.persistence.*; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; +import javax.persistence.Version; import java.io.Serializable; @MappedSuperclass diff --git a/src/main/java/ru/ulstu/core/util/DateUtils.java b/src/main/java/ru/ulstu/core/util/DateUtils.java index b24b09c..6122583 100644 --- a/src/main/java/ru/ulstu/core/util/DateUtils.java +++ b/src/main/java/ru/ulstu/core/util/DateUtils.java @@ -1,6 +1,11 @@ package ru.ulstu.core.util; -import java.time.*; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.Month; +import java.time.ZoneId; import java.util.Arrays; import java.util.Calendar; import java.util.Date; @@ -24,7 +29,7 @@ public class DateUtils { return cal; } - public static List getMonths () { + public static List getMonths() { return Arrays.asList(Month.values()); } diff --git a/src/main/java/ru/ulstu/file/service/FileService.java b/src/main/java/ru/ulstu/file/service/FileService.java index d3a7e8c..4bb1658 100644 --- a/src/main/java/ru/ulstu/file/service/FileService.java +++ b/src/main/java/ru/ulstu/file/service/FileService.java @@ -127,7 +127,7 @@ public class FileService { public void createLatexAttachs(PaperDto paper) throws IOException { for (FileDataDto fileDataDto : paper.getFiles() .stream() - .filter(f -> (f.isLatexAttach()!=null && f.isLatexAttach()) && !f.isDeleted()) + .filter(f -> (f.isLatexAttach() != null && f.isLatexAttach()) && !f.isDeleted()) .collect(Collectors.toList())) { if (fileDataDto.getId() == null) { File oldFile = getTmpFilePath(fileDataDto.getTmpFileName()).toFile(); diff --git a/src/main/java/ru/ulstu/odin/model/OdinField.java b/src/main/java/ru/ulstu/odin/model/OdinField.java index 5917a44..c60c945 100644 --- a/src/main/java/ru/ulstu/odin/model/OdinField.java +++ b/src/main/java/ru/ulstu/odin/model/OdinField.java @@ -31,14 +31,13 @@ public abstract class OdinField implements Comparable { return this.name().toLowerCase(); } } - - private Field field; protected final OdinFieldType fieldType; protected final String fieldName; protected final String caption; protected final OdinVisible.OdinVisibleType visible; protected final boolean readOnly; protected final boolean notEmpty; + private Field field; public OdinField(Field field, OdinFieldType fieldType) { this.field = field; @@ -126,8 +125,12 @@ public abstract class OdinField implements Comparable { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } OdinField odinField = (OdinField) o; return Objects.equals(fieldName, odinField.fieldName); } diff --git a/src/main/java/ru/ulstu/paper/service/LatexService.java b/src/main/java/ru/ulstu/paper/service/LatexService.java index 6bf5226..82dd1ba 100644 --- a/src/main/java/ru/ulstu/paper/service/LatexService.java +++ b/src/main/java/ru/ulstu/paper/service/LatexService.java @@ -12,11 +12,11 @@ import java.nio.file.Files; @Service public class LatexService { + private final String pdfLatexError = "Errors occurred while executing pdfLaTeX."; + private final String bibtexError = "Errors occurred while executing bibtex."; private String errorMessage; private File pdfFile; private FileService fileService; - private final String pdfLatexError = "Errors occurred while executing pdfLaTeX."; - private final String bibtexError = "Errors occurred while executing bibtex."; public LatexService(FileService fileService) { this.fileService = fileService; @@ -42,7 +42,9 @@ public class LatexService { InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream()); try (BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { - while ((bufferedReader.readLine()) != null) ; + while ((bufferedReader.readLine()) != null) { + // + } } int exitCode = process.waitFor(); @@ -55,16 +57,18 @@ public class LatexService { private boolean generate(String filename, File dir) throws IOException, InterruptedException { startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError); startProcess(new String[]{"bibtex", filename}, dir, bibtexError); - if (startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError) != 0) + if (startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError) != 0) { return false; + } return checkPdf(filename, dir); } private boolean checkPdf(String filename, File dir) { pdfFile = new File(dir.getAbsolutePath() + File.separator + filename + ".pdf"); - if (pdfFile.isFile()) return true; - else { + if (pdfFile.isFile()) { + return true; + } else { errorMessage = "The pdf file could not be created."; return false; } diff --git a/src/main/java/ru/ulstu/students/controller/TaskController.java b/src/main/java/ru/ulstu/students/controller/TaskController.java index 8fd9575..50cb052 100644 --- a/src/main/java/ru/ulstu/students/controller/TaskController.java +++ b/src/main/java/ru/ulstu/students/controller/TaskController.java @@ -3,7 +3,11 @@ package ru.ulstu.students.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.validation.Errors; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.students.model.Task; import ru.ulstu.students.model.TaskDto; @@ -16,7 +20,9 @@ import java.util.List; import java.util.stream.Collectors; import static org.springframework.util.StringUtils.isEmpty; -import static ru.ulstu.students.controller.Navigation.*; +import static ru.ulstu.students.controller.Navigation.REDIRECT_TO; +import static ru.ulstu.students.controller.Navigation.TASKS_PAGE; +import static ru.ulstu.students.controller.Navigation.TASK_PAGE; @Controller() @RequestMapping(value = "/students") diff --git a/src/main/java/ru/ulstu/students/model/Task.java b/src/main/java/ru/ulstu/students/model/Task.java index be1b1c6..c4d7409 100644 --- a/src/main/java/ru/ulstu/students/model/Task.java +++ b/src/main/java/ru/ulstu/students/model/Task.java @@ -7,7 +7,19 @@ import ru.ulstu.core.model.BaseEntity; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.tags.model.Tag; -import javax.persistence.*; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/src/main/java/ru/ulstu/user/model/UserSession.java b/src/main/java/ru/ulstu/user/model/UserSession.java index 1eb761d..50fec65 100644 --- a/src/main/java/ru/ulstu/user/model/UserSession.java +++ b/src/main/java/ru/ulstu/user/model/UserSession.java @@ -2,7 +2,13 @@ package ru.ulstu.user.model; import ru.ulstu.core.model.BaseEntity; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; import javax.validation.constraints.NotNull; import java.util.Date;