\subsection{CLI-application}
You can run diKTat as a CLI-application. To do this you simply need to install ktlint/diktat and to run it via console with a special option \texttt{--disabled\_rules=standard} that we have introduced in ktlint \footnote{\url{https://github.com/pinterest/ktlint/pull/977/files}} :

\begin{center}
\texttt{\$ ./ktlint -R diktat.jar --disabled\_rules=standard "path/to/project/**/*.kt"}
\end{center}

After the run, all detected errors will displayed. Each warning contains of a rule name, a description of the rule and line/column where this error appears in the code. It also will contain \texttt{"cannot be auto-corrected"} note if the Inspection does not have autofixer. The format of warning is the following:

\begin{center}
/path/to/project/file.kt:6:5: [WARNING\_ID\_NAME] free text of the warning (cannot be auto-corrected)
\end{center}

Please also note, that as diktat is using ktlint framework - the format of the reported warnings can be changed: it can be xml, json and other formats that are supported by ktlint. Please refer to ktlint documentation \footnote{\url{https://github.com/pinterest/ktlint\#creating-a-reporter}} to see the information about custom reporters.

\subsection{Maven plugin}
Maven plugin was introduced for diktat since the version 0.1.3. The following code snippet from \texttt{pom.xml} shows how to use diktat with Maven plugin:
\begin{lstlisting}[caption={DiKTat with Maven plugin}, label={lst:maven}, language=Kotlin]
          <plugin>
                <groupId>com.saveourtool.diktat</groupId>
                <artifactId>diktat-maven-plugin</artifactId>
                <version>${diktat.version}</version>
                <executions>
                    <execution>
                        <id>diktat</id>
                        <phase>none</phase>
                        <goals>
                            <goal>check</goal>
                            <goal>fix</goal>
                        </goals>
                        <configuration>
                            <inputs>
                                <input>${project.basedir}/src/main/kotlin</input>
                                <input>${project.basedir}/src/test/kotlin</input>
                            </inputs>
                            <diktatConfigFile>diktat-analysis.yml</diktatConfigFile>
                            <excludes>
                               <exclude>${project.basedir}/src/test/kotlin/excluded</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
\end{lstlisting}

To run diktat in only-check mode use the command: \texttt{mvn diktat:check@diktat}. To run diktat in autocorrect mode use the command: \texttt{mvn diktat:fix@diktat}.


\subsection{Gradle plugin}
This plugin is available since version 0.1.5. The following code snippet shows how to configure Gradle plugin for diktat.

\begin{lstlisting}[caption={DiKTat with Gradle plugin}, label={lst:gradle1}, language=Kotlin]
plugins {
    id("com.saveourtool.diktat.diktat-gradle-plugin") version "0.1.7"
}
\end{lstlisting}

Or use buildscript syntax:

\begin{lstlisting}[caption={DiKTat with Gradle plugin}, label={lst:gradle1}, language=Kotlin]

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("com.saveourtool.diktat:diktat-gradle-plugin:0.1.7")
    }
}
apply(plugin = "com.saveourtool.diktat.diktat-gradle-plugin")
\end{lstlisting}

Then you can configure diktat using diktat extension:

\begin{lstlisting}[caption={DiKTat extension}, label={lst:gradle2}, language=Kotlin]
diktat {
    inputs = files("src/**/*.kt")  // file collection that will be checked by diktat
    debug = true  // turn on debug logging
    excludes = files("src/test/kotlin/excluded")  // these files will not be checked by diktat
}
\end{lstlisting}

You can run diktat checks using task \texttt{diktatCheck} and automatically fix errors with tasks \texttt{diktatFix}.

\subsection{Configuratifon file}
As described above, diKTat has a configuration file. Note that you should place the \textsl{diktat-analysis.yml} file containing the diktat configuration in the parent directory of your project when running as a CLI application. Diktat-maven-plugin and diktat-gradle-plugin have a separate option to setup the path where the configuration file is stored.

\subsection{DiKTat-web}
The easiest way to use diktat without any downloads or installations is the web version of the app. You can try it by the following link: \url{https://ktlint-demo.herokuapp.com/demo}. Web app supports both checking and fixing, using either ktlint or diktat ruleset. For diktat you can also upload a custom configuration file.
