├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── checkstyle.gradle └── config ├── checkstyle-noframes-sorted.xsl └── checkstyle.xml /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Freshly Pressed 2 | 3 | Thanks for considering contributing to the project! 4 | 5 | Here's the set of guidelines to follow: 6 | 7 | * Open up issues but please, try to see if that issue has been raised before and possibly fixed 8 | * Send your Pull Requests with as much background info as possible 9 | 10 | ## Commit messages 11 | * Use the present tense ("Add feature" not "Added feature") 12 | * Use the imperative mood ("Move cursor to..." not "Moves cursor to...") 13 | * Limit the first line to 72 characters or less -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2010-2015 Stefanos Togoulidis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # checkstyle-android 2 | 3 | A [gradle checkstyle](https://docs.gradle.org/current/userguide/checkstyle_plugin.html) configuration that most closely matches the [Android Code Style Guidelines for Contributors](https://source.android.com/source/code-style.html). Many Android projects chose to follow those guidelines and this checkstyle configuration helps enforce them on your code. 4 | 5 | This is still Work-In-Progress! Only a few rules have been implemented so far. Check the #Contributing section below on how to contrbute ;) 6 | 7 | ## Usage 8 | 9 | You can just grab [the rules file](config/checkstyle.xml) and use it with your own checkstyle setup or you can add this repo as a git submodule: 10 | ``` 11 | git submodule add git@github.com:hypest/checkstyle-android.git 12 | ``` 13 | Add it in your project's `build.gradle` like this: 14 | ``` 15 | apply from: 'checkstyle-android/checkstyle.gradle' 16 | ``` 17 | You can now run the checks at the command line: 18 | ``` 19 | ./gradlew checkstyle 20 | ``` 21 | Xml and html reports will be created in `/reports/checkstyle/` 22 | 23 | You may opt to have the build fail if checkstyle reports issues. You can enable that by adding to build.gradle: 24 | ``` 25 | preBuild.dependsOn('checkstyle') 26 | ``` 27 | ## Prerequisities 28 | 29 | You will need gradle or AndroidStudio. 30 | 31 | ## Contributing 32 | 33 | Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and how you can contribute to this project! 34 | 35 | ## License 36 | 37 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. 38 | -------------------------------------------------------------------------------- /checkstyle.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'checkstyle' 2 | 3 | checkstyle { 4 | toolVersion = "6.5" 5 | } 6 | 7 | task checkstyle (type: Checkstyle) { 8 | description 'Runs Checkstyle inspection against Android sourcesets.' 9 | group = 'Code Quality' 10 | 11 | ignoreFailures = false 12 | showViolations = false 13 | source 'src/main', 'src/release', 'src/androidTest/java' 14 | include '**/*.java' 15 | exclude '**/gen/**' 16 | exclude '**/R.java' 17 | exclude '**/BuildConfig.java' 18 | reports { 19 | xml.destination "$project.buildDir/reports/checkstyle/checkstyle-report.xml" 20 | } 21 | classpath = files() 22 | configFile = file("checkstyle-android/config/checkstyle.xml") 23 | 24 | configProperties.lineWidth = 120 25 | } 26 | 27 | task checkstyleReport << { 28 | if (file("$buildDir/reports/checkstyle/checkstyle-report.xml").exists()) { 29 | ant.xslt(in: "$project.buildDir/reports/checkstyle/checkstyle-report.xml", 30 | style:"checkstyle-android/config/checkstyle-noframes-sorted.xsl", 31 | out:"$project.buildDir/reports/checkstyle/checkstyle-report.html" 32 | ) 33 | } 34 | } 35 | 36 | gradle.taskGraph.afterTask {Task task, TaskState state -> 37 | if (task.name in ['checkstyle']) { 38 | checkstyleReport.execute() 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /config/checkstyle-noframes-sorted.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 83 | 84 | 85 | 86 | 87 | 88 |
79 | 82 |

CheckStyle Audit

Designed for use with CheckStyle and Ant.
89 |
90 | 91 | 92 | 93 |
94 | 95 | 96 | 97 |
98 | 99 | 100 | 101 | 102 |
103 | 104 | 105 | 106 | 107 |
108 | 109 | 110 | 111 | 112 |

Files

113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 |
NameErrors
129 |
130 | 131 | 132 | 133 | 134 |

File

135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 |
Error DescriptionLine
150 | Back to top 151 |
152 | 153 | 154 | 155 |

Summary

156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 |
FilesErrors
169 |
170 | 171 | 172 | 173 | a 174 | b 175 | 176 | 177 |
178 | 179 | 180 | -------------------------------------------------------------------------------- /config/checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | --------------------------------------------------------------------------------