Skip to content

Commit 3769005

Browse files
Stypoxlitetex
authored andcommitted
Add checkstyle to extractor gradle project
With respect to NewPipe's checkstyle.xml, checkstyle is disabled for javadoc comments. There is no need for strict rules over comments here in the extractor, as sometimes javadocs are just needed to clarify a small thing and having empty/meaningless @param or @throws is useless.
1 parent 9284569 commit 3769005

3 files changed

Lines changed: 209 additions & 1 deletion

File tree

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ allprojects {
3030
nanojsonVersion = "1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751"
3131
spotbugsVersion = "4.6.0"
3232
junitVersion = "5.8.2"
33+
checkstyleVersion = "9.3" // do not use latest version (10.0) as it requires compile SDK 11
3334
}
3435
}
3536

checkstyle/checkstyle.xml

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
<module name="Checker">
6+
<!--
7+
If you set the basedir property below, then all reported file
8+
names will be relative to the specified directory. See
9+
https://checkstyle.org/5.x/config.html#Checker
10+
11+
<property name="basedir" value="${basedir}"/>
12+
-->
13+
<property name="severity" value="error"/>
14+
15+
<property name="fileExtensions" value="java, properties, xml"/>
16+
17+
<!-- Excludes all 'module-info.java' files -->
18+
<!-- See https://checkstyle.org/config_filefilters.html -->
19+
<module name="BeforeExecutionExclusionFileFilter">
20+
<property name="fileNamePattern" value="module\-info\.java$"/>
21+
</module>
22+
23+
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
24+
<module name="SuppressionFilter">
25+
<property name="file" value="${config_loc}/suppressions.xml" />
26+
<property name="optional" value="true"/>
27+
</module>
28+
29+
<!-- Checks that a package-info.java file exists for each package. -->
30+
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
31+
<!--<module name="JavadocPackage"/>-->
32+
33+
<!-- Checks whether files end with a new line. -->
34+
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
35+
<module name="NewlineAtEndOfFile"/>
36+
37+
<!-- Checks that property files contain the same keys. -->
38+
<!-- See https://checkstyle.org/config_misc.html#Translation -->
39+
<module name="Translation"/>
40+
41+
<!-- Checks for Size Violations. -->
42+
<!-- See https://checkstyle.org/config_sizes.html -->
43+
<module name="FileLength"/>
44+
<module name="LineLength">
45+
<property name="max" value="100"/>
46+
<property name="fileExtensions" value="java"/>
47+
</module>
48+
49+
<!-- Checks for whitespace -->
50+
<!-- See https://checkstyle.org/config_whitespace.html -->
51+
<module name="FileTabCharacter"/>
52+
53+
<!-- Miscellaneous other checks. -->
54+
<!-- See https://checkstyle.org/config_misc.html -->
55+
<module name="RegexpSingleline">
56+
<property name="format" value="\s+$"/>
57+
<property name="minimum" value="0"/>
58+
<property name="maximum" value="0"/>
59+
<property name="message" value="Line has trailing spaces."/>
60+
</module>
61+
62+
<!-- Checks for Headers -->
63+
<!-- See https://checkstyle.org/config_header.html -->
64+
<!-- <module name="Header"> -->
65+
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
66+
<!-- <property name="fileExtensions" value="java"/> -->
67+
<!-- </module> -->
68+
69+
<module name="SuppressWarningsFilter" />
70+
71+
<module name="TreeWalker">
72+
<!-- Checks for Javadoc comments. -->
73+
<!-- See https://checkstyle.org/config_javadoc.html -->
74+
<module name="InvalidJavadocPosition"/>
75+
<module name="JavadocMethod">
76+
<property name="allowMissingParamTags" value="true"/>
77+
<property name="allowMissingReturnTag" value="true"/>
78+
</module>
79+
<module name="JavadocType"/>
80+
<!--<module name="JavadocVariable"/>-->
81+
<module name="JavadocStyle">
82+
<property name="checkFirstSentence" value="false"/>
83+
</module>
84+
<!--<module name="MissingJavadocMethod"/>-->
85+
86+
<!-- Checks for Naming Conventions. -->
87+
<!-- See https://checkstyle.org/config_naming.html -->
88+
<module name="ConstantName"/>
89+
<module name="LocalFinalVariableName"/>
90+
<module name="LocalVariableName"/>
91+
<module name="MemberName">
92+
<property name="format" value="^(TAG|DEBUG|[a-z][a-zA-Z0-9]*)$"/>
93+
</module>
94+
<module name="MethodName"/>
95+
<module name="PackageName"/>
96+
<module name="ParameterName"/>
97+
<module name="StaticVariableName"/>
98+
<module name="TypeName"/>
99+
100+
<!-- Checks for imports -->
101+
<!-- See https://checkstyle.org/config_import.html -->
102+
<module name="AvoidStarImport"/>
103+
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
104+
<module name="RedundantImport"/>
105+
<module name="UnusedImports"/>
106+
107+
<!-- Checks for Size Violations. -->
108+
<!-- See https://checkstyle.org/config_sizes.html -->
109+
<module name="MethodLength">
110+
<property name="severity" value="warning"/>
111+
</module>
112+
<module name="ParameterNumber">
113+
<property name="severity" value="warning"/>
114+
</module>
115+
116+
<!-- Checks for whitespace -->
117+
<!-- See https://checkstyle.org/config_whitespace.html -->
118+
<module name="EmptyForIteratorPad"/>
119+
<module name="GenericWhitespace"/>
120+
<module name="MethodParamPad"/>
121+
<module name="NoWhitespaceAfter"/>
122+
<module name="NoWhitespaceBefore"/>
123+
<module name="OperatorWrap"/>
124+
<module name="ParenPad"/>
125+
<module name="TypecastParenPad"/>
126+
<module name="WhitespaceAfter"/>
127+
<module name="WhitespaceAround"/>
128+
129+
<!-- Modifier Checks -->
130+
<!-- See https://checkstyle.org/config_modifiers.html -->
131+
<module name="ModifierOrder"/>
132+
<module name="RedundantModifier"/>
133+
134+
<!-- Checks for blocks. You know, those {}'s -->
135+
<!-- See https://checkstyle.org/config_blocks.html -->
136+
<module name="AvoidNestedBlocks"/>
137+
<module name="EmptyBlock"/>
138+
<module name="LeftCurly"/>
139+
<module name="NeedBraces"/>
140+
<module name="RightCurly"/>
141+
142+
<!-- Checks for common coding problems -->
143+
<!-- See https://checkstyle.org/config_coding.html -->
144+
<module name="EmptyStatement"/>
145+
<module name="EqualsHashCode">
146+
<property name="severity" value="warning"/>
147+
</module>
148+
<module name="HiddenField">
149+
<property name="ignoreConstructorParameter" value="true"/>
150+
<property name="ignoreSetter" value="true"/>
151+
</module>
152+
<module name="IllegalInstantiation"/>
153+
<module name="InnerAssignment"/>
154+
<!--<module name="MagicNumber"/>-->
155+
<!--<module name="MissingSwitchDefault">
156+
<property name="severity" value="warning"/>
157+
</module>-->
158+
<module name="MultipleVariableDeclarations"/>
159+
<module name="SimplifyBooleanExpression"/>
160+
<module name="SimplifyBooleanReturn"/>
161+
<module name="FinalLocalVariable">
162+
<property name="tokens" value="VARIABLE_DEF,PARAMETER_DEF"/>
163+
<property name="validateEnhancedForLoopVariable" value="true"/>
164+
</module>
165+
166+
<!-- Checks for class design -->
167+
<!-- See https://checkstyle.org/config_design.html -->
168+
<!--<module name="DesignForExtension"/>-->
169+
<module name="FinalClass"/>
170+
<module name="HideUtilityClassConstructor"/>
171+
<module name="InterfaceIsType"/>
172+
<!--<module name="VisibilityModifier">
173+
<property name="ignoreAnnotationCanonicalNames" value="State,ColumnInfo"/>
174+
<property name="severity" value="warning"/>
175+
</module>-->
176+
177+
<!-- Miscellaneous other checks. -->
178+
<!-- See https://checkstyle.org/config_misc.html -->
179+
<module name="ArrayTypeStyle"/>
180+
<module name="FinalParameters"/>
181+
<!--<module name="TodoComment">
182+
<property name="format" value="(TODO:|FIXME:)"/>
183+
<property name="severity" value="warning"/>
184+
</module>-->
185+
<module name="UpperEll"/>
186+
187+
<module name="SuppressWarningsHolder" />
188+
</module>
189+
</module>

