Skip to content

Commit 04316c9

Browse files
committed
Merge branch 'master' of https://github.com/saveourtool/diktat into bugfix/minor-doc-fixes
# Conflicts: # info/available-rules.md
2 parents 4f12a76 + dbb88ee commit 04316c9

File tree

267 files changed

+7621
-6174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

267 files changed

+7621
-6174
lines changed

.editorconfig

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
[*]
2+
charset = utf-8
3+
indent_size = 4
4+
indent_style = space
5+
insert_final_newline = true
6+
max_line_length = 180
7+
tab_width = 4
8+
trim_trailing_whitespace = true
9+
ij_continuation_indent_size = 8
10+
ij_formatter_off_tag = @formatter:off
11+
ij_formatter_on_tag = @formatter:on
12+
ij_formatter_tags_enabled = true
13+
ij_smart_tabs = false
14+
ij_visual_guides = 80,120,180
15+
ij_wrap_on_typing = false
16+
17+
[{*.kt,*.kts}]
18+
ij_kotlin_align_in_columns_case_branch = false
19+
ij_kotlin_align_multiline_binary_operation = false
20+
ij_kotlin_align_multiline_extends_list = false
21+
ij_kotlin_align_multiline_method_parentheses = false
22+
ij_kotlin_align_multiline_parameters = true
23+
ij_kotlin_align_multiline_parameters_in_calls = false
24+
ij_kotlin_allow_trailing_comma = false
25+
ij_kotlin_allow_trailing_comma_on_call_site = false
26+
ij_kotlin_assignment_wrap = normal
27+
ij_kotlin_blank_lines_after_class_header = 0
28+
ij_kotlin_blank_lines_around_block_when_branches = 0
29+
ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1
30+
ij_kotlin_block_comment_add_space = false
31+
ij_kotlin_block_comment_at_first_column = true
32+
ij_kotlin_call_parameters_new_line_after_left_paren = true
33+
ij_kotlin_call_parameters_right_paren_on_new_line = true
34+
ij_kotlin_call_parameters_wrap = on_every_item
35+
ij_kotlin_catch_on_new_line = false
36+
ij_kotlin_class_annotation_wrap = split_into_lines
37+
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
38+
ij_kotlin_continuation_indent_for_chained_calls = false
39+
ij_kotlin_continuation_indent_for_expression_bodies = false
40+
ij_kotlin_continuation_indent_in_argument_lists = false
41+
ij_kotlin_continuation_indent_in_elvis = false
42+
ij_kotlin_continuation_indent_in_if_conditions = false
43+
ij_kotlin_continuation_indent_in_parameter_lists = false
44+
ij_kotlin_continuation_indent_in_supertype_lists = false
45+
ij_kotlin_else_on_new_line = false
46+
ij_kotlin_enum_constants_wrap = off
47+
ij_kotlin_extends_list_wrap = normal
48+
ij_kotlin_field_annotation_wrap = split_into_lines
49+
ij_kotlin_finally_on_new_line = false
50+
ij_kotlin_if_rparen_on_new_line = true
51+
ij_kotlin_import_nested_classes = false
52+
ij_kotlin_imports_layout = android.**,androidx.**,com.android.**,org.cqfn.diktat.**,*,java.**,javax.**,kotlin.**,kotlinx.**,^
53+
ij_kotlin_insert_whitespaces_in_simple_one_line_method = true
54+
ij_kotlin_keep_blank_lines_before_right_brace = 2
55+
ij_kotlin_keep_blank_lines_in_code = 2
56+
ij_kotlin_keep_blank_lines_in_declarations = 2
57+
ij_kotlin_keep_first_column_comment = true
58+
ij_kotlin_keep_indents_on_empty_lines = false
59+
ij_kotlin_keep_line_breaks = true
60+
ij_kotlin_lbrace_on_next_line = false
61+
ij_kotlin_line_comment_add_space = false
62+
ij_kotlin_line_comment_add_space_on_reformat = false
63+
ij_kotlin_line_comment_at_first_column = true
64+
ij_kotlin_method_annotation_wrap = split_into_lines
65+
ij_kotlin_method_call_chain_wrap = normal
66+
ij_kotlin_method_parameters_new_line_after_left_paren = true
67+
ij_kotlin_method_parameters_right_paren_on_new_line = true
68+
ij_kotlin_method_parameters_wrap = on_every_item
69+
ij_kotlin_name_count_to_use_star_import = 2147483647
70+
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
71+
ij_kotlin_parameter_annotation_wrap = off
72+
ij_kotlin_space_after_comma = true
73+
ij_kotlin_space_after_extend_colon = true
74+
ij_kotlin_space_after_type_colon = true
75+
ij_kotlin_space_before_catch_parentheses = true
76+
ij_kotlin_space_before_comma = false
77+
ij_kotlin_space_before_extend_colon = true
78+
ij_kotlin_space_before_for_parentheses = true
79+
ij_kotlin_space_before_if_parentheses = true
80+
ij_kotlin_space_before_lambda_arrow = true
81+
ij_kotlin_space_before_type_colon = false
82+
ij_kotlin_space_before_when_parentheses = true
83+
ij_kotlin_space_before_while_parentheses = true
84+
ij_kotlin_spaces_around_additive_operators = true
85+
ij_kotlin_spaces_around_assignment_operators = true
86+
ij_kotlin_spaces_around_equality_operators = true
87+
ij_kotlin_spaces_around_function_type_arrow = true
88+
ij_kotlin_spaces_around_logical_operators = true
89+
ij_kotlin_spaces_around_multiplicative_operators = true
90+
ij_kotlin_spaces_around_range = false
91+
ij_kotlin_spaces_around_relational_operators = true
92+
ij_kotlin_spaces_around_unary_operator = false
93+
ij_kotlin_spaces_around_when_arrow = true
94+
ij_kotlin_variable_annotation_wrap = off
95+
ij_kotlin_while_on_new_line = false
96+
ij_kotlin_wrap_elvis_expressions = 1
97+
ij_kotlin_wrap_expression_body_functions = 1
98+
ij_kotlin_wrap_first_method_in_call_chain = false

