Bug 1512274 - Enable Checkstyle for GeckoView. r=geckoview-reviewers,nalexander,snorp

Differential Revision: https://phabricator.services.mozilla.com/D23692

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Agi Sferro 2019-03-15 21:21:57 +00:00
Родитель cc987caa5a
Коммит 82fc0b279b
3 изменённых файлов: 79 добавлений и 2 удалений

Просмотреть файл

@ -1,6 +1,7 @@
buildDir "${topobjdir}/gradle/build/mobile/android/geckoview"
apply plugin: 'com.android.library'
apply plugin: 'checkstyle'
apply plugin: 'kotlin-android'
apply from: "${topsrcdir}/mobile/android/gradle/product_flavors.gradle"
@ -297,6 +298,14 @@ android.libraryVariants.all { variant ->
destinationDir = new File(destinationDir, variant.baseName)
from files(variant.javaCompile.source)
}
task("checkstyle${name.capitalize()}", type: Checkstyle) {
classpath = variant.javaCompile.classpath
configFile file("checkstyle.xml")
// TODO: cleanup and include all sources
source = ['src/main/java/']
include '**/*.java'
}
}
android.libraryVariants.all { variant ->

Просмотреть файл

@ -0,0 +1,67 @@
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<!-- Disallow tabs -->
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<!-- Disallow trailing whitespace -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="message" value="Trailing whitespace"/>
</module>
<module name="TreeWalker">
<module name="FinalParameters"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="LeftCurly"/>
<module name="RightCurly"/>
<module name="Indentation"/>
<module name="OneStatementPerLine"/>
<module name="AvoidStarImport"/>
<module name="UnusedImports"/>
<module name="MemberName">
<!-- Private members must use mHungarianNotation -->
<property name="format" value="m[A-Z][A-Za-z]*$"/>
<property name="applyToPrivate" value="true" />
<property name="applyToPublic" value="false" />
<property name="applyToPackage" value="false" />
<property name="applyToProtected" value="false" />
</module>
<module name="ClassTypeParameterName">
<property name="format" value="^[A-Z][A-Za-z]*$"/>
</module>
<module name="InterfaceTypeParameterName">
<property name="format" value="^[A-Z][A-Za-z]*$"/>
</module>
<module name="LocalVariableName"/>
<module name="GenericWhitespace"/>
<module name="NoLineWrap">
<property name="tokens" value="IMPORT,PACKAGE_DEF"/>
</module>
<module name="OuterTypeFilename"/>
<module name="WhitespaceAfter">
<property name="tokens" value="COMMA, SEMI"/>
</module>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
</module>
<module name="OneTopLevelClass"/>
</module>
</module>

Просмотреть файл

@ -236,11 +236,12 @@ def gradle_android_api_lint_tasks(build_config):
set_config('GRADLE_ANDROID_API_LINT_TASKS', gradle_android_api_lint_tasks)
@dependable
def gradle_android_checkstyle_tasks():
@depends(gradle_android_build_config)
def gradle_android_checkstyle_tasks(build_config):
'''Gradle tasks run by |mach android checkstyle|.'''
return [
'app:checkstyle',
'geckoview:checkstyle{geckoview.variant.name}'.format(geckoview=build_config.geckoview),
]
set_config('GRADLE_ANDROID_CHECKSTYLE_TASKS', gradle_android_checkstyle_tasks)