Skip to content

Commit 8194026

Browse files
authored
Merge pull request #1 from ArtemGet/qulice
Enabled qulice checkstyle
2 parents 1398e18 + 8a01903 commit 8194026

File tree

20 files changed

+404
-41
lines changed

20 files changed

+404
-41
lines changed

.github/workflows/maven.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
distribution: 'temurin'
2121
cache: maven
2222
- name: Build with Maven
23-
run: mvn clean install --batch-mode --update-snapshots
23+
run: mvn clean install -Pqulice --batch-mode --update-snapshots

src/main/java/io/github/artemget/tagrelease/command/CmdListStand.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*
4343
* @since 0.1.0
4444
*/
45-
public class CmdListStand implements Cmd<Update, AbsSender> {
45+
public final class CmdListStand implements Cmd<Update, AbsSender> {
4646
/**
4747
* Available stands.
4848
*/
@@ -56,22 +56,27 @@ public CmdListStand(final Stands stands) {
5656
this.stands = stands;
5757
}
5858

59+
// @checkstyle IllegalCatchCheck (50 lines)
60+
@SuppressWarnings("PMD.AvoidCatchingGenericException")
5961
@Override
6062
public Send<AbsSender> execute(final Update update) throws CmdException {
6163
final SendMessage message;
6264
try {
6365
message = new SendMessage(
6466
update.getMessage().getChatId().toString(),
65-
new Stand.Text(
67+
new Stand.Printed(
6668
this.stands.stand(
6769
new Trimmed(
6870
new Replaced(
69-
new TextOf(update.getMessage().getText()), "Покажи сервис", "")
71+
new TextOf(update.getMessage().getText()),
72+
"Покажи сервис",
73+
""
74+
)
7075
).asString()
7176
)
7277
).toString()
7378
);
74-
} catch (Exception exception) {
79+
} catch (final Exception exception) {
7580
throw new CmdException(
7681
String.format("Failed to eject value from cmd %s", update.getMessage().getText()),
7782
exception

src/main/java/io/github/artemget/tagrelease/command/CmdListStands.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import io.github.artemget.tagrelease.domain.Stands;
2828
import io.github.artemget.teleroute.command.Cmd;
29-
import io.github.artemget.teleroute.command.CmdException;
3029
import io.github.artemget.teleroute.send.Send;
3130
import io.github.artemget.teleroute.telegrambots.send.SendMessageWrap;
3231
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
@@ -56,7 +55,7 @@ public CmdListStands(final Stands stands) {
5655
public Send<AbsSender> execute(final Update update) {
5756
final SendMessage message = new SendMessage(
5857
update.getMessage().getChatId().toString(),
59-
new Stands.Text(this.stands).toString()
58+
new Stands.Printed(this.stands).toString()
6059
);
6160
message.setReplyToMessageId(update.getMessage().getMessageId());
6261
message.enableMarkdownV2(true);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2024-2025. Artem Getmanskii
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
/**
26+
* Commands directory.
27+
*/
28+
package io.github.artemget.tagrelease.command;

src/main/java/io/github/artemget/tagrelease/domain/Service.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,34 @@
2424

2525
package io.github.artemget.tagrelease.domain;
2626

27+
import io.github.artemget.tagrelease.exception.TagException;
2728
import org.cactoos.Scalar;
2829

30+
/**
31+
* Application's source code in git.
32+
*
33+
* @since 0.1.0
34+
*/
2935
public interface Service {
36+
/**
37+
* Returns application name.
38+
*
39+
* @return Name
40+
*/
3041
String name();
3142

43+
/**
44+
* Returns application's tag.
45+
*
46+
* @return Tag
47+
*/
3248
String tag();
3349

34-
Service tagged(Scalar<String> tag);
50+
/**
51+
* Builds new tag.
52+
*
53+
* @param rule To build tag
54+
* @return Service with a new tag
55+
*/
56+
Service tagged(Scalar<String> rule) throws TagException;
3557
}

src/main/java/io/github/artemget/tagrelease/domain/ServiceGitlabEager.java

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,32 @@
2424

2525
package io.github.artemget.tagrelease.domain;
2626

27+
import io.github.artemget.tagrelease.exception.TagException;
2728
import org.cactoos.Scalar;
2829

29-
public class ServiceGitlabEager implements Service {
30+
/**
31+
* Application's source code in gitlab.
32+
*
33+
* @since 0.1.0
34+
*/
35+
@SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName")
36+
public final class ServiceGitlabEager implements Service {
37+
/**
38+
* Application name.
39+
*/
3040
private final String name;
41+
42+
/**
43+
* Application tag.
44+
*/
3145
private final String tag;
3246

47+
/**
48+
* Main ctor.
49+
*
50+
* @param name Of application
51+
* @param tag Of application
52+
*/
3353
public ServiceGitlabEager(final String name, final String tag) {
3454
this.name = name;
3555
this.tag = tag;
@@ -45,13 +65,17 @@ public String tag() {
4565
return this.tag;
4666
}
4767

68+
// @checkstyle IllegalCatchCheck (50 lines)
69+
@SuppressWarnings("PMD.AvoidCatchingGenericException")
4870
@Override
49-
public Service tagged(Scalar<String> tag) {
50-
//todo: req to gitlab
71+
public Service tagged(final Scalar<String> rule) throws TagException {
5172
try {
52-
return new ServiceGitlabEager(this.name, tag.value());
53-
} catch (Exception exception) {
54-
throw new UnsupportedOperationException(exception);
73+
return new ServiceGitlabEager(this.name, rule.value());
74+
} catch (final Exception exception) {
75+
throw new TagException(
76+
String.format("Failed to create tag for service: %s", this.name),
77+
exception
78+
);
5579
}
5680
}
5781
}

src/main/java/io/github/artemget/tagrelease/domain/Services.java

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,61 @@
2626

2727
import java.util.List;
2828
import java.util.stream.Collectors;
29+
import org.cactoos.Text;
2930

31+
/**
32+
* Applications.
33+
*
34+
* @since 0.1.0
35+
*/
3036
public interface Services {
37+
/**
38+
* Returns all services from stand.
39+
*
40+
* @return Services
41+
*/
3142
List<Service> services();
3243

44+
/**
45+
* Returns service from stand by it's name.
46+
*
47+
* @param name Of service
48+
* @return Service
49+
*/
3350
Service service(String name);
3451

35-
final class Text {
52+
/**
53+
* Printed Services.
54+
* Format: ```java %s:%s```\n
55+
*
56+
* @since 0.1.0
57+
*/
58+
final class Printed implements Text {
59+
/**
60+
* Services.
61+
*/
3662
private final Services services;
3763

38-
public Text(final Services services) {
64+
/**
65+
* Main ctor.
66+
*
67+
* @param services Services
68+
*/
69+
public Printed(final Services services) {
3970
this.services = services;
4071
}
4172

4273
@Override
43-
public String toString() {
74+
public String asString() {
4475
return this.services.services().stream()
45-
.map(service -> String.format("```java %s:%s```\n ", service.name(), service.tag()))
76+
.map(
77+
service ->
78+
String.format(
79+
"```java %s:%s```\n ",
80+
service.name(),
81+
service.tag()
82+
)
83+
)
4684
.collect(Collectors.joining());
4785
}
4886
}

src/main/java/io/github/artemget/tagrelease/domain/ServicesGitlab.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@
2626

2727
import java.util.List;
2828

29-
public class ServicesGitlab implements Services {
29+
/**
30+
* Applications from gitlab.
31+
*
32+
* @since 0.1.0
33+
*/
34+
public final class ServicesGitlab implements Services {
3035
@Override
3136
public List<Service> services() {
3237
throw new UnsupportedOperationException();
3338
}
3439

3540
@Override
36-
public Service service(String name) {
41+
public Service service(final String name) {
3742
throw new UnsupportedOperationException();
3843
}
3944
}

src/main/java/io/github/artemget/tagrelease/domain/Stand.java

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,62 @@
2424

2525
package io.github.artemget.tagrelease.domain;
2626

27+
import org.cactoos.Text;
28+
29+
/**
30+
* Server.
31+
*
32+
* @since 0.1.0
33+
*/
2734
public interface Stand {
35+
/**
36+
* Returns server name.
37+
*
38+
* @return Name
39+
*/
2840
String name();
2941

42+
/**
43+
* Returns server's services.
44+
*
45+
* @return Services
46+
*/
3047
Services services();
3148

32-
final class Text {
49+
/**
50+
* Printed server.
51+
* Format:
52+
* Стенд: %s
53+
* Сервисы:
54+
* %s
55+
*
56+
* @since 0.1.0
57+
*/
58+
final class Printed implements Text {
59+
/**
60+
* Server.
61+
*/
3362
private final Stand stand;
3463

35-
public Text(final Stand stand) {
64+
/**
65+
* Main ctor.
66+
*
67+
* @param stand Stand
68+
*/
69+
public Printed(final Stand stand) {
3670
this.stand = stand;
3771
}
3872

3973
@Override
40-
public String toString() {
74+
public String asString() {
4175
return String.format(
4276
"""
4377
Стенд: %s
4478
Сервисы:
4579
%s
4680
""",
4781
this.stand.name(),
48-
new Services.Text(this.stand.services())
82+
new Services.Printed(this.stand.services())
4983
);
5084
}
5185
}

src/main/java/io/github/artemget/tagrelease/domain/StandGitlab.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424

2525
package io.github.artemget.tagrelease.domain;
2626

27-
public class StandGitlab implements Stand {
27+
/**
28+
* Server at gitlab.
29+
*
30+
* @since 0.1.0
31+
*/
32+
public final class StandGitlab implements Stand {
2833
@Override
2934
public String name() {
3035
throw new UnsupportedOperationException();

0 commit comments

Comments
 (0)