Skip to content

Commit 1d6b838

Browse files
authored
Improve checkstyle rules with header and unused imports (#504)
* Improve checkstyle rules with header and unused imports * fix order
1 parent dffa48f commit 1d6b838

File tree

220 files changed

+4423
-601
lines changed

Some content is hidden

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

220 files changed

+4423
-601
lines changed

.checkstyle/HEADER

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/

.checkstyle/checkstyle.xml

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,6 @@
22
<!DOCTYPE module PUBLIC
33
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
44
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5-
6-
<!--
7-
Checkstyle configuration that checks the Google coding conventions from Google Java Style
8-
that can be found at https://google.github.io/styleguide/javaguide.html
9-
10-
Checkstyle is very configurable. Be sure to read the documentation at
11-
http://checkstyle.org (or in your downloaded distribution).
12-
13-
To completely disable a check, just comment it out or delete it from the file.
14-
To suppress certain violations please review suppression filters.
15-
16-
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
17-
-->
18-
195
<module name="Checker">
206
<module name="SuppressWarningsFilter"/>
217

@@ -24,20 +10,21 @@
2410
<property name="severity" value="warning"/>
2511

2612
<property name="fileExtensions" value="java, properties, xml"/>
27-
<!-- Excludes all 'module-info.java' files -->
28-
<!-- See https://checkstyle.org/filefilters/index.html -->
13+
14+
<module name="Header">
15+
<property name="headerFile" value="${config_loc}/HEADER"/>
16+
</module>
17+
2918
<module name="BeforeExecutionExclusionFileFilter">
3019
<property name="fileNamePattern" value="module\-info\.java$"/>
3120
</module>
32-
<!-- https://checkstyle.org/filters/suppressionfilter.html -->
21+
3322
<module name="SuppressionFilter">
3423
<property name="file" value="${org.checkstyle.google.suppressionfilter.config}"
3524
default="checkstyle-suppressions.xml"/>
3625
<property name="optional" value="true"/>
3726
</module>
3827

39-
<!-- Checks for whitespace -->
40-
<!-- See http://checkstyle.org/checks/whitespace/index.html -->
4128
<module name="FileTabCharacter">
4229
<property name="eachLine" value="true"/>
4330
</module>
@@ -49,7 +36,15 @@
4936
</module>
5037

5138
<module name="TreeWalker">
39+
<module name="UnusedImports"/>
40+
<module name="RedundantImport"/>
41+
<module name="SimplifyBooleanExpression"/>
42+
<module name="SimplifyBooleanReturn"/>
5243
<module name="OuterTypeFilename"/>
44+
<module name="UnnecessaryParentheses">
45+
<property name="tokens"
46+
value="IDENT, NUM_DOUBLE, LAMBDA, TEXT_BLOCK_LITERAL_BEGIN, UNARY_MINUS, UNARY_PLUS, INC, DEC, POST_INC, POST_DEC"/>
47+
</module>
5348
<module name="IllegalTokenText">
5449
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
5550
<property name="format"
@@ -96,7 +91,7 @@
9691
<property name="tokens"
9792
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT,
9893
INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF, INTERFACE_DEF, RECORD_DEF,
99-
COMPACT_CTOR_DEF"/>
94+
COMPACT_CTOR_DEF, LITERAL_SWITCH"/>
10095
</module>
10196
<module name="SuppressionXpathSingleFilter">
10297
<!-- suppresion is required till https://github.com/checkstyle/checkstyle/issues/7541 -->
@@ -379,4 +374,4 @@
379374
<property name="influenceFormat" value="1"/>
380375
</module>
381376
</module>
382-
</module>
377+
</module>

.github/workflows/hotfix.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99

1010
jobs:
1111
create-branch:
12+
name: Create Branch
1213
runs-on: ubuntu-latest
1314
if: github.ref == 'refs/heads/main'
1415
steps:
@@ -18,7 +19,7 @@ jobs:
1819
fetch-depth: 0
1920
token: ${{ secrets.CI_CD_TOKEN }}
2021

21-
- name: Create hotfix branch
22+
- name: Create branch
2223
run: |
2324
START_TAG=v${{ github.event.inputs.tag_version }}
2425
echo "Start from tag $START_TAG"

.github/workflows/pull_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88

99
jobs:
1010
build:
11+
name: Build
1112
runs-on: ubuntu-latest
1213
steps:
1314
- name: Checkout project

.github/workflows/push_master.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
jobs:
99
build:
10+
name: Build
1011
runs-on: ubuntu-latest
1112
steps:
1213
- name: Docker login

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
jobs:
99
build:
10+
name: Release
1011
runs-on: ubuntu-latest
1112
steps:
1213
- name: Docker login

.github/workflows/tag.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99

1010
jobs:
1111
tag:
12+
name: Tag
1213
runs-on: ubuntu-latest
1314
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/hotfix/v')
1415
steps:

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ test {
126126
}
127127

128128
checkstyle {
129-
toolVersion = '10.12.3'
129+
toolVersion = '10.12.4'
130130
configFile = file(".checkstyle/checkstyle.xml")
131131
ignoreFailures = false
132132
maxErrors = 0
133133
maxWarnings = 0
134+
configDirectory = file(".checkstyle")
134135
}
135136

src/main/java/com/michelin/ns4kafka/Application.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
120
package com.michelin.ns4kafka;
221

322
import io.micronaut.openapi.annotation.OpenAPIInclude;

src/main/java/com/michelin/ns4kafka/controller/AkhqClaimProviderController.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
120
package com.michelin.ns4kafka.controller;
221

322
import com.michelin.ns4kafka.model.AccessControlEntry;

src/main/java/com/michelin/ns4kafka/controller/ApiResourcesController.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
120
package com.michelin.ns4kafka.controller;
221

322
import com.michelin.ns4kafka.repository.RoleBindingRepository;

src/main/java/com/michelin/ns4kafka/controller/ConnectorController.java

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
120
package com.michelin.ns4kafka.controller;
221

322
import static com.michelin.ns4kafka.util.FormatErrorUtils.invalidOwner;
@@ -223,9 +242,9 @@ public Mono<HttpResponse<List<Connector>>> bulkDelete(String namespace,
223242

224243
// Validate ownership
225244
List<String> validationErrors = connectors.stream()
226-
.filter(connector -> !connectorService.isNamespaceOwnerOfConnect(ns, connector.getMetadata().getName()))
227-
.map(connector -> invalidOwner(connector.getMetadata().getName()))
228-
.toList();
245+
.filter(connector -> !connectorService.isNamespaceOwnerOfConnect(ns, connector.getMetadata().getName()))
246+
.map(connector -> invalidOwner(connector.getMetadata().getName()))
247+
.toList();
229248

230249
if (!validationErrors.isEmpty()) {
231250
return Mono.error(new ResourceValidationException(CONNECTOR, name, validationErrors));
@@ -240,11 +259,11 @@ public Mono<HttpResponse<List<Connector>>> bulkDelete(String namespace,
240259
}
241260

242261
return Flux.fromIterable(connectors)
243-
.flatMap(connector -> {
244-
sendEventLog(connector, ApplyStatus.deleted, connector.getSpec(), null, EMPTY_STRING);
245-
return connectorService.delete(ns, connector);
246-
})
247-
.then(Mono.just(HttpResponse.ok(connectors)));
262+
.flatMap(connector -> {
263+
sendEventLog(connector, ApplyStatus.deleted, connector.getSpec(), null, EMPTY_STRING);
264+
return connectorService.delete(ns, connector);
265+
})
266+
.then(Mono.just(HttpResponse.ok(connectors)));
248267
}
249268

250269
/**

src/main/java/com/michelin/ns4kafka/controller/ConsumerGroupController.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
120
package com.michelin.ns4kafka.controller;
221

322
import static com.michelin.ns4kafka.util.FormatErrorUtils.invalidConsumerGroupOperation;

src/main/java/com/michelin/ns4kafka/controller/ExceptionHandlerController.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
120
package com.michelin.ns4kafka.controller;
221

322
import com.michelin.ns4kafka.model.Status;

src/main/java/com/michelin/ns4kafka/controller/NamespaceController.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
120
package com.michelin.ns4kafka.controller;
221

322
import static com.michelin.ns4kafka.util.FormatErrorUtils.invalidImmutableValue;

0 commit comments

Comments
 (0)