#106 add checkstyle rules

merge-requests/62/head
Anton Romanov 5 years ago
parent 6c8554a0b8
commit 9e31bfa7d7

@ -100,7 +100,7 @@
<!-- Checks for imports --> <!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html --> <!-- See http://checkstyle.sf.net/config_import.html -->
<!--<module name="AvoidStarImport"/>--> <module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages --> <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/> <module name="RedundantImport"/>
<!--module name="UnusedImports"> <!--module name="UnusedImports">
@ -136,7 +136,7 @@
<module name="AvoidNestedBlocks"/> <module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/> <module name="EmptyBlock"/>
<module name="LeftCurly"/> <module name="LeftCurly"/>
<!--<module name="NeedBraces"/>--> <module name="NeedBraces"/>
<module name="RightCurly"/> <module name="RightCurly"/>
<!-- Checks for common coding problems --> <!-- Checks for common coding problems -->

@ -1,6 +1,10 @@
package ru.ulstu.core.model; 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; import java.io.Serializable;
@MappedSuperclass @MappedSuperclass

@ -1,6 +1,11 @@
package ru.ulstu.core.util; 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.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
@ -24,7 +29,7 @@ public class DateUtils {
return cal; return cal;
} }
public static List<Month> getMonths () { public static List<Month> getMonths() {
return Arrays.asList(Month.values()); return Arrays.asList(Month.values());
} }

@ -127,7 +127,7 @@ public class FileService {
public void createLatexAttachs(PaperDto paper) throws IOException { public void createLatexAttachs(PaperDto paper) throws IOException {
for (FileDataDto fileDataDto : paper.getFiles() for (FileDataDto fileDataDto : paper.getFiles()
.stream() .stream()
.filter(f -> (f.isLatexAttach()!=null && f.isLatexAttach()) && !f.isDeleted()) .filter(f -> (f.isLatexAttach() != null && f.isLatexAttach()) && !f.isDeleted())
.collect(Collectors.toList())) { .collect(Collectors.toList())) {
if (fileDataDto.getId() == null) { if (fileDataDto.getId() == null) {
File oldFile = getTmpFilePath(fileDataDto.getTmpFileName()).toFile(); File oldFile = getTmpFilePath(fileDataDto.getTmpFileName()).toFile();

@ -31,14 +31,13 @@ public abstract class OdinField implements Comparable {
return this.name().toLowerCase(); return this.name().toLowerCase();
} }
} }
private Field field;
protected final OdinFieldType fieldType; protected final OdinFieldType fieldType;
protected final String fieldName; protected final String fieldName;
protected final String caption; protected final String caption;
protected final OdinVisible.OdinVisibleType visible; protected final OdinVisible.OdinVisibleType visible;
protected final boolean readOnly; protected final boolean readOnly;
protected final boolean notEmpty; protected final boolean notEmpty;
private Field field;
public OdinField(Field field, OdinFieldType fieldType) { public OdinField(Field field, OdinFieldType fieldType) {
this.field = field; this.field = field;
@ -126,8 +125,12 @@ public abstract class OdinField implements Comparable {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) {
if (o == null || getClass() != o.getClass()) return false; return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
OdinField odinField = (OdinField) o; OdinField odinField = (OdinField) o;
return Objects.equals(fieldName, odinField.fieldName); return Objects.equals(fieldName, odinField.fieldName);
} }

@ -12,11 +12,11 @@ import java.nio.file.Files;
@Service @Service
public class LatexService { 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 String errorMessage;
private File pdfFile; private File pdfFile;
private FileService fileService; 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) { public LatexService(FileService fileService) {
this.fileService = fileService; this.fileService = fileService;
@ -42,7 +42,9 @@ public class LatexService {
InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream()); InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream());
try (BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { try (BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
while ((bufferedReader.readLine()) != null) ; while ((bufferedReader.readLine()) != null) {
//
}
} }
int exitCode = process.waitFor(); int exitCode = process.waitFor();
@ -55,16 +57,18 @@ public class LatexService {
private boolean generate(String filename, File dir) throws IOException, InterruptedException { private boolean generate(String filename, File dir) throws IOException, InterruptedException {
startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError); startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError);
startProcess(new String[]{"bibtex", filename}, dir, bibtexError); 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 false;
}
return checkPdf(filename, dir); return checkPdf(filename, dir);
} }
private boolean checkPdf(String filename, File dir) { private boolean checkPdf(String filename, File dir) {
pdfFile = new File(dir.getAbsolutePath() + File.separator + filename + ".pdf"); pdfFile = new File(dir.getAbsolutePath() + File.separator + filename + ".pdf");
if (pdfFile.isFile()) return true; if (pdfFile.isFile()) {
else { return true;
} else {
errorMessage = "The pdf file could not be created."; errorMessage = "The pdf file could not be created.";
return false; return false;
} }

@ -3,7 +3,11 @@ package ru.ulstu.students.controller;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.Errors; 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.deadline.model.Deadline;
import ru.ulstu.students.model.Task; import ru.ulstu.students.model.Task;
import ru.ulstu.students.model.TaskDto; import ru.ulstu.students.model.TaskDto;
@ -16,7 +20,9 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.springframework.util.StringUtils.isEmpty; 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() @Controller()
@RequestMapping(value = "/students") @RequestMapping(value = "/students")

@ -7,7 +7,19 @@ import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.tags.model.Tag; 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.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;

@ -2,7 +2,13 @@ package ru.ulstu.user.model;
import ru.ulstu.core.model.BaseEntity; 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 javax.validation.constraints.NotNull;
import java.util.Date; import java.util.Date;

Loading…
Cancel
Save