├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src ├── main ├── kotlin │ └── me │ │ └── cassiano │ │ └── ktlint │ │ └── reporter │ │ └── html │ │ ├── HtmlReporter.kt │ │ └── HtmlReporterProvider.kt └── resources │ └── META-INF │ └── services │ └── com.pinterest.ktlint.core.ReporterProvider └── test └── kotlin └── me └── cassiano └── ktlint └── reporter └── html └── HtmlReporterTest.kt /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/linux,macos,gradle,windows,android,intellij+all 3 | 4 | ### Android ### 5 | # Built application files 6 | *.apk 7 | *.ap_ 8 | 9 | # Files for the ART/Dalvik VM 10 | *.dex 11 | 12 | # Java class files 13 | *.class 14 | 15 | # Generated files 16 | bin/ 17 | gen/ 18 | out/ 19 | 20 | # Gradle files 21 | .gradle/ 22 | build/ 23 | 24 | # Local configuration file (sdk path, etc) 25 | local.properties 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ 29 | 30 | # Log Files 31 | *.log 32 | 33 | # Android Studio Navigation editor temp files 34 | .navigation/ 35 | 36 | # Android Studio captures folder 37 | captures/ 38 | 39 | # Intellij 40 | *.iml 41 | .idea/workspace.xml 42 | .idea/tasks.xml 43 | .idea/gradle.xml 44 | .idea/dictionaries 45 | .idea/libraries 46 | 47 | # External native build folder generated in Android Studio 2.2 and later 48 | .externalNativeBuild 49 | 50 | # Freeline 51 | freeline.py 52 | freeline/ 53 | freeline_project_description.json 54 | 55 | ### Android Patch ### 56 | gen-external-apklibs 57 | 58 | ### Intellij+all ### 59 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 60 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 61 | 62 | # User-specific stuff: 63 | .idea/**/workspace.xml 64 | .idea/**/tasks.xml 65 | 66 | # Sensitive or high-churn files: 67 | .idea/**/dataSources/ 68 | .idea/**/dataSources.ids 69 | .idea/**/dataSources.xml 70 | .idea/**/dataSources.local.xml 71 | .idea/**/sqlDataSources.xml 72 | .idea/**/dynamic.xml 73 | .idea/**/uiDesigner.xml 74 | 75 | # Gradle: 76 | .idea/**/gradle.xml 77 | .idea/**/libraries 78 | 79 | # CMake 80 | cmake-build-debug/ 81 | 82 | # Mongo Explorer plugin: 83 | .idea/**/mongoSettings.xml 84 | 85 | ## File-based project format: 86 | *.iws 87 | 88 | ## Plugin-specific files: 89 | 90 | # IntelliJ 91 | /out/ 92 | 93 | # mpeltonen/sbt-idea plugin 94 | .idea_modules/ 95 | 96 | # JIRA plugin 97 | atlassian-ide-plugin.xml 98 | 99 | # Cursive Clojure plugin 100 | .idea/replstate.xml 101 | 102 | # Ruby plugin and RubyMine 103 | /.rakeTasks 104 | 105 | # Crashlytics plugin (for Android Studio and IntelliJ) 106 | com_crashlytics_export_strings.xml 107 | crashlytics.properties 108 | crashlytics-build.properties 109 | fabric.properties 110 | 111 | ### Intellij+all Patch ### 112 | # Ignores the whole idea folder 113 | # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 114 | 115 | .idea/ 116 | 117 | ### Linux ### 118 | *~ 119 | 120 | # temporary files which can be created if a process still has a handle open of a deleted file 121 | .fuse_hidden* 122 | 123 | # KDE directory preferences 124 | .directory 125 | 126 | # Linux trash folder which might appear on any partition or disk 127 | .Trash-* 128 | 129 | # .nfs files are created when an open file is removed but is still being accessed 130 | .nfs* 131 | 132 | ### macOS ### 133 | *.DS_Store 134 | .AppleDouble 135 | .LSOverride 136 | 137 | # Icon must end with two \r 138 | Icon 139 | 140 | # Thumbnails 141 | ._* 142 | 143 | # Files that might appear in the root of a volume 144 | .DocumentRevisions-V100 145 | .fseventsd 146 | .Spotlight-V100 147 | .TemporaryItems 148 | .Trashes 149 | .VolumeIcon.icns 150 | .com.apple.timemachine.donotpresent 151 | 152 | # Directories potentially created on remote AFP share 153 | .AppleDB 154 | .AppleDesktop 155 | Network Trash Folder 156 | Temporary Items 157 | .apdisk 158 | 159 | ### Windows ### 160 | # Windows thumbnail cache files 161 | Thumbs.db 162 | ehthumbs.db 163 | ehthumbs_vista.db 164 | 165 | # Folder config file 166 | Desktop.ini 167 | 168 | # Recycle Bin used on file shares 169 | $RECYCLE.BIN/ 170 | 171 | # Windows Installer files 172 | *.cab 173 | *.msi 174 | *.msm 175 | *.msp 176 | 177 | # Windows shortcuts 178 | *.lnk 179 | 180 | ### Gradle ### 181 | .gradle 182 | **/build/ 183 | 184 | # Ignore Gradle GUI config 185 | gradle-app.setting 186 | 187 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 188 | !gradle-wrapper.jar 189 | 190 | # Cache of project 191 | .gradletasknamecache 192 | 193 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 194 | # gradle/wrapper/gradle-wrapper.properties 195 | 196 | 197 | # End of https://www.gitignore.io/api/linux,macos,gradle,windows,android,intellij+all 198 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at matheus.cassiano@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to ktlint-html-reporter 2 | 3 | If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request (on a branch other than `master` or `gh-pages`). 4 | 5 | When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Matheus Candido 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deprecated 2 | 3 | This has been deprecated and will no longer be maintened as the reporter is now available through ktlint :) 4 | https://github.com/pinterest/ktlint 5 | 6 | ## ktlint HTML Reporter 7 | 8 | This is a simple HTML reporter for [ktlint](https://github.com/pinterest/ktlint). I wrote it while setting up quality tools for [Yosef](https://github.com/concretesolutions/yosef-android). 9 | 10 | ### Usage: 11 | 12 | Since ktlint is able to load reporters from external sources, you can simply configure it like: 13 | 14 | ```groovy 15 | task ktlint(type: JavaExec, group: "verification") { 16 | // ... 17 | args "--reporter=html,artifact=me.cassiano:ktlint-html-reporter:,output=${buildDir}/ktlint.html" 18 | } 19 | 20 | ``` 21 | 22 | The reporter is also available on jCenter, so you don't need to include JitPack if you need to use it directly as a dependency: 23 | 24 | ```compile "me.cassiano:ktlint-html-reporter:$latestVersion"``` 25 | 26 | **Note: you need to upgrade to ktlint 0.20.0 before using this.** 27 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlinVersion = '1.3.30' 3 | ext.ktlintVersion = '0.32.0' 4 | ext.junitVersion = '4.12' 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | // noinspection all 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 11 | } 12 | } 13 | 14 | plugins { 15 | id "com.jfrog.artifactory" version "4.7.2" 16 | id "com.jfrog.bintray" version "1.8.0" 17 | } 18 | 19 | apply plugin: 'java' 20 | apply plugin: 'kotlin' 21 | apply plugin: 'maven-publish' 22 | 23 | group 'me.cassiano' 24 | version '0.2.3' 25 | sourceCompatibility = 1.6 26 | 27 | final ciBuild = System.hasProperty('ci') 28 | final localProps = new Properties() 29 | localProps.load(file('local.properties').newDataInputStream()) 30 | 31 | repositories { 32 | mavenCentral() 33 | } 34 | 35 | dependencies { 36 | compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" 37 | compileOnly "com.pinterest.ktlint:ktlint-core:$ktlintVersion" 38 | testCompile "com.pinterest.ktlint:ktlint-core:$ktlintVersion" 39 | testCompile "junit:junit:$junitVersion" 40 | } 41 | 42 | bintray { 43 | 44 | if (ciBuild) { 45 | user = System.getenv('bintrayUser') 46 | key = System.getenv('bintrayKey') 47 | } else { 48 | user = localProps.getProperty('bintrayUser') 49 | key = localProps.getProperty('bintrayKey') 50 | } 51 | 52 | publications = ['mavenJava'] 53 | 54 | pkg { 55 | repo = 'maven' 56 | name = 'ktlint-html-reporter' 57 | 58 | version { 59 | name = project.version 60 | released = new Date() 61 | vcsTag = "v${project.version}" 62 | } 63 | } 64 | } 65 | 66 | task sourcesJar(type: Jar, dependsOn: project.classes) { 67 | from sourceSets.main.allSource 68 | } 69 | 70 | task javadocJar(type: Jar, dependsOn: project.javadoc) { 71 | from javadoc.destinationDir 72 | } 73 | 74 | artifacts { 75 | archives sourcesJar, javadocJar 76 | } 77 | 78 | publishing { 79 | publications { 80 | mavenJava(MavenPublication) { 81 | artifactId project.bintray.pkg.name 82 | from components.java 83 | 84 | artifact sourcesJar { 85 | classifier = 'sources' 86 | } 87 | artifact javadocJar { 88 | classifier = 'javadoc' 89 | } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcassiano/ktlint-html-reporter/1698dd2c2d55dc68fee02bf6fa335005a13a8b8c/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Feb 13 22:40:41 CET 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'ktlint-html-reporter' 2 | 3 | -------------------------------------------------------------------------------- /src/main/kotlin/me/cassiano/ktlint/reporter/html/HtmlReporter.kt: -------------------------------------------------------------------------------- 1 | package me.cassiano.ktlint.reporter.html 2 | 3 | import com.pinterest.ktlint.core.LintError 4 | import com.pinterest.ktlint.core.Reporter 5 | import java.io.PrintStream 6 | import java.util.concurrent.ConcurrentHashMap 7 | 8 | class HtmlReporter(private val out: PrintStream) : Reporter { 9 | 10 | private val acc = ConcurrentHashMap>() 11 | private var issueCount = 0 12 | private var correctedCount = 0 13 | 14 | override fun onLintError(file: String, err: LintError, corrected: Boolean) { 15 | if (!corrected) { 16 | issueCount += 1 17 | acc.getOrPut(file) { mutableListOf() }.add(err) 18 | } else { 19 | correctedCount += 1 20 | } 21 | } 22 | 23 | override fun afterAll() { 24 | html { 25 | head { 26 | cssLink("https://fonts.googleapis.com/css?family=Source+Code+Pro") 27 | text("\n") 35 | } 36 | body { 37 | if (!acc.isEmpty()) { 38 | 39 | h1 { text("Overview") } 40 | 41 | paragraph { 42 | text("Issues found: $issueCount") 43 | } 44 | 45 | paragraph { 46 | text("Issues corrected: $correctedCount") 47 | } 48 | 49 | acc.forEach { file: String, errors: MutableList -> 50 | h3 { text(file) } 51 | ul { 52 | errors.forEach { (line, col, ruleId, detail) -> 53 | item("($line, $col): $detail ($ruleId)") 54 | } 55 | } 56 | } 57 | } else { 58 | paragraph { 59 | text("Congratulations, no issues found!") 60 | } 61 | } 62 | } 63 | } 64 | } 65 | 66 | private fun html(body: () -> Unit) { 67 | out.println("") 68 | body() 69 | out.println("") 70 | } 71 | 72 | private fun head(body: () -> Unit) { 73 | out.println("") 74 | body() 75 | out.println("") 76 | } 77 | 78 | private fun body(body: () -> Unit) { 79 | out.println("") 80 | body() 81 | out.println("") 82 | } 83 | 84 | private fun h1(body: () -> Unit) { 85 | out.print("

