Skip to content

Commit 9ca45de

Browse files
authored
chore: fixes code smells unused checked exceptions, deprecated methods (#353) (#355)
* chore: fixes code smells unused checked exceptions, deprecated methods * ci: fixes secret check * ci: moved secret check to step * ci: fix secret check
1 parent b2ed6be commit 9ca45de

18 files changed

+73
-19
lines changed

.github/workflows/master-2.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jobs:
1010
build-scan:
1111
name: SonarCloud Scan
1212
runs-on: ubuntu-latest
13-
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
1413

1514
steps:
1615
- uses: actions/checkout@v4
@@ -25,6 +24,9 @@ jobs:
2524
cache: maven
2625

2726
- name: Build/Test & SonarCloud Scan
27+
env:
28+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
29+
if: env.SONAR_TOKEN != ''
2830
run: mvn -B clean verify -Pcoverage,sonar -Dsonar.token=${{ secrets.SONAR_TOKEN }}
2931

3032
build-test:
@@ -35,7 +37,6 @@ jobs:
3537
java: ['11', '17', '21']
3638
os: [ubuntu-latest, windows-latest]
3739
runs-on: ${{ matrix.os }}
38-
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
3940

4041
steps:
4142
- uses: actions/checkout@v4

.github/workflows/master.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jobs:
1010
build-scan:
1111
name: SonarCloud Scan
1212
runs-on: ubuntu-latest
13-
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
1413

1514
steps:
1615
- uses: actions/checkout@v4
@@ -25,6 +24,9 @@ jobs:
2524
cache: maven
2625

2726
- name: Build/Test & SonarCloud Scan
27+
env:
28+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
29+
if: env.SONAR_TOKEN != ''
2830
run: mvn -B clean verify -Pcoverage,sonar -Dsonar.token=${{ secrets.SONAR_TOKEN }}
2931

3032
build-test:
@@ -35,7 +37,6 @@ jobs:
3537
java: ['8', '11', '17', '21']
3638
os: [ubuntu-latest, windows-latest]
3739
runs-on: ${{ matrix.os }}
38-
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
3940

4041
steps:
4142
- uses: actions/checkout@v4

.github/workflows/sonar.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Manual SonarCloud Analysis
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
pr_id:
7+
description: 'Pull Request ID to analyze'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
sonar-analysis:
13+
name: SonarCloud Analysis for PR
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Get PR details
18+
id: pr
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
const pr = await github.rest.pulls.get({
23+
owner: context.repo.owner,
24+
repo: context.repo.repo,
25+
pull_number: ${{ inputs.pr_id }}
26+
});
27+
core.setOutput('head_ref', pr.data.head.ref);
28+
core.setOutput('base_ref', pr.data.base.ref);
29+
core.setOutput('head_sha', pr.data.head.sha);
30+
31+
- uses: actions/checkout@v4
32+
with:
33+
ref: ${{ steps.pr.outputs.head_sha }}
34+
fetch-depth: 0
35+
36+
- name: Set up JDK 17
37+
uses: actions/setup-java@v4
38+
with:
39+
java-version: 17
40+
distribution: 'temurin'
41+
cache: maven
42+
43+
- name: Build/Test & SonarCloud Scan
44+
env:
45+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
46+
if: env.SONAR_TOKEN != ''
47+
run: |
48+
mvn -B clean verify -Pcoverage,sonar \
49+
-Dsonar.token=${{ secrets.SONAR_TOKEN }} \
50+
-Dsonar.pullrequest.key=${{ inputs.pr_id }} \
51+
-Dsonar.pullrequest.branch=${{ steps.pr.outputs.head_ref }} \
52+
-Dsonar.pullrequest.base=${{ steps.pr.outputs.base_ref }}

src/main/java/com/github/switcherapi/client/service/validators/DateTimeValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public abstract class DateTimeValidator extends Validator {
1919
protected String getFullDate(final String date) {
2020
SwitcherUtils.debug(logger, LOG_DATE, date);
2121

22-
final String time = RegExUtils.removePattern(date, FULL_DATE_REGEX).trim();
22+
final String time = RegExUtils.removePattern((CharSequence) date, FULL_DATE_REGEX).trim();
2323
return getFullTime(date, time);
2424
}
2525

src/test/java/com/github/switcherapi/client/SwitcherBasicCriteriaResponseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static void setup() throws IOException {
3737
}
3838

3939
@AfterAll
40-
static void tearDown() throws IOException {
40+
static void tearDown() {
4141
MockWebServerHelper.tearDownMockServer();
4242
}
4343

src/test/java/com/github/switcherapi/client/SwitcherBasicTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static void setup() throws IOException {
3535
}
3636

3737
@AfterAll
38-
static void tearDown() throws IOException {
38+
static void tearDown() {
3939
MockWebServerHelper.tearDownMockServer();
4040
}
4141

src/test/java/com/github/switcherapi/client/SwitcherConfigNativeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static void setup() throws IOException {
2020
}
2121

2222
@AfterAll
23-
static void tearDown() throws IOException {
23+
static void tearDown() {
2424
MockWebServerHelper.tearDownMockServer();
2525
}
2626

src/test/java/com/github/switcherapi/client/SwitcherContextRemoteExecutorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static void setup() throws IOException {
2121
}
2222

2323
@AfterAll
24-
static void tearDown() throws IOException {
24+
static void tearDown() {
2525
MockWebServerHelper.tearDownMockServer();
2626
}
2727

src/test/java/com/github/switcherapi/client/SwitcherFail1Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void setup() throws IOException {
2828
}
2929

3030
@AfterAll
31-
static void tearDown() throws IOException {
31+
static void tearDown() {
3232
MockWebServerHelper.tearDownMockServer();
3333

3434
//clean generated outputs

src/test/java/com/github/switcherapi/client/SwitcherFail2Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void setup() throws IOException {
2828
}
2929

3030
@AfterAll
31-
static void tearDown() throws IOException {
31+
static void tearDown() {
3232
MockWebServerHelper.tearDownMockServer();
3333
}
3434

0 commit comments

Comments
 (0)