.github/workflows/build_and_test.yml

+64
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ jobs:
118118
name: Build and test
119119
runs-on: ${{ matrix.os }}
120120
strategy:
121+
# We need multiple builds to run even if the 1st one is failing, because
122+
# test failures may be OS-specific (or the tests themselves flaky).
123+
fail-fast: false
121124
matrix:
122125
os: [ windows-latest, macos-latest ]
123126
steps:
@@ -147,10 +150,71 @@ jobs:
147150
mvn -B -T1C clean install
148151
shell: cmd
149152

153+
# This step needs a Git repository, so it's impossible to extract it
154+
# into a separate job (or, otherwise, we'd need to upload the content
155+
# of the whole `.git` folder as an artifact).
156+
- name: JUnit Tests (dorny/test-reporter@v1)
157+
uses: dorny/test-reporter@v1
158+
if: ${{ always() }}
159+
with:
160+
name: JUnit Tests (${{ runner.os }}, dorny/test-reporter@v1)
161+
# Comma-separated values.
162+
path: "**/target/*-reports/TEST-*.xml, **/build/test-results/*/TEST-*.xml"
163+
reporter: java-junit
164+
165+
- name: Upload test results
166+
uses: actions/upload-artifact@v3
167+
if: ${{ always() }}
168+
with:
169+
name: xml-test-reports-${{ runner.os }}
170+
path: |
171+
**/target/*-reports/TEST-*.xml
172+
**/build/test-results/*/TEST-*.xml
173+
retention-days: 1
174+
150175
- name: Upload gradle reports
151176
if: ${{ failure() }}
152177
uses: actions/upload-artifact@v3
153178
with:
154179
name: gradle-test-report-${{ matrix.os }}
155180
path: 'diktat-gradle-plugin/build/reports/'
156181
retention-days: 1
182+
183+
report:
184+
name: Publish JUnit test results
185+
if: ${{ always() }}
186+
needs: build_and_test
187+
runs-on: ${{ matrix.os }}
188+
189+
strategy:
190+
matrix:
191+
os: [ windows-latest, macos-latest ]
192+
193+
permissions:
194+
checks: write
195+
pull-requests: write
196+
197+
steps:
198+
- uses: actions/download-artifact@v3
199+
if: ${{ always() }}
200+
with:
201+
name: xml-test-reports-${{ runner.os }}
202+
203+
# Uses Docker, that's why Linux-only.
204+
- name: JUnit Tests (EnricoMi/publish-unit-test-result-action@v1, Linux)
205+
uses: EnricoMi/publish-unit-test-result-action@v1
206+
if: ${{ runner.os == 'Linux' }}
207+
with:
208+
check_name: JUnit Tests (${{ runner.os }}, EnricoMi/publish-unit-test-result-action@v1)
209+
files: |
210+
**/target/*-reports/TEST-*.xml
211+
**/build/test-results/*/TEST-*.xml
212+
213+
- name: JUnit Tests (EnricoMi/publish-unit-test-result-action@v1, Windows or Mac OS X)
214+
uses: EnricoMi/publish-unit-test-result-action/composite@v1
215+
if: ${{ runner.os == 'Windows' || runner.os == 'macOS' }}
216+
with:
217+
check_name: JUnit Tests (${{ runner.os }}, EnricoMi/publish-unit-test-result-action@v1)
218+
files: |
219+
**/target/*-reports/TEST-*.xml
220+
**/build/test-results/*/TEST-*.xml

README.md

+41-12
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DiKTat is a strict [coding standard ](info/guide/diktat-coding-convention.md) fo
2020
as AST visitors on the top of [KTlint](https://ktlint.github.io/). It can be used for detecting and autofixing code smells in CI/CD process.
2121
The full list of available supported rules and inspections can be found [here](info/available-rules.md).
2222

23-
Now diKTat was already added to the lists of [static analysis tools](https://github.com/analysis-tools-dev/static-analysis), to [kotlin-awesome](https://github.com/KotlinBy/awesome-kotlin) and to [kompar](https://catalog.kompar.tools/Analyzer/diKTat/1.1.0). Thanks to the community for this support!
23+
Now diKTat was already added to the lists of [static analysis tools](https://github.com/analysis-tools-dev/static-analysis), to [kotlin-awesome](https://github.com/KotlinBy/awesome-kotlin) and to [kompar](https://catalog.kompar.tools/Analyzer/diKTat/1.2.0). Thanks to the community for this support!
2424

2525
## See first
2626

@@ -56,11 +56,11 @@ Main features of diktat are the following:
5656
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.43.2/ktlint && chmod a+x ktlint
5757
```
5858

59-
2. Load diKTat manually: [here](https://github.com/saveourtool/diKTat/releases/download/v1.1.0/diktat-1.1.0.jar)
59+
2. Load diKTat manually: [here](https://github.com/saveourtool/diKTat/releases/download/v1.2.0/diktat-1.2.0.jar)
6060

6161
**OR** use curl:
6262
```bash
63-
$ curl -sSLO https://github.com/saveourtool/diKTat/releases/download/v1.1.0/diktat-1.1.0.jar
63+
$ curl -sSLO https://github.com/saveourtool/diKTat/releases/download/v1.2.0/diktat-1.2.0.jar
6464
```
6565
</details>
6666

@@ -187,7 +187,7 @@ This plugin is available since version 0.1.5. You can see how the plugin is conf
187187

188188
```kotlin
189189
plugins {
190-
id("org.cqfn.diktat.diktat-gradle-plugin") version "1.1.0"
190+
id("org.cqfn.diktat.diktat-gradle-plugin") version "1.2.0"
191191
}
192192
```
193193

@@ -198,7 +198,7 @@ buildscript {
198198
mavenCentral()
199199
}
200200
dependencies {
201-
classpath("org.cqfn.diktat:diktat-gradle-plugin:1.1.0")
201+
classpath("org.cqfn.diktat:diktat-gradle-plugin:1.2.0")
202202
}
203203
}
204204

@@ -219,17 +219,17 @@ diktat {
219219
Also `diktat` extension has different reporters. You can specify `json`, `html`, `sarif`, `plain` (default) or your own custom reporter (it should be added as a dependency into `diktat` configuration):
220220
```kotlin
221221
diktat {
222-
// since 1.1.0 to keep in line with maven properties
222+
// since 1.2.0 to keep in line with maven properties
223223
reporter = "json" // "html", "json", "plain" (default), "sarif"
224-
// before 1.1.0
224+
// before 1.2.0
225225
// reporterType = "json" // "html", "json", "plain" (default), "sarif"
226226
}
227227
```
228228

229229
You can also specify an output.
230230
```kotlin
231231
diktat {
232-
// since 1.1.0 (reporterType for old versions)
232+
// since 1.2.0 (reporterType for old versions)
233233
reporter = "json"
234234
output = "someFile.json"
235235
}
@@ -270,7 +270,7 @@ spotless {
270270
```kotlin
271271
spotless {
272272
kotlin {
273-
diktat("1.1.0").configFile("full/path/to/diktat-analysis.yml")
273+
diktat("1.2.0").configFile("full/path/to/diktat-analysis.yml")
274274
}
275275
}
276276
```
@@ -301,7 +301,7 @@ Diktat can be run via spotless-maven-plugin since version 2.8.0
301301

302302
```xml
303303
<diktat>
304-
<version>1.1.0</version> <!-- optional -->
304+
<version>1.2.0</version> <!-- optional -->
305305
<configFile>full/path/to/diktat-analysis.yml</configFile> <!-- optional, configuration file path -->
306306
</diktat>
307307
```
@@ -374,7 +374,8 @@ Also see [the list of all rules supported by diKTat](info/available-rules.md).
374374

375375
<details>
376376
<summary>Suppress warnings on individual code blocks</summary>
377-
In addition to enabling/disabling warning globally via config file (`enable = false`), you can suppress warnings by adding `@Suppress` annotation on individual code blocks
377+
In addition to enabling/disabling warning globally via config file (`enable = false`), you can suppress warnings
378+
by adding `@Suppress` annotation on individual code blocks or `@file:Suppress()` annotation on a file-level.
378379

379380
For example:
380381

@@ -389,7 +390,35 @@ class SomeClass {
389390
</details>
390391

391392
<details>
392-
<summary>Suppress groups of inspections</summary>
393+
<summary>Disable all inspections on selected code blocks</summary>
394+
Also you can suppress **all** warnings by adding `@Suppress("diktat")` annotation on individual code blocks.
395+
396+
For example:
397+
398+
``` kotlin
399+
@Suppress("diktat")
400+
class SomeClass {
401+
fun methODTREE(): String {
402+
403+
}
404+
}
405+
```
406+
</details>
407+
408+
<details>
409+
<summary>ignoreAnnotated: disable inspections on blocks with predefined annotation</summary>
410+
In the `diktat-analysis.yml` file for each inspection it is possible to define a list of annotations that will cause
411+
disabling of the inspection on that particular code block:
412+
413+
```yaml
414+
- name: HEADER_NOT_BEFORE_PACKAGE
415+
enabled: true
416+
ignoreAnnotated: [MyAnnotation, Compose, Controller]
417+
```
418+
</details>
419+
420+
<details>
421+
<summary>Suppress groups of inspections by chapters</summary>
393422
It is easy to suppress even groups of inspections in diKTat.
394423

395424
These groups are linked to chapters of [Codestyle](info/guide/diktat-coding-convention.md).

0 commit comments

Comments
 (0)