Skip to content

Commit

Permalink
Updated code styles
Browse files Browse the repository at this point in the history
  • Loading branch information
drakeet committed Jul 3, 2018
1 parent 7c52378 commit 7410511
Show file tree
Hide file tree
Showing 15 changed files with 354 additions and 455 deletions.
26 changes: 13 additions & 13 deletions build.gradle
@@ -1,21 +1,21 @@
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
}

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
}
}

allprojects {
repositories {
google()
jcenter()
}
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
delete rootProject.buildDir
}
79 changes: 9 additions & 70 deletions checkstyle.xml
Expand Up @@ -2,77 +2,47 @@
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
<property name="charset" value="UTF-8"/>

<!-- Rationale: Any source files and text files in general should end with a line separator
to let other easily add new content at the end of file and "diff" command does not
show previous lines as changed.
See http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf"/>
</module>
<!-- Checks for long source files. Default max: 2000 -->
<!-- See http://checkstyle.sourceforge.net/config_sizes.html#FileLength -->
<module name="FileLength"/>
<module name="FileTabCharacter"/>
<!-- Checks that property files contain the same keys. -->
<module name="Translation"/>

<module name="TreeWalker">
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<!--module name="JavadocMethod"/-->
<!--module name="JavadocType"/-->
<!--module name="JavadocVariable"/-->
<!--module name="JavadocStyle"/-->

<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName"/>
<!-- local, final variables, including catch parameters -->
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<!--<module name="PackageName"/>-->
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<!-- classes and interfaces -->
<module name="TypeName"/>

<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>

<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="LineLength">
<property name="max" value="140"/>
<property name="max" value="200"/>
</module>
<module name="MethodLength"/>
<!--module name="ParameterNumber"/-->

<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="GenericWhitespace"/>
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter">
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS"/>
</module>
<module name="NoWhitespaceBefore"/>
<!-- Checks the policy on how to wrap lines on operators. -->
<!-- <module name="OperatorWrap"/> -->
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<!-- <module name="WhitespaceAfter"/> -->
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
Expand All @@ -83,59 +53,29 @@
<property name="validateComments" value="true"/>
</module>

<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<!-- Default order: public, protected, private, abstract, static, final, transient, volatile, synchronized, native, strictfp -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>

<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<!--module name="AvoidNestedBlocks"/-->
<!--module name="EmptyBlock"/-->
<!-- See http://checkstyle.sourceforge.net/config_blocks.html#LeftCurly -->
<!-- <module name="LeftCurly"/> -->
<!--module name="NeedBraces"/-->
<!-- See http://checkstyle.sourceforge.net/property_types.html#rcurly#rcurly -->
<!-- <module name="RightCurly"/> -->

<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<!--module name="AvoidInlineConditionals"/-->
<module name="CovariantEquals"/>
<module name="EmptyStatement"/>
<module name="EqualsAvoidNull"/>
<module name="EqualsHashCode"/>
<!--module name="HiddenField"/-->
<module name="IllegalInstantiation"/>
<!--module name="InnerAssignment"/-->
<!--module name="MagicNumber"/-->
<module name="MissingSwitchDefault"/>
<!-- Checks for overly complicated boolean expressions. Currently finds code like if (b == true), b || true, !false, etc.
Rationale: Complex boolean logic makes code hard to understand and maintain. -->
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>

<!-- Checks for class design -->
<!-- See http://checkstyle.sf.net/config_design.html -->
<!--module name="DesignForExtension"/-->
<!-- Checks that a class which has only private constructors is declared as final. -->
<module name="FinalClass"/>
<!--module name="HideUtilityClassConstructor"/-->
<module name="InterfaceIsType"/>
<!--module name="VisibilityModifier"/-->

<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<!-- Checks the style of array type definitions.
Some like Java-style: public static void main(String[] args) and
some like C-style: public static void main(String args[]) -->
<module name="ArrayTypeStyle"/>
<!--module name="FinalParameters"/-->
<!--module name="TodoComment"/-->
<module name="UpperEll"/>
<!-- Checks correct indentation of Java code. Default basicOffset: 4 -->
<module name="Indentation"/>
<module name="Indentation">
<property name="basicOffset" value="2"/>
<property name="caseIndent" value="2"/>
<property name="throwsIndent" value="2"/>
<property name="arrayInitIndent" value="2"/>
<property name="lineWrappingIndentation" value="2"/>
</module>
<module name="CommentsIndentation"/>

<module name="StringLiteralEquality"/>
Expand All @@ -146,6 +86,5 @@
<module name="NestedTryDepth">
<property name="max" value="2"/>
</module>

</module>
</module>
4 changes: 0 additions & 4 deletions gradle.properties
@@ -1,16 +1,12 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
Expand Down
28 changes: 14 additions & 14 deletions library/build.gradle
Expand Up @@ -5,23 +5,23 @@ apply from: 'checkstyle.gradle'


android {
compileSdkVersion gradle.compileSdkVersion
buildToolsVersion gradle.buildToolsVersion
compileSdkVersion gradle.compileSdkVersion

defaultConfig {
minSdkVersion gradle.minSdkVersion
targetSdkVersion gradle.targetSdkVersion
versionCode gradle.versionCode
versionName gradle.versionName
}
buildTypes {
release {
minifyEnabled false
}
defaultConfig {
minSdkVersion gradle.minSdkVersion
targetSdkVersion gradle.targetSdkVersion
versionCode gradle.versionCode
versionName gradle.versionName
}

buildTypes {
release {
minifyEnabled false
}
}
}

dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:support-annotations:' + gradle.supportLibraryVersion
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:support-annotations:' + gradle.supportLibraryVersion
}
21 changes: 10 additions & 11 deletions library/checkstyle.gradle
Expand Up @@ -16,20 +16,19 @@
apply plugin: 'checkstyle'

checkstyle {
toolVersion = 8.2
toolVersion = 8.2
}

task checkStyle(type: Checkstyle) {
description = 'Runs checkStyle inspection against ToastCompat sourcesets.'
group = 'Code Style'
configFile = rootProject.file('checkstyle.xml')
ignoreFailures = false
showViolations = true
classpath = files()
source = 'src/main/java'
description = 'Runs checkStyle inspection against ToastCompat sourcesets.'
group = 'Code Style'
configFile = rootProject.file('checkstyle.xml')
ignoreFailures = false
showViolations = true
classpath = files()
source = 'src/main/java'
}

// check code style after project evaluation
afterEvaluate { project ->
getTasksByName('checkStyle', false)[0].execute()
}
afterEvaluate { project -> getTasksByName('checkStyle', false)[0].execute()
}

0 comments on commit 7410511

Please sign in to comment.