extractor/build.gradle

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
plugins {
2+
id 'checkstyle'
3+
}
4+
15
test {
2-
// Pass on downloader type to tests for different CI jobs. See DownloaderFactory.java and ci.yml
6+
// Pass on downloader type to tests for different CI jobs. See DownloaderFactory.java and ci.yml
37
if (System.properties.containsKey('downloader')) {
48
systemProperty('downloader', System.getProperty('downloader'))
59
}
610
useJUnitPlatform()
11+
dependsOn checkstyleMain // run checkstyle when testing
12+
}
13+
14+
checkstyle {
15+
getConfigDirectory().set(rootProject.file("checkstyle"))
16+
ignoreFailures false
17+
showViolations true
18+
toolVersion checkstyleVersion
19+
}
20+
21+
checkstyleTest {
22+
enabled false // do not checkstyle test files
723
}
824

925
dependencies {
@@ -15,6 +31,8 @@ dependencies {
1531
implementation "com.github.spotbugs:spotbugs-annotations:$spotbugsVersion"
1632
implementation 'org.nibor.autolink:autolink:0.10.0'
1733

34+
checkstyle "com.puppycrawl.tools:checkstyle:$checkstyleVersion"
35+
1836
testImplementation platform("org.junit:junit-bom:$junitVersion")
1937
testImplementation 'org.junit.jupiter:junit-jupiter-api'
2038
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'

0 commit comments

Comments
 (0)