Skip to content

Commit 665f8a8

Browse files
committed
Finish reliability showcase quality gates
1 parent c50d228 commit 665f8a8

12 files changed

Lines changed: 175 additions & 25 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ jobs:
2929
with:
3030
persist-credentials: false
3131
- name: Setup Java
32-
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
32+
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0
3333
with:
3434
distribution: temurin
3535
java-version: 21
3636
- name: Initialize CodeQL
37-
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4
37+
uses: github/codeql-action/init@7188fc363630916deb702c7fdcf4e481b751f97a # v4.37.1
3838
with:
3939
languages: ${{ matrix.language }}
4040
queries: security-and-quality
4141
- name: Build for CodeQL
4242
run: mvn -B verify --file pom.xml
4343
- name: Perform CodeQL Analysis
44-
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4
44+
uses: github/codeql-action/analyze@7188fc363630916deb702c7fdcf4e481b751f97a # v4.37.1
4545
with:
4646
category: "/language:${{ matrix.language }}"

.github/workflows/maven.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
with:
2020
persist-credentials: false
2121
- name: Set up JDK
22-
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
22+
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0
2323
with:
2424
distribution: temurin
2525
java-version: 21
@@ -49,7 +49,7 @@ jobs:
4949
with:
5050
persist-credentials: false
5151
- name: Set up JDK
52-
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
52+
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0
5353
with:
5454
distribution: temurin
5555
java-version: 21
@@ -60,6 +60,9 @@ jobs:
6060
verify:
6161
name: Maven Verify (JDK ${{ matrix.java }})
6262
runs-on: ubuntu-latest
63+
permissions:
64+
contents: read
65+
id-token: write
6366
strategy:
6467
fail-fast: false
6568
matrix:
@@ -71,7 +74,7 @@ jobs:
7174
with:
7275
persist-credentials: false
7376
- name: Set up JDK
74-
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
77+
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0
7578
with:
7679
distribution: temurin
7780
java-version: ${{ matrix.java }}
@@ -99,5 +102,6 @@ jobs:
99102
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
100103
with:
101104
files: target/site/jacoco/jacoco.xml
102-
fail_ci_if_error: false
105+
use_oidc: true
106+
fail_ci_if_error: true
103107
verbose: true

.github/workflows/quality.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
with:
2020
persist-credentials: false
2121
- name: Set up JDK
22-
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
22+
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0
2323
with:
2424
distribution: temurin
2525
java-version: 21
@@ -44,3 +44,27 @@ jobs:
4444
name: spotbugs-report
4545
path: target/spotbugsXml.xml
4646
if-no-files-found: ignore
47+
48+
sonarcloud:
49+
name: SonarCloud analysis
50+
if: github.actor != 'dependabot[bot]'
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
55+
with:
56+
fetch-depth: 0
57+
persist-credentials: false
58+
- name: Set up JDK
59+
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0
60+
with:
61+
distribution: temurin
62+
java-version: 21
63+
cache: maven
64+
- name: Build and analyze
65+
env:
66+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
67+
run: >-
68+
mvn -B verify sonar:sonar
69+
-Dsonar.qualitygate.wait=true
70+
-Dsonar.qualitygate.timeout=300

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
results_format: sarif
3737
publish_results: true
3838
- name: Upload Scorecard SARIF
39-
uses: github/codeql-action/upload-sarif@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
39+
uses: github/codeql-action/upload-sarif@7188fc363630916deb702c7fdcf4e481b751f97a # v4.37.1
4040
with:
4141
sarif_file: scorecard-results.sarif
4242
- name: Upload Scorecard artifact

