Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit 4d7b96d

Browse files
authored
Merge pull request #49 from BasePractice/features/checkstyle
Change
2 parents b26e768 + 5bd73e8 commit 4d7b96d

File tree

67 files changed

+352
-251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+352
-251
lines changed

pom.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,38 @@
9292
<source>${maven.compiler.source}</source>
9393
</configuration>
9494
</plugin>
95+
<plugin>
96+
<groupId>org.apache.maven.plugins</groupId>
97+
<artifactId>maven-checkstyle-plugin</artifactId>
98+
<version>3.5.0</version>
99+
<dependencies>
100+
<dependency>
101+
<groupId>com.puppycrawl.tools</groupId>
102+
<artifactId>checkstyle</artifactId>
103+
<version>10.18.1</version>
104+
</dependency>
105+
</dependencies>
106+
<configuration>
107+
<excludes>**/canonical/db/**/*</excludes>
108+
<configLocation>checkstyle.xml</configLocation>
109+
<consoleOutput>true</consoleOutput>
110+
<failsOnError>true</failsOnError>
111+
<failOnViolation>true</failOnViolation>
112+
<outputFileFormat>xml</outputFileFormat>
113+
<sourceDirectories>
114+
<sourceDirectory>src/main/java</sourceDirectory>
115+
<sourceDirectory>src/test/java</sourceDirectory>
116+
</sourceDirectories>
117+
</configuration>
118+
<executions>
119+
<execution>
120+
<phase>validate</phase>
121+
<goals>
122+
<goal>check</goal>
123+
</goals>
124+
</execution>
125+
</executions>
126+
</plugin>
95127
<plugin>
96128
<groupId>org.apache.maven.plugins</groupId>
97129
<artifactId>maven-pmd-plugin</artifactId>

students/23K0120/23K0120-p01/src/main/java/ru/mirea/practice/s23k0120/task3/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ public static void main(String[] args) {
55
int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
66

77
int sum = 0;
8-
for (int i: arr) {
8+
for (int i : arr) {
99
sum += i;
1010
}
11-
System.out.printf("Sum: %d, Arithmetic mean: %.2f", sum, (float)sum / (float)arr.length);
11+
System.out.printf("Sum: %d, Arithmetic mean: %.2f", sum, (float) sum / (float) arr.length);
1212
}
1313
}