") 86 | body() 87 | out.println("

") 88 | } 89 | 90 | private fun h3(body: () -> Unit) { 91 | out.print("

") 92 | body() 93 | out.println("

") 94 | } 95 | 96 | private fun text(value: String) { 97 | out.print(value) 98 | } 99 | 100 | private fun ul(body: () -> Unit) { 101 | out.println("
    ") 102 | body() 103 | out.println("
") 104 | } 105 | 106 | private fun item(value: String) { 107 | out.print("
  • ") 108 | text(value) 109 | out.println("
  • ") 110 | } 111 | 112 | private fun cssLink(link: String) { 113 | out.print("") 116 | } 117 | 118 | private fun paragraph(body: () -> Unit) { 119 | out.print("

    ") 120 | body() 121 | out.println("

    ") 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/main/kotlin/me/cassiano/ktlint/reporter/html/HtmlReporterProvider.kt: -------------------------------------------------------------------------------- 1 | package me.cassiano.ktlint.reporter.html 2 | 3 | import com.pinterest.ktlint.core.Reporter 4 | import com.pinterest.ktlint.core.ReporterProvider 5 | import java.io.PrintStream 6 | 7 | class HtmlReporterProvider : ReporterProvider { 8 | override val id: String = "html" 9 | override fun get(out: PrintStream, opt: Map): Reporter = HtmlReporter(out) 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/com.pinterest.ktlint.core.ReporterProvider: -------------------------------------------------------------------------------- 1 | me.cassiano.ktlint.reporter.html.HtmlReporterProvider 2 | -------------------------------------------------------------------------------- /src/test/kotlin/me/cassiano/ktlint/reporter/html/HtmlReporterTest.kt: -------------------------------------------------------------------------------- 1 | package me.cassiano.ktlint.reporter.html 2 | 3 | import com.pinterest.ktlint.core.LintError 4 | import org.junit.Assert.assertEquals 5 | import org.junit.Test 6 | import java.io.ByteArrayOutputStream 7 | import java.io.PrintStream 8 | 9 | class HtmlReporterTest { 10 | 11 | @Test 12 | fun shouldRenderEmptyReportWhen_NoIssuesFound() { 13 | val out = ByteArrayOutputStream() 14 | val reporter = HtmlReporter(PrintStream(out, true)) 15 | reporter.afterAll() 16 | 17 | val actual = """ 18 | 19 | 20 | 21 | 28 | 29 | 30 |

    Congratulations, no issues found!

    31 | 32 | 33 | """.trimStart().replace("\n", System.lineSeparator()) 34 | 35 | val expected = String(out.toByteArray()) 36 | assertEquals(actual, expected) 37 | } 38 | 39 | @Test 40 | fun shouldRenderIssuesWhen_LintProblemsFound() { 41 | val out = ByteArrayOutputStream() 42 | val reporter = HtmlReporter(PrintStream(out, true)) 43 | 44 | reporter.onLintError( 45 | "/file1.kt", 46 | LintError(1, 1, "rule-1", "rule-1 broken"), 47 | false 48 | ) 49 | 50 | reporter.afterAll() 51 | 52 | val actual = """ 53 | 54 | 55 | 62 | 63 | 64 |

    Overview

    65 |

    Issues found: 1

    66 |

    Issues corrected: 0

    67 |

    /file1.kt

    68 |
      69 |
    • (1, 1): rule-1 broken (rule-1)
    • 70 |
    71 | 72 | 73 | """.trimStart().replace("\n", System.lineSeparator()) 74 | 75 | val expected = String(out.toByteArray()) 76 | assertEquals(actual, expected) 77 | } 78 | 79 | @Test 80 | fun shouldNotRenderCorrectedIssuesWhen_LintOneIsFound() { 81 | val out = ByteArrayOutputStream() 82 | val reporter = HtmlReporter(PrintStream(out, true)) 83 | 84 | reporter.onLintError( 85 | "/file1.kt", 86 | LintError(1, 1, "rule-1", "rule-1 broken"), 87 | false 88 | ) 89 | 90 | reporter.onLintError( 91 | "/file2.kt", 92 | LintError(1, 1, "rule-1", "rule-1 broken"), 93 | true 94 | ) 95 | 96 | reporter.afterAll() 97 | 98 | val actual = """ 99 | 100 | 101 | 108 | 109 | 110 |

    Overview

    111 |

    Issues found: 1

    112 |

    Issues corrected: 1

    113 |

    /file1.kt

    114 |
      115 |
    • (1, 1): rule-1 broken (rule-1)
    • 116 |
    117 | 118 | 119 | """.trimStart().replace("\n", System.lineSeparator()) 120 | 121 | val expected = String(out.toByteArray()) 122 | assertEquals(actual, expected) 123 | } 124 | } 125 | --------------------------------------------------------------------------------