forked from opensearch-project/opensearch-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkstyle.xml
156 lines (131 loc) · 6.12 KB
/
checkstyle.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?xml version="1.0"?>
<!--
~ SPDX-License-Identifier: Apache-2.0
~ The OpenSearch Contributors require contributions made to
~ this file be licensed under the Apache-2.0 license or a
~ compatible open source license.
-->
<!--
~ Licensed to Elasticsearch B.V. under one or more contributor
~ license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright
~ ownership. Elasticsearch B.V. licenses this file to you under
~ the Apache License, Version 2.0 (the "License"); you may
~ not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<!--
~ Modifications Copyright OpenSearch Contributors. See
~ GitHub history for details.
-->
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8" />
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/checkstyle_suppressions.xml" />
</module>
<module name="Header">
<property name="headerFile" value="${config_loc}/header.java.txt"/>
<property name="fileExtensions" value="java,kt,kts"/>
</module>
<module name="SuppressWarningsFilter" />
<!-- Checks Java files and forbids empty Javadoc comments. -->
<!-- Although you can use the "JavadocStyle" rule for this, it considers Javadoc -->
<!-- that only contains a "@return" line to be empty. -->
<!--
<module name="RegexpMultiline">
<property name="id" value="EmptyJavadoc" />
<property name="format" value="\/\*[\s\*]*\*\/" />
<property name="fileExtensions" value="java" />
<property name="message" value="Empty javadoc comments are forbidden" />
</module>
-->
<!-- Its our official line length! See checkstyle_suppressions.xml for the files that don't pass this. For now we
suppress the check there but enforce it everywhere else. This prevents the list from getting longer even if it is
unfair. -->
<module name="LineLength">
<property name="max" value="140" />
<property name="ignorePattern" value="^ *\* *https?://[^ ]+$" />
</module>
<module name="TreeWalker">
<!-- Make the @SuppressWarnings annotations available to Checkstyle -->
<module name="SuppressWarningsHolder" />
<module name="AvoidStarImport" />
<!-- Unused imports are forbidden -->
<module name="UnusedImports" />
<!-- Non-inner classes must be in files that match their names. -->
<module name="OuterTypeFilename" />
<!-- No line wraps inside of import and package statements. -->
<module name="NoLineWrap" />
<!-- only one statement per line should be allowed -->
<module name="OneStatementPerLine" />
<!-- Each java file has only one outer class -->
<module name="OneTopLevelClass" />
<!-- The suffix L is preferred, because the letter l (ell) is often
hard to distinguish from the digit 1 (one). -->
<module name="UpperEll" />
<module name="EqualsHashCode" />
<!-- Checks that the order of modifiers conforms to the suggestions in the
Java Language specification, sections 8.1.1, 8.3.1 and 8.4.3. It is not that
the standard is perfect, but having a consistent order makes the code more
readable and no other order is compellingly better than the standard.
The correct order is:
public
protected
private
abstract
static
final
transient
volatile
synchronized
native
strictfp
-->
<module name="ModifierOrder" />
<!-- Checks that we don't include modifier where they are implied. For
example, this does not allow interface methods to be declared public
because they are *always* public. -->
<module name="RedundantModifier" />
<!-- Checks that all java files have a package declaration and that it
lines up with the directory structure. -->
<module name="PackageDeclaration" />
<!-- We don't use Java's builtin serialization and we suppress all warning
about it. The flip side of that coin is that we shouldn't _try_ to use
it. We can't outright ban it with ForbiddenApis because it complain about
every we reference a class that implements Serializable like String or
Exception.
-->
<module name="RegexpSinglelineJava">
<property name="format" value="serialVersionUID" />
<property name="message" value="Do not declare serialVersionUID." />
<property name="ignoreComments" value="true" />
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="java\.io\.Serializable;" />
<property name="message" value="References java.io.Serializable." />
<property name="ignoreComments" value="true" />
</module>
<!-- end Orwellian suppression of Serializable -->
<!-- Forbid equality comparisons with `true` -->
<module name="DescendantToken">
<property name="id" value="EqualityWithTrue" />
<property name="tokens" value="EQUAL" />
<property name="limitedTokens" value="LITERAL_TRUE" />
<property name="maximumNumber" value="0" />
<property name="maximumDepth" value="1" />
<message key="descendant.token.max" value="Do not check for equality with 'true', since it is implied" />
</module>
</module>
</module>