Skip to content

Commit 5064a34

Browse files
author
Maksim Zinal
committed
refactored to support ydb coding style
1 parent 63b396c commit 5064a34

Some content is hidden

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

43 files changed

+1130
-597
lines changed

config/ydb.checkstyle.xml

+249
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
4+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
5+
6+
<module name="Checker">
7+
8+
<property name="charset" value="UTF-8"/>
9+
10+
<!-- Checks whether files end with a new line. -->
11+
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
12+
<module name="NewlineAtEndOfFile">
13+
<!--Checkstyle 8.17 had bug with lineSeparator, after update to 8.36 it fails of CRLF-->
14+
<property name="lineSeparator" value="lf_cr_crlf"/>
15+
</module>
16+
17+
<!-- File length should be less than 2000 lines. -->
18+
<!-- See http://checkstyle.sourceforge.net/config_sizes.html#FileLength -->
19+
<module name="FileLength"/>
20+
21+
<!-- Whitespaces are used for indents. -->
22+
<!-- See http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter -->
23+
<module name="FileTabCharacter">
24+
<property name="eachLine" value="true"/>
25+
</module>
26+
27+
<!-- Trailing spaces are prohibited. -->
28+
<!-- See http://checkstyle.sf.net/config_misc.html -->
29+
<module name="RegexpSingleline">
30+
<property name="format" value="\s+$"/>
31+
<property name="minimum" value="0"/>
32+
<property name="maximum" value="0"/>
33+
<property name="message" value="Line has trailing spaces."/>
34+
</module>
35+
36+
<!-- Checkstyle can be disabled code between comments CHECKSTYLE:OFF and CHECKSTYLE:ON -->
37+
<!-- See https://checkstyle.sourceforge.io/config_filters.html#SuppressWithPlainTextCommentFilter -->
38+
<module name="SuppressWithPlainTextCommentFilter">
39+
<!-- Allow absent space between // and CHECKSTYLE-->
40+
<property name="offCommentFormat" value="// *CHECKSTYLE:OFF"/>
41+
<property name="onCommentFormat" value="// *CHECKSTYLE:ON"/>
42+
</module>
43+
44+
<!-- Checks can be disabled using @SuppressWarnings annotation. -->
45+
<!-- See http://checkstyle.sourceforge.net/config_filters.html#SuppressWarningsFilter -->
46+
<module name="SuppressWarningsFilter"/>
47+
48+
<!-- Sets max length of one line to 120 symbols. See https://clubs.at.yandex-team.ru/java/593 for more details -->
49+
<!-- See http://checkstyle.sourceforge.net/config_sizes.html#LineLength -->
50+
<module name="LineLength">
51+
<property name="max" value="120"/>
52+
<!-- Checkstyle 8.24 moves LineLength out of TreeWalker and javadoc comments need to be excluded explicitly-->
53+
<property name="ignorePattern" value="^( *\*|package|import) *.+$"/>
54+
</module>
55+
56+
<module name="TreeWalker">
57+
<!-- Checkstyle can be disabled code between comments CHECKSTYLE:OFF and CHECKSTYLE:ON -->
58+
<!-- See http://checkstyle.sourceforge.net/config_filters.html#SuppressionCommentFilter -->
59+
<module name="SuppressionCommentFilter"/>
60+
<!-- Checkstyle can be disabled using @SuppressWarnings annotation -->
61+
<!-- See http://checkstyle.sourceforge.net/config_filters.html#SuppressWarningsFilter -->
62+
<module name="SuppressWarningsHolder"/>
63+
64+
<!--
65+
Check for public static final aka constants naming.
66+
Allows only upper case letters, numbers and underscores in variable names.
67+
The only exceptions are "logger", "log", "*Log", "*Logger" variable names.
68+
-->
69+
<!-- See http://checkstyle.sourceforge.net/config_naming.html#ConstantName -->
70+
<module name="ConstantName">
71+
<property name="format"
72+
value="^(([A-Z][A-Z0-9]*(_[A-Z0-9]+)*)|(logger)|(log)|([a-z][a-zA-Z0-9]*Log)|([a-z][a-zA-Z0-9]*Logger))$"/>
73+
<message key="сonstantName.invalidPattern"
74+
value="Member ''{0}'' must be UPPERCASE_WITH_UNDERSCORE, except it a logger name (checked pattern ''{1}'')." />
75+
</module>
76+
77+
<!--
78+
Standard java naming convention rules i. e. camel case variables, no underscore and camel case in package
79+
names, type names starting from upper letter etc.
80+
-->
81+
<!-- See http://checkstyle.sourceforge.net/config_naming.html -->
82+
<module name="LocalFinalVariableName"/>
83+
<module name="LocalVariableName"/>
84+
<module name="MemberName"/>
85+
<module name="MethodName"/>
86+
<module name="PackageName"/>
87+
<module name="ParameterName"/>
88+
<module name="StaticVariableName"/>
89+
<module name="TypeName"/>
90+
91+
<!--
92+
Main purpose is to forbid unused imports in code as it complicates code usage search in code search.
93+
-->
94+
<!-- See http://checkstyle.sourceforge.net/config_imports.html#UnusedImports -->
95+
<module name="RedundantImport"/>
96+
<module name="UnusedImports">
97+
<property name="processJavadoc" value="true"/>
98+
</module>
99+
100+
<!-- Sets max method length to 150 lines. -->
101+
<!-- See http://checkstyle.sourceforge.net/config_sizes.html#MethodLength -->
102+
<module name="MethodLength"/>
103+
104+
<!--
105+
Sets max method parameters number to 7. If you need more parameters for method, you have two options:
106+
- refactor you code (recommended)
107+
- use one of suppression methods (i. e. @SuppressWarnings annotation)
108+
-->
109+
<!-- See http://checkstyle.sourceforge.net/config_sizes.html#ParameterNumber -->
110+
<module name="ParameterNumber"/>
111+
112+
<!-- Checks for default java formatting which is fully compliant with default Intellij Idea settings. -->
113+
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
114+
<module name="GenericWhitespace"/>
115+
<module name="MethodParamPad"/>
116+
<module name="NoWhitespaceAfter"/>
117+
<module name="NoWhitespaceBefore"/>
118+
<module name="ParenPad"/>
119+
<module name="TypecastParenPad"/>
120+
<module name="WhitespaceAfter"/>
121+
<module name="WhitespaceAround"/>
122+
123+
<!-- Checks that modifiers follow certain order for the sake of code consistency. -->
124+
<!-- See http://checkstyle.sourceforge.net/config_modifier.html#ModifierOrder -->
125+
<module name="ModifierOrder"/>
126+
127+
<!-- Checks that redundant modifiers are not specified. -->
128+
<!-- See http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier -->
129+
<module name="RedundantModifier"/>
130+
131+
<!-- Nested blocks in java have no meaning and only add confusion. Example: -->
132+
<!-- void foo() { -->
133+
<!-- someCode(); -->
134+
<!-- { -->
135+
<!-- nestedBlockCode(); -->
136+
<!-- } -->
137+
<!-- evenMoreCode(); -->
138+
<!-- } -->
139+
<!-- See http://checkstyle.sf.net/config_blocks.html -->
140+
<module name="AvoidNestedBlocks">
141+
<property name="allowInSwitchCase" value="true"/>
142+
</module>
143+
144+
<!-- Empty blocks for specified tokens are suspicious and should not be used. -->
145+
<!-- See http://checkstyle.sourceforge.net/config_blocks.html#EmptyBlock -->
146+
<module name="EmptyBlock">
147+
<property name="tokens" value="LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_IF,LITERAL_FOR,
148+
LITERAL_TRY,LITERAL_WHILE,INSTANCE_INIT,STATIC_INIT"/>
149+
</module>
150+
151+
<!-- Blocks without braces are not allowed (one line lambdas are ok) as they are error prone. -->
152+
<module name="LeftCurly"/>
153+
<module name="NeedBraces"/>
154+
<module name="RightCurly"/>
155+
156+
<!-- Checks for common coding problems -->
157+
<!-- See http://checkstyle.sf.net/config_coding.html -->
158+
<module name="DeclarationOrder">
159+
<property name="ignoreModifiers" value="true"/>
160+
</module>
161+
162+
<!-- ; without any actual statement is not allowed. -->
163+
<module name="EmptyStatement"/>
164+
165+
<!-- Checks that classes either implement both equals and hashCode or none of them -->
166+
<!-- See http://checkstyle.sourceforge.net/config_coding.html#EqualsHashCode -->
167+
<module name="EqualsHashCode"/>
168+
169+
<!-- Forbids hiding of fields. -->
170+
<!-- See http://checkstyle.sourceforge.net/config_coding.html#HiddenField -->
171+
<module name="HiddenField">
172+
<property name="tokens" value="VARIABLE_DEF"/>
173+
</module>
174+
175+
<!-- Detects missing default branch for switch expressions. -->
176+
<!-- See http://checkstyle.sourceforge.net/config_coding.html#MissingSwitchDefault -->
177+
<module name="MissingSwitchDefault"/>
178+
179+
<!-- Some checks for simplification of boolean expression. See links bellow for examples. -->
180+
<!-- http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanExpression -->
181+
<module name="SimplifyBooleanExpression"/>
182+
<!-- http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanReturn -->
183+
<module name="SimplifyBooleanReturn"/>
184+
185+
<!-- Multiple variables declarations, i. e. int a, b = 42 are forbidden as they are error prone. -->
186+
<!-- See http://checkstyle.sourceforge.net/config_coding.html#MultipleVariableDeclarations -->
187+
<module name="MultipleVariableDeclarations"/>
188+
189+
<!-- Only one statement per line is allowed. -->
190+
<!-- See http://checkstyle.sourceforge.net/config_coding.html#OneStatementPerLine -->
191+
<module name="OneStatementPerLine"/>
192+
193+
<!-- Classes with only static members require private constructor to avoid improper usage. -->
194+
<!-- See http://checkstyle.sourceforge.net/config_design.html#HideUtilityClassConstructor -->
195+
<module name="HideUtilityClassConstructor"/>
196+
<module name="SuppressionXpathSingleFilter">
197+
<property name="checks" value="HideUtilityClassConstructor"/>
198+
<property name="query" value="//*[MODIFIERS//*[@text = 'UtilityClass' or @text='NoArgsConstructor' or @text = 'SpringBootApplication']]/descendant-or-self::node()"/>
199+
</module>
200+
201+
<!-- Restriction for declaring visibility modifiers for class fields. -->
202+
<!-- See http://checkstyle.sourceforge.net/config_design.html#VisibilityModifier -->
203+
<module name="VisibilityModifier">
204+
<property name="packageAllowed" value="true"/>
205+
<property name="protectedAllowed" value="true"/>
206+
</module>
207+
208+
<!-- Check for java-style enum declarations. Is required for the sake of consistency. -->
209+
<!-- Example: String[] args -->
210+
<!-- See http://checkstyle.sourceforge.net/config_misc.html#ArrayTypeStyle -->
211+
<module name="ArrayTypeStyle"/>
212+
213+
<!-- Checks that long constants don't use lower l to mark variable as long. -->
214+
<!-- See Puzzle 11: The Last Laugh for explanation -->
215+
<!-- See http://checkstyle.sourceforge.net/config_misc.html#UpperEll -->
216+
<module name="UpperEll"/>
217+
218+
<!-- Forbids any kind of * imports. Absence of * imports simplifies code search especially in mono repository. -->
219+
<!-- See http://checkstyle.sourceforge.net/config_imports.html#AvoidStarImport -->
220+
<module name="AvoidStarImport">
221+
<property name="allowClassImports" value="false"/>
222+
<property name="allowStaticMemberImports" value="false"/>
223+
</module>
224+
225+
<!-- Check location of annotation on language elements -->
226+
<!-- See http://checkstyle.sourceforge.net/config_annotation.html#AnnotationLocation -->
227+
<module name="AnnotationLocation">
228+
<property name="allowSamelineMultipleAnnotations" value="false"/>
229+
<property name="allowSamelineSingleParameterlessAnnotation"
230+
value="true"/>
231+
<property name="allowSamelineParameterizedAnnotation" value="true"/>
232+
</module>
233+
234+
<!-- Checks for import order -->
235+
<!-- See http://checkstyle.sf.net/config_imports.html#ImportOrder -->
236+
<module name="ImportOrder">
237+
<property name="groups" value="java,javax,/^(?!ru\.yandex\.)/,yandex,ru.yandex,tech.ydb"/>
238+
<property name="ordered" value="true"/>
239+
<property name="separated" value="true"/>
240+
<property name="option" value="bottom"/>
241+
<property name="sortStaticImportsAlphabetically" value="true"/>
242+
</module>
243+
<module name="SuppressionXpathSingleFilter">
244+
<property name="checks" value="ImportOrder"/>
245+
<property name="message" value="^'ru\.yandex\..*'.*should be separated.*"/>
246+
</module>
247+
248+
</module>
249+
</module>

config/ydb.suppressions.xml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE suppressions PUBLIC
3+
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
4+
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
5+
<suppressions>
6+
<suppress checks="MethodNameCheck|VisibilityModifierCheck" files=".*Test.java"/>
7+
</suppressions>

0 commit comments

Comments
 (0)