students/23K0120/23K0120-p01/src/main/java/ru/mirea/practice/s23k0120/task5/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public abstract class Main {
66
public static void main(String[] args) {
7-
for (String arg: args) {
7+
for (String arg : args) {
88
System.out.printf(arg);
99
}
1010
System.out.println(Arrays.toString(args));

students/23K0120/23K0120-p01/src/main/java/ru/mirea/practice/s23k0120/task6/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public abstract class Main {
44
public static void main(String[] args) {
55
float partSum = 0;
66
for (int i = 1; i < 11; i++) {
7-
partSum += 1/(float)i;
7+
partSum += 1 / (float) i;
88
System.out.printf("%d-е число гармонического ряда: ", i);
99
for (int j = 1; j < i; j++) {
1010
System.out.printf("1/%d + ", j);

students/23K0120/23K0120-p01/src/main/java/ru/mirea/practice/s23k0120/task7/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public abstract class Main {
44
public static int factorial(int n) {
5-
for (int i = n-1; i > 0; i--) {
5+
for (int i = n - 1; i > 0; i--) {
66
n *= i;
77
}
88
return n;

students/23K0120/23K0120-p02/src/main/java/ru/mirea/practice/s23k0120/task1/author/Author.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package ru.mirea.practice.s23k0120.task1.author;
22

33
public class Author {
4-
private String name;
4+
private final String name;
55
private String email;
6-
private char gender;
6+
private final char gender;
77

88
public Author(String name, String email, char gender) {
99
this.name = name;
@@ -29,9 +29,9 @@ public char getGender() {
2929

3030
@Override
3131
public String toString() {
32-
return "---------Автор---------\n" +
33-
"Имя: " + name + '\n' +
34-
"Почта: " + email + '\n' +
35-
"Пол: " + gender + "\n-----------------------";
32+
return "---------Автор---------\n"
33+
+ "Имя: " + name + '\n'
34+
+ "Почта: " + email + '\n'
35+
+ "Пол: " + gender + "\n-----------------------";
3636
}
3737
}

students/23K0120/23K0120-p02/src/main/java/ru/mirea/practice/s23k0120/task2/ball/Ball.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
public class Ball {
44
double x = 0.0;
55
double y = 0.0;
6+
67
public Ball(double x, double y) {
78
this.x = x;
89
this.y = y;
910
}
11+
1012
public Ball() {
1113
// Default constructor
1214
}
@@ -32,16 +34,13 @@ public void setXY(double x, double y) {
3234
this.setY(y);
3335
}
3436

35-
public void move(double xDisp, double yDisp) {
36-
this.setX(this.getX() + xDisp);
37-
this.setY(this.getY() + yDisp);
37+
public void move(double x, double y) {
38+
this.setX(this.getX() + x);
39+
this.setY(this.getY() + y);
3840
}
3941

4042
@Override
4143
public String toString() {
42-
return "Ball{" +
43-
"x=" + x +
44-
", y=" + y +
45-
'}';
44+
return "Ball{" + "x=" + x + ", y=" + y + '}';
4645
}
4746
}

students/23K0120/23K0120-p02/src/main/java/ru/mirea/practice/s23k0120/task3/circle/Circle.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
public class Circle {
44
private Point center;
55
private double r;
6+
67
public Circle(Point center, double r) {
78
this.center = center;
89
this.r = r;
@@ -26,9 +27,6 @@ public void setR(double r) {
2627

2728
@Override
2829
public String toString() {
29-
return "\nCircle{" +
30-
"center=" + center +
31-
", r=" + r +
32-
"}";
30+
return "\nCircle{" + "center=" + center + ", r=" + r + "}";
3331
}
3432
}

students/23K0120/23K0120-p02/src/main/java/ru/mirea/practice/s23k0120/task3/circle/Point.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
public class Point {
55
private double x = 0.0;
66
private double y = 0.0;
7+
78
public Point() {
89
// Default Constructor
910
}
@@ -15,8 +16,8 @@ public Point(double x, double y) {
1516

1617
public void setPolar(double r, double angle) {
1718
angle = angle * Math.PI / 180f;
18-
this.x = r*Math.cos(angle);
19-
this.y = r*Math.sin(angle);
19+
this.x = r * Math.cos(angle);
20+
this.y = r * Math.sin(angle);
2021
}
2122

2223
public double getX() {
@@ -52,8 +53,8 @@ public void move(Point point) {
5253
public void rotate(double angle) {
5354
angle = angle * Math.PI / 180f;
5455
double xTemp = this.x;
55-
this.x = this.x*Math.cos(angle) - this.y*Math.sin(angle);
56-
this.y = xTemp*Math.sin(angle) + this.y*Math.cos(angle);
56+
this.x = this.x * Math.cos(angle) - this.y * Math.sin(angle);
57+
this.y = xTemp * Math.sin(angle) + this.y * Math.cos(angle);
5758
}
5859

5960
@Override

students/23K0120/23K0120-p02/src/main/java/ru/mirea/practice/s23k0120/task3/circle/Tester.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,23 @@
33
import java.util.Arrays;
44

55
public class Tester {
6-
private Circle[] circles;
7-
private int numOfObjects;
6+
private final Circle[] circles;
7+
private final int numOfObjects;
8+
89
public Tester(Circle[] circles) {
910
this.circles = circles.clone();
1011
this.numOfObjects = this.circles.length;
1112
}
1213

1314
@Override
1415
public String toString() {
15-
return "Tester{" +
16-
"circles=" + Arrays.toString(circles) +
17-
", numOfObjects=" + numOfObjects +
18-
'}';
16+
return "Tester{" + "circles=" + Arrays.toString(circles) + ", numOfObjects=" + numOfObjects + '}';
1917
}
2018

2119
public static void main(String[] args) {
2220
Circle[] circles = new Circle[5];
2321
for (int i = 0; i < circles.length; i++) {
24-
circles[i] = new Circle(new Point(i, i*2), Math.sqrt(i));
22+
circles[i] = new Circle(new Point(i, i * 2), Math.sqrt(i));
2523
}
2624

2725
Tester tester = new Tester(circles);

0 commit comments

Comments
 (0)