README.en.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Curated Java reference implementations for deterministic algorithms and stateful
77
[![CI](https://github.com/krotname/JavaAlgorithmsShowcase/actions/workflows/maven.yml/badge.svg)](https://github.com/krotname/JavaAlgorithmsShowcase/actions/workflows/maven.yml)
88
[![Quality Gates](https://github.com/krotname/JavaAlgorithmsShowcase/actions/workflows/quality.yml/badge.svg)](https://github.com/krotname/JavaAlgorithmsShowcase/actions/workflows/quality.yml)
99
[![CodeQL](https://github.com/krotname/JavaAlgorithmsShowcase/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/krotname/JavaAlgorithmsShowcase/actions/workflows/codeql-analysis.yml)
10+
[![SonarCloud Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=krotname_JavaAlgorithmsShowcase&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=krotname_JavaAlgorithmsShowcase)
1011
[![Coverage](https://codecov.io/gh/krotname/JavaAlgorithmsShowcase/branch/main/graph/badge.svg)](https://app.codecov.io/gh/krotname/JavaAlgorithmsShowcase)
1112
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/krotname/JavaAlgorithmsShowcase/badge)](https://securityscorecards.dev/viewer/?uri=github.com/krotname/JavaAlgorithmsShowcase)
1213
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/13151/badge)](https://www.bestpractices.dev/projects/13151)
@@ -21,8 +22,8 @@ Curated Java reference implementations for deterministic algorithms and stateful
2122

2223
| Component | Engineering problem | What it demonstrates |
2324
| --- | --- | --- |
24-
| [Transaction validation](src/main/java/transactions) | Ordered, stateful operations; cascading invalidation; balance and overflow boundaries | Deterministic state transitions, immutable results, integration scenarios |
25-
| [Algorithm utilities](src/main/java/algorithms) | Boundary conditions, complexity, stream and file I/O | Deterministic APIs, explicit complexity tradeoffs, edge cases, and property-based invariants |
25+
| [Transaction validation](src/main/java/transactions) | Ordered, stateful operations; cascading invalidation; balance and overflow boundaries | Deterministic state transitions, immutable results, integration and property-based tests |
26+
| [Algorithm utilities](src/main/java/algorithms) | Boundary conditions, complexity, stream and file I/O | Deterministic APIs, explicit complexity tradeoffs, and edge cases |
2627
| [Parsing / validation](src/main/java/common/SafeParse.java) | Malformed numeric and text input | Explicit contracts, preserved exception causality, unit tests, and static analysis |
2728

2829
This is an engineering demonstration repository, not a commercial product. Implementations are selected to make code quality, test strategy, and the development process directly reviewable.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Curated Java reference implementations for deterministic algorithms and stateful
77
[![CI](https://github.com/krotname/JavaAlgorithmsShowcase/actions/workflows/maven.yml/badge.svg)](https://github.com/krotname/JavaAlgorithmsShowcase/actions/workflows/maven.yml)
88
[![Quality Gates](https://github.com/krotname/JavaAlgorithmsShowcase/actions/workflows/quality.yml/badge.svg)](https://github.com/krotname/JavaAlgorithmsShowcase/actions/workflows/quality.yml)
99
[![CodeQL](https://github.com/krotname/JavaAlgorithmsShowcase/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/krotname/JavaAlgorithmsShowcase/actions/workflows/codeql-analysis.yml)
10+
[![SonarCloud Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=krotname_JavaAlgorithmsShowcase&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=krotname_JavaAlgorithmsShowcase)
1011
[![Coverage](https://codecov.io/gh/krotname/JavaAlgorithmsShowcase/branch/main/graph/badge.svg)](https://app.codecov.io/gh/krotname/JavaAlgorithmsShowcase)
1112
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/krotname/JavaAlgorithmsShowcase/badge)](https://securityscorecards.dev/viewer/?uri=github.com/krotname/JavaAlgorithmsShowcase)
1213
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/13151/badge)](https://www.bestpractices.dev/projects/13151)
@@ -21,8 +22,8 @@ Curated Java reference implementations for deterministic algorithms and stateful
2122

2223
| Компонент | Инженерная задача | Что демонстрирует |
2324
| --- | --- | --- |
24-
| [Transaction validation](src/main/java/transactions) | Порядок и состояние операций, каскадная невалидность, баланс и переполнение | Детерминированные переходы состояния, неизменяемый результат, интеграционные сценарии |
25-
| [Algorithm utilities](src/main/java/algorithms) | Граничные условия, сложность, поточный и файловый ввод-вывод | Детерминированные API, явные компромиссы по сложности, edge cases и property-based инварианты |
25+
| [Transaction validation](src/main/java/transactions) | Порядок и состояние операций, каскадная невалидность, баланс и переполнение | Детерминированные переходы состояния, неизменяемый результат, интеграционные и property-based тесты |
26+
| [Algorithm utilities](src/main/java/algorithms) | Граничные условия, сложность, поточный и файловый ввод-вывод | Детерминированные API, явные компромиссы по сложности и edge cases |
2627
| [Parsing / validation](src/main/java/common/SafeParse.java) | Некорректный числовой и текстовый ввод | Явные контракты, сохранение причины исключения, unit-тесты и статический анализ |
2728

2829
Это демонстрационный инженерный репозиторий, а не коммерческий продукт. Реализации отобраны так, чтобы на ревью были видны качество кода, тестовая стратегия и воспроизводимый процесс разработки.

pom.xml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@
2020
<jacoco.version>0.8.15</jacoco.version>
2121
<checkstyle.version>3.6.0</checkstyle.version>
2222
<pmd.version>3.28.0</pmd.version>
23-
<spotbugs.maven.version>4.9.8.5</spotbugs.maven.version>
23+
<spotbugs.maven.version>4.10.3.0</spotbugs.maven.version>
24+
<sonar.maven.version>5.7.0.6970</sonar.maven.version>
2425
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
25-
<junit.version>6.1.1</junit.version>
26+
<junit.version>6.1.2</junit.version>
2627
<assertj.version>3.27.7</assertj.version>
2728
<jqwik.version>1.10.1</jqwik.version>
28-
<junit.platform.version>6.1.1</junit.platform.version>
29+
<junit.platform.version>6.1.2</junit.platform.version>
2930
<lombok.version>1.18.46</lombok.version>
31+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
32+
<sonar.organization>krotname</sonar.organization>
33+
<sonar.projectKey>krotname_JavaAlgorithmsShowcase</sonar.projectKey>
34+
<sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
3035
<coverage.line.minimum>0.70</coverage.line.minimum>
3136
<coverage.branch.minimum>0.70</coverage.branch.minimum>
3237
<coverage.instruction.minimum>0.70</coverage.instruction.minimum>
@@ -233,6 +238,12 @@
233238
</execution>
234239
</executions>
235240
</plugin>
241+
242+
<plugin>
243+
<groupId>org.sonarsource.scanner.maven</groupId>
244+
<artifactId>sonar-maven-plugin</artifactId>
245+
<version>${sonar.maven.version}</version>
246+
</plugin>
236247
</plugins>
237248
</build>
238249

src/main/java/interview/CallbackScheduler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Класс CallbackSchedulerImpl планирует исполнение Runnable в заданный момент времени.
1515
* Задачи делегируются ScheduledExecutorService, чтобы не держать отдельный ручной worker-loop.
1616
*/
17-
public class CallbackScheduler implements AutoCloseable {
17+
public final class CallbackScheduler implements AutoCloseable {
1818

1919
private final ScheduledExecutorService scheduler;
2020

src/main/java/kyu6/TribonacciSequence.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44

55
public class TribonacciSequence {
66

7+
private static final int SIGNATURE_SIZE = 3;
8+
79
//6 https://www.codewars.com/kata/556deca17c58da83c00002db
810

911
public static double[] tribonacci(double[] s, int n) {
10-
if (s == null || s.length != 3) {
12+
if (s == null || s.length != SIGNATURE_SIZE) {
1113
throw new IllegalArgumentException("signature must contain exactly three values");
1214
}
1315
if (n < 0) {
1416
throw new IllegalArgumentException("sequence length must not be negative");
1517
}
1618
double[] result = new double[n];
17-
int signatureLength = Math.min(s.length, n);
19+
int signatureLength = Math.min(SIGNATURE_SIZE, n);
1820
System.arraycopy(s, 0, result, 0, signatureLength);
19-
for (int i = s.length; i < n; i++) {
21+
for (int i = SIGNATURE_SIZE; i < n; i++) {
2022
result[i] = result[i - 1] + result[i - 2] + result[i - 3];
2123
}
2224
return result;
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package transactions;
22

3-
import lombok.Getter;
4-
3+
import java.util.ArrayList;
4+
import java.util.Collections;
55
import java.util.List;
66

7-
@Getter
87
final class ValidationResult {
98
private final List<TransactionStatus> transactions;
109

@@ -15,4 +14,8 @@ public ValidationResult(List<TransactionStatus> transactions) {
1514
public static ValidationResult empty() {
1615
return new ValidationResult(List.of());
1716
}
17+
18+
public List<TransactionStatus> getTransactions() {
19+
return Collections.unmodifiableList(new ArrayList<>(transactions));
20+
}
1821
}

0 commit comments

Comments
 (0)