Skip to content

Commit 44537e3

Browse files
committed
added badges
1 parent 091fd32 commit 44537e3

File tree

11 files changed

+107
-10
lines changed

11 files changed

+107
-10
lines changed

.github/workflows/checkstyle.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Checkstyle
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
checkstyle:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- name: Set up JDK 17
20+
uses: actions/setup-java@v3
21+
with:
22+
distribution: 'temurin'
23+
java-version: '17'
24+
25+
- name: Set up Gradle
26+
uses: gradle/gradle-build-action@v2
27+
28+
- name: Run Checkstyle
29+
run: ./gradlew checkstyleMain checkstyleTest

.github/workflows/codeclimate.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CodeClimate
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
codeclimate:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- name: Set up JDK 17
20+
uses: actions/setup-java@v3
21+
with:
22+
distribution: 'temurin'
23+
java-version: '17'
24+
25+
- name: Install CodeClimate Test Reporter
26+
run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter && chmod +x ./cc-test-reporter
27+
28+
- name: Run Checkstyle and report to CodeClimate
29+
env:
30+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
31+
run: |
32+
./gradlew checkstyleMain checkstyleTest
33+
./cc-test-reporter format-coverage build/reports/checkstyle/main.xml --input-type checkstyle
34+
./cc-test-reporter upload-coverage

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/java-project-71.iml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
### Hexlet tests and linter status:
2-
[![Actions Status](https://github.com/DashProsh/java-project-71/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/DashProsh/java-project-71/actions)
2+
[![Actions Status](https://github.com/DashProsh/java-project-71/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/DashProsh/java-project-71/actions)
3+
[![Maintainability](https://api.codeclimate.com/v1/badges/0b1e0037af9861a38f11/maintainability)](https://codeclimate.com/github/DashProsh/java-project-71/maintainability)
4+
[![Test Coverage](https://api.codeclimate.com/v1/badges/0b1e0037af9861a38f11/test_coverage)](https://codeclimate.com/github/DashProsh/java-project-71/test_coverage)
5+

app/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ tasks.test {
3636
}
3737
}
3838

39+
checkstyle {
40+
toolVersion = "10.12.1" // Убедись, что используешь актуальную версию
41+
configFile = file("${rootProject.projectDir}/config/checkstyle/checkstyle.xml")
42+
isIgnoreFailures = false // Если true, ошибки не будут прерывать билд
43+
isShowViolations = true // Показывает найденные проблемы
44+
}
45+
3946
tasks.jacocoTestReport {
4047
reports {
4148
xml.required.set(true)

app/src/main/java/hexlet/code/App.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
import picocli.CommandLine.Command;
55
import picocli.CommandLine.Option;
66

7-
import com.fasterxml.jackson.databind.ObjectMapper;
8-
import java.io.File;
97
import java.io.IOException;
10-
import java.util.Map;
11-
128

139
@Command(name = "gendiff", mixinStandardHelpOptions = true, version = "gendiff 1.1.1",
1410
description = "Compares two configuration files and shows a difference.")

app/src/main/java/hexlet/code/Differ.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package hexlet.code;
22

3+
import com.fasterxml.jackson.core.type.TypeReference;
34
import com.fasterxml.jackson.databind.ObjectMapper;
45

56
import java.io.File;
@@ -8,14 +9,19 @@
89
import java.util.Set;
910
import java.util.TreeSet;
1011

12+
13+
1114
public class Differ {
1215

1316
public static String generate(String filePath1, String filePath2) throws IOException {
1417
ObjectMapper objectMapper = new ObjectMapper();
1518

1619
// Читаю JSON и складываю в Map
17-
Map<String, Object> fileInfo1 = objectMapper.readValue(new File("src/main/resources/" + filePath1), Map.class);
18-
Map<String, Object> fileInfo2 = objectMapper.readValue(new File("src/main/resources/" + filePath2), Map.class);
20+
21+
Map<String, Object> fileInfo1 = objectMapper.readValue(new File("src/main/resources/" + filePath1),
22+
new TypeReference<Map<String, Object>>() { });
23+
Map<String, Object> fileInfo2 = objectMapper.readValue(new File("src/main/resources/" + filePath2),
24+
new TypeReference<Map<String, Object>>() { });
1925

2026
return generateDiff(fileInfo1, fileInfo2);
2127
}
@@ -28,8 +34,8 @@ public static String generateDiff(Map<String, Object> fileInfo1, Map<String, Obj
2834
allKeys.addAll(fileInfo2.keySet());
2935

3036
// тут буду хранить результат сравнения
31-
StringBuilder differences = new StringBuilder("\n" +
32-
"{\n");
37+
StringBuilder differences = new StringBuilder("\n"
38+
+ "{\n");
3339

3440
//сравниваю по значениям и вывожу обратно ключ-значение
3541
for (String key : allKeys) {
@@ -42,7 +48,8 @@ public static String generateDiff(Map<String, Object> fileInfo1, Map<String, Obj
4248
} else {
4349
if (value1 != null) {
4450
differences.append(" - ").append(key).append(": ").append(value1).append("\n");
45-
} if (value2 != null) {
51+
}
52+
if (value2 != null) {
4653
differences.append(" + ").append(key).append(": ").append(value2).append("\n");
4754
}
4855
}

config/checkstyle/checkstyle.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.sourceforge.io/dtds/configuration_1_3.dtd">
5+
<module name="Checker">
6+
<module name="TreeWalker">
7+
<module name="WhitespaceAfter"/>
8+
<module name="FinalLocalVariable"/>
9+
<module name="AvoidStarImport"/>
10+
<module name="UnusedImports"/>
11+
<module name="JavadocMethod"/>
12+
</module>
13+
</module>

0 commit comments

Comments
 (0)