diff --git a/.gitignore b/.gitignore index 79d16306f2..37ac6a8ad3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ build /.idea *.iml out +.DS_Store diff --git a/README.md b/README.md index 882d235831..5dfd171857 100644 --- a/README.md +++ b/README.md @@ -1,148 +1,165 @@ -![diktat logo](diktat_small.jpg) - + ![Build and test](https://github.com/cqfn/diKTat/workflows/Build%20and%20test/badge.svg) ![deteKT static analysis](https://github.com/cqfn/diKTat/workflows/Run%20deteKT/badge.svg) -![Releases](https://img.shields.io/github/v/release/cqfn/diKTat) -![License](https://img.shields.io/github/license/cqfn/diKtat) +[![Releases](https://img.shields.io/github/v/release/cqfn/diKTat)](https://github.com/cqfn/diKTat/releases) +[![License](https://img.shields.io/github/license/cqfn/diKtat)](https://github.com/cqfn/diKTat/blob/master/LICENSE) + [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcqfn%2FdiKTat.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcqfn%2FdiKTat?ref=badge_shield) [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![ktlint](https://img.shields.io/badge/code%20style-%E2%9D%A4-FF4081.svg)](https://ktlint.github.io/) -[![Chat on Telegram](https://img.shields.io/badge/Chat%20on-Telegram-brightgreen.svg)](https://t.me/joinchat/AAAAAFDg-ipuZFGyBGPPeg) [![Hits-of-Code](https://hitsofcode.com/github/cqfn/diktat)](https://hitsofcode.com/view/github/cqfn/diktat) [![codecov](https://codecov.io/gh/cqfn/diKTat/branch/master/graph/badge.svg)](https://codecov.io/gh/cqfn/diKTat) -## diKTat project -### What is diKTat -diKTat ([github](https://github.com/cqfn/diKTat)) - is a rule set of Kotlin code style rules that are using [KTlint](https://ktlint.github.io/) framework under the hood. -In this project we are trying to define Kotlin code style rules and implement them as visitors for AST tree provided by Ktlint. -It will detect (check) and fix code style issues based on [diKTat Kotlin codestyle](https://github.com/cqfn/diKTat/wiki/diKTat-codestyle-guide). +[![Chat on Telegram](https://img.shields.io/badge/Chat%20on-Telegram-brightgreen.svg)](https://t.me/joinchat/AAAAAFDg-ipuZFGyBGPPeg) + +It is a collection of [Kotlin](https://kotlinlang.org/) code style rules implemented +as AST visitors on top of [KTlint](https://ktlint.github.io/). +The full list of rules is [here](https://github.com/cqfn/diKTat/wiki/diKTat-codestyle-guide). -## Usage -diKTat uses KTlint framework so see it's [usage first](https://ktlint.github.io/) +First, [install KTlint](https://ktlint.github.io/). +Then, load diKTat: -### How to: run default configuration of diKTat as CLI application -load KTlint: -```shell script -curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.37.2/ktlint && chmod a+x ktlint` +```bash +$ curl -sSLO https://central.artipie.com/akuleshov7/diktat/org/cqfn/diktat/diktat-rules/0.0.1/diktat-rules-0.0.1-jar-with-dependencies.jar ``` -you can also download ktlint manually from [ktlint project repo](https://github.com/pinterest/ktlint/releases) -another option for MacOS is `brew install ktlint` -load diKTat: -```shell script -curl -sSLO https://central.artipie.com/akuleshov7/diktat/org/cqfn/diktat/diktat-rules/0.0.1/diktat-rules-0.0.1-jar-with-dependencies.jar -``` +Finally, run KTlint with diKTat injected to check your `*.kt` files in `src/test`: -run KTlint with diKTat injected: -```shell script -./ktlint -R diktat-rules-0.0.1-jar-with-dependencies.jar "src/test/**/*.kt" +```bash +$ ./ktlint -R diktat-rules-0.0.1-jar-with-dependencies.jar "src/test/**/*.kt" ``` -this will run the default configuration of diKTat in check mode. To start autofixing use `-F` option. \ -To see any reference related to ktlint - see: [KTlint](https://ktlint.github.io/) or use: +To autofix all violations use `-F` option. + +If in trouble, try this: + `./ktlint -help` -### How to: run default configuration of diKTat with maven plugin -Please note, that currently diKTat releases are hosted on the [Artipie](https://www.artipie.com/), so you need to add lines below to your pom.xml file: +## Maven Plugin + +Currently diKTat releases are hosted on the +[Artipie](https://www.artipie.com/), +so you need to add lines below to your `pom.xml` file: + ```xml - - - artipie - https://central.artipie.com/akuleshov7/diktat - - - artipie - https://central.artipie.com/akuleshov7/diktat - - - - - artipie - https://central.artipie.com/akuleshov7/diktat - - + + [...] + + + artipie + https://central.artipie.com/akuleshov7/diktat + + + artipie + https://central.artipie.com/akuleshov7/diktat + + + + + artipie + https://central.artipie.com/akuleshov7/diktat + + + ``` -add this snippet to your pom.xml `-` section: +Add this snippet to your pom.xml: + ```xml - - org.apache.maven.plugins - maven-antrun-plugin - 1.8 - - - ktlint - verify - - - - - - - - - run - - - - - - com.pinterest - ktlint - 0.37.2 - - - org.cqfn.diktat - diktat-rules - 0.0.1-SNAPSHOT - - - + + [...] + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + ktlint + verify + + + + + + + + + run + + + + + + com.pinterest + ktlint + 0.37.2 + + + org.cqfn.diktat + diktat-rules + 0.0.1-SNAPSHOT + + + + + + ``` -in case you want to add autofixer with diktat ruleset just extend the snippet above with: `` +In case you want to add autofixer with diKTat ruleset just extend +the snippet above with ``. + +## Customizations via `rules-config.json` + +In KTlint, rules can be configured via `.editorconfig`, but +this does not give a chance to customize or enable/disable +each and every rule independently. +That is why we have supported `rules-config.json` that can be easily +changed and help in customization of your own rule set. +It has simple fields: +`name` — name of the rule, +`enabled` (true/false) — to enable or disable that rule, and +`configuration` — a simple map of some extra unique configurations for the rule. +For example: -### How to: make deep customization of diKTat (rules-config.json) -In ktlint rules can be configured via .editorconfig, but this does not give a chance to customize or enable/disable each and every rule independently. -That is why we have supported `rules-config.json` that can be easily changed and help in customization of your own rule set. -It has simple fields: "name" - name of the rule, "enabled" (true/false) to enable or disable that rule and "configuration" - a simple map of some extra unique configurations for the rule, for example: ```json - "configuration": { - "isCopyrightMandatory": true, - "copyrightText": "Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved." - } +"configuration": { + "isCopyrightMandatory": true, + "copyrightText": "Copyright (c) Jeff Lebowski, 2012-2020. All rights reserved." +} ``` -To see all list of available configurations go to our wiki: [Available inspections](info/available-rules.md) +## How to contribute? -## Development -### Main components Main components are: -1) diktat-ruleset - number of rules that are supported by diKTat -2) diktat-test-framework - functional/unit test framework that can be used for running your code fixer on the initial code and compare it with the expected result -3) also see our demo: diktat-demo in a separate repository +1) diktat-ruleset — number of rules that are supported by diKTat; +2) diktat-test-framework — functional/unit test framework that can be used for running your code fixer on the initial code and compare it with the expected result; +3) also see our demo: diktat-demo in a separate repository. -### How to: build the project -### What was hacked and changed in KTlint and why do we temporary need a fork of it? -Mainly we wanted to create a common configurable mechanism that will give us a chance to enable/disable and customize all rules. +Mainly we wanted to create a common configurable mechanism that +will give us a chance to enable/disable and customize all rules. That's why we added logic for: -1) Parsing .json file with configurations of rules and passing it to visitors -2) Passing information about properties to visitors. This information is very useful, when you are trying to get, for example, a filename of file where the code is stored. -3) We added a bunch of visitors that will extended KTlint functionaliity +1) Parsing .json file with configurations of rules and passing it to visitors; +2) Passing information about properties to visitors. This information is very useful, when you are trying to get, for example, a filename of file where the code is stored; +3) We added a bunch of visitors that will extended KTlint functionaliity. Download: -```shell script -git clone https://github.com/akuleshov7/diKTat.git + +```bash +$ git clone https://github.com/akuleshov7/diKTat.git ``` -We are using maven as we tired of Gradle: -```shell script -mvn clean install +We are using Maven as we are tired of Gradle: + +```bash +$ mvn clean install ``` -This will also install git hooks into your local .git directory. The hooks will restrict commit messages and branch naming. +This will also install git hooks into your local `.git` directory. The hooks +will restrict commit messages and branch naming. -### Contribution policy Please follow our [contributing policy](info/CONTRIBUTING.md) diff --git a/diktat_small.jpg b/diktat_small.jpg deleted file mode 100644 index 639cab6b18..0000000000 Binary files a/diktat_small.jpg and /dev/null differ diff --git a/logo-1024.png b/logo-1024.png new file mode 100644 index 0000000000..7c0c215dd7 Binary files /dev/null and b/logo-1024.png differ diff --git a/logo.svg b/logo.svg new file mode 100644 index 0000000000..392e2cb22f --- /dev/null +++ b/logo.svg @@ -0,0 +1,44 @@ + + + + Group 2 + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file