mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-09 10:19:41 +02:00
checkstyle: Use $config_loc for Java 11
Also move configuration files into "${rootProject}/config/checkstyle" to follow convention over configuration. See https://github.com/gradle/gradle/issues/8286#issuecomment-458145619
This commit is contained in:
parent
947244b704
commit
cd0cb95ce1
6 changed files with 2 additions and 3 deletions
216
config/checkstyle/checkstyle.xml
Normal file
216
config/checkstyle/checkstyle.xml
Normal file
|
@ -0,0 +1,216 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
<module name="Checker">
|
||||
<module name="SuppressionFilter">
|
||||
<property name="file" value="${config_loc}/suppressions.xml"/>
|
||||
</module>
|
||||
<module name="SuppressWithPlainTextCommentFilter">
|
||||
<property name="offCommentFormat" value="CHECKSTYLE\:OFF\:(\w+)"/>
|
||||
<property name="onCommentFormat" value="CHECKSTYLE\:ON\:(\w+)"/>
|
||||
<property name="checkFormat" value="$1"/>
|
||||
</module>
|
||||
<module name="Header">
|
||||
<property name="headerFile" value="${config_loc}/${checkstyleLicenseHeader}.txt"/>
|
||||
<property name="ignoreLines" value="3"/>
|
||||
<property name="fileExtensions" value="java"/>
|
||||
</module>
|
||||
<module name="NewlineAtEndOfFile">
|
||||
<property name="lineSeparator" value="lf"/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="MXParser"/>
|
||||
<property name="message" value="Must not use MXParser, use XmlPullParserFactory instead"/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<!--
|
||||
Matches StringBuilder.append(String) calls where the
|
||||
argument is a String of length one. Those should be replaced
|
||||
with append(char) for performance reasons.
|
||||
|
||||
TODO: This could be more advanced in order to match also
|
||||
- .append("\u1234")
|
||||
-->
|
||||
<property name="format" value="\.append\("(.|\\.)"\)"/>
|
||||
<property name="message" value="Don't use StringBuilder.append(String) when you can use StringBuilder.append(char). Solution: Replace double quotes of append's argument with single quotes."/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="^\s+$"/>
|
||||
<property name="message" value="Line containing only whitespace character(s)"/>
|
||||
</module>
|
||||
<module name="FileTabCharacter"/>
|
||||
<module name="RegexpSingleline">
|
||||
<!--
|
||||
Explaining the following Regex
|
||||
|
||||
\s+ $
|
||||
| +- End of Line (2)
|
||||
+- At least one whitespace (1)
|
||||
|
||||
Rationale:
|
||||
Matches trailing whitespace (2) in lines containing at least one (1) non-whitespace character
|
||||
-->
|
||||
<property name="format" value="\s+$"/>
|
||||
<property name="message" value="Line containing trailing whitespace character(s)"/>
|
||||
</module>
|
||||
<!-- <module name="RegexpSingleline"> -->
|
||||
<!-- <property name="format" value="fqdn"/> -->
|
||||
<!-- </module> -->
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="^\s*//[^\s]"/>
|
||||
<property name="message" value="Comment start ('//') followed by non-space character. You would not continue after a punctuation without a space, would you?"/>
|
||||
</module>
|
||||
<!-- Check for synchronized keyword on Manager's static
|
||||
getInstanceFor() method. Note that if XMPPConnection is every
|
||||
replaced with something else, then we need to change it here
|
||||
too. -->
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="^\s*public(?!.*synchronized).*getInstanceFor\(XMPPConnection.*$"/>
|
||||
<property name="message" value="getInstanceFor() should be synchronized"/>
|
||||
</module>
|
||||
<module name="JavadocPackage"/>
|
||||
<module name="TreeWalker">
|
||||
<module name="SuppressionCommentFilter"/>
|
||||
<module name="FinalClass"/>
|
||||
<module name="UnusedImports">
|
||||
<property name="processJavadoc" value="true"/>
|
||||
</module>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="IllegalImport"/>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="RedundantModifier"/>
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="UpperEll"/>
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<module name="GenericWhitespace"/>
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="PackageDeclaration"/>
|
||||
<module name="LeftCurly"/>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="printStackTrace"/>
|
||||
<property name="message" value="Usage of printStackTrace"/>
|
||||
<property name="ignoreComments" value="true"/>
|
||||
</module>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="println"/>
|
||||
<property name="message" value="Usage of println"/>
|
||||
<property name="ignoreComments" value="true"/>
|
||||
</module>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="Boolean\.valueOf\("/>
|
||||
<property name="message" value="Usage Boolean.valueOf(), consider using ParserUtils.parseXmlBoolean() instead (if you want to parse xs:boolean values)"/>
|
||||
<property name="ignoreComments" value="true"/>
|
||||
</module>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="^\t+"/>
|
||||
<property name="message" value="Indent must not use tab characters. Use space instead."/>
|
||||
</module>
|
||||
<module name="JavadocMethod">
|
||||
<!-- TODO stricten those checks -->
|
||||
<property name="scope" value="public"/>
|
||||
<property name="allowUndeclaredRTE" value="true"/>
|
||||
<property name="allowMissingParamTags" value="true"/>
|
||||
<property name="allowMissingThrowsTags" value="true"/>
|
||||
<property name="allowMissingReturnTag" value="true"/>
|
||||
<property name="allowMissingJavadoc" value="true"/>
|
||||
<property name="suppressLoadErrors" value="true"/>
|
||||
</module>
|
||||
<module name="JavadocStyle">
|
||||
<property name="scope" value="public"/>
|
||||
<property name="checkEmptyJavadoc" value="true"/>
|
||||
<property name="checkHtml" value="false"/>
|
||||
</module>
|
||||
<module name="ParenPad">
|
||||
</module>
|
||||
<module name="NoWhitespaceAfter">
|
||||
<property name="tokens" value="INC
|
||||
, DEC
|
||||
, UNARY_MINUS
|
||||
, UNARY_PLUS
|
||||
, BNOT, LNOT
|
||||
, DOT
|
||||
, ARRAY_DECLARATOR
|
||||
, INDEX_OP
|
||||
"/>
|
||||
</module>
|
||||
<module name="WhitespaceAfter">
|
||||
<property name="tokens" value="TYPECAST
|
||||
, LITERAL_IF
|
||||
, LITERAL_ELSE
|
||||
, LITERAL_WHILE
|
||||
, LITERAL_DO
|
||||
, LITERAL_FOR
|
||||
, DO_WHILE
|
||||
, COMMA
|
||||
"/>
|
||||
</module>
|
||||
<module name="WhitespaceAround">
|
||||
<property
|
||||
name="ignoreEnhancedForColon"
|
||||
value="false"
|
||||
/>
|
||||
<!-- Currently disabled tokens: LCURLY, RCURLY, WILDCARD_TYPE, GENERIC_START, GENERIC_END -->
|
||||
<property
|
||||
name="tokens"
|
||||
value="ASSIGN
|
||||
, ARRAY_INIT
|
||||
, BAND
|
||||
, BAND_ASSIGN
|
||||
, BOR
|
||||
, BOR_ASSIGN
|
||||
, BSR
|
||||
, BSR_ASSIGN
|
||||
, BXOR
|
||||
, BXOR_ASSIGN
|
||||
, COLON
|
||||
, DIV
|
||||
, DIV_ASSIGN
|
||||
, DO_WHILE
|
||||
, EQUAL
|
||||
, GE
|
||||
, GT
|
||||
, LAMBDA
|
||||
, LAND
|
||||
, LE
|
||||
, LITERAL_CATCH
|
||||
, LITERAL_DO
|
||||
, LITERAL_ELSE
|
||||
, LITERAL_FINALLY
|
||||
, LITERAL_FOR
|
||||
, LITERAL_IF
|
||||
, LITERAL_RETURN
|
||||
, LITERAL_SWITCH
|
||||
, LITERAL_SYNCHRONIZED
|
||||
, LITERAL_TRY
|
||||
, LITERAL_WHILE
|
||||
, LOR
|
||||
, LT
|
||||
, MINUS
|
||||
, MINUS_ASSIGN
|
||||
, MOD
|
||||
, MOD_ASSIGN
|
||||
, NOT_EQUAL
|
||||
, PLUS
|
||||
, PLUS_ASSIGN
|
||||
, QUESTION
|
||||
, SL
|
||||
, SLIST
|
||||
, SL_ASSIGN
|
||||
, SR
|
||||
, SR_ASSIGN
|
||||
, STAR
|
||||
, STAR_ASSIGN
|
||||
, LITERAL_ASSERT
|
||||
, TYPE_EXTENSION_AND
|
||||
"/>
|
||||
</module>
|
||||
<module name="CustomImportOrder">
|
||||
<property name="customImportOrderRules"
|
||||
value="STATIC###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE"/>
|
||||
<property name="specialImportsRegExp" value="^org\.jivesoftware\.smack"/>
|
||||
<property name="sortImportsInGroupAlphabetically" value="true"/>
|
||||
<property name="separateLineBetweenGroups" value="true"/>
|
||||
</module>
|
||||
</module>
|
||||
</module>
|
16
config/checkstyle/header.txt
Normal file
16
config/checkstyle/header.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 20XX the original author or authors
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 20XX John Doe
|
||||
*
|
||||
* This file is part of smack-omemo-signal.
|
||||
*
|
||||
* smack-omemo-signal is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 20XX John Doe
|
||||
*
|
||||
* This file is part of smack-omemo-signal-integration-test.
|
||||
*
|
||||
* smack-omemo-signal-integration-test is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
13
config/checkstyle/suppressions.xml
Normal file
13
config/checkstyle/suppressions.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE suppressions PUBLIC
|
||||
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
|
||||
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
|
||||
<suppressions>
|
||||
<!-- GenericWhitespace has some problems with false postive, leave
|
||||
it disabled until gradle uses a checkstyle version where this is fixed
|
||||
-->
|
||||
<suppress checks="GenericWhitespace"
|
||||
files="Protocol.java" />
|
||||
<!-- Suppress JavadocPackage in the test packages -->
|
||||
<suppress checks="JavadocPackage" files="[\\/]test[\\/]"/>
|
||||
</suppressions>
|
Loading…
Add table
Add a link
Reference in